我一直在努力将Fuzzylite集成到我的模拟器Castalia中,到目前为止,在Fuzzylite src文件夹下有一个与Console.cpp相关的错误。 为了将Fuzzylite链接到我的模拟器Castalia,我在Castalia下的makemake文件中添加了 EXTOPTS ,
#!/bin/bash
ROOT=`pwd`
# The following options are used by OMNeT's opp_makemake tool
# For explanation and a complete list of options run: opp_makemake -h
OPTS=" -f -r --deep -o CastaliaBin -u Cmdenv -P $ROOT -M release"
# -X excludes a directory from being considered
EXCLUDEDIRS=" -X Simulations -X out -X bin"
# Use options -I -L -l to include external header files or libraries
EXTOPTS="-I /home/utar/Desktop/HY/fuzzylite-6.0/fuzzylite/ -L /home/utar/Desktop/HY/fuzzylite-6.0/fuzzylite/release/bin/ -lfuzzylite"
# Run OMNeT's opp_makemake tool with the above options
opp_makemake $OPTS $EXCLUDEDIRS $EXTOPTS
然后在编译顺利运行时,模拟根本无法运行。跟踪文件后,我能够跟踪由Python编写的Castalia bin文件导致的问题根源。以下是我关注的代码片段:
r_castalia = re.compile("^Castalia\|\s+(.+)$")
r_scenario = re.compile("Scenario:\s(.*)\$repetition=(\d+)$")
r_progress = re.compile("^\*\* Event \#\d+\s+T=(\S+)\s+Elapsed: (\S+)s.+\s(\d+)\% completed")
r_newrun = re.compile("Preparing for running configuration General, run #(\d+)")
r_totalrun = re.compile("Number of runs: (\d+)")
for ini in iniList:
ini_num += 1
baselabel = label = labelList.pop(0)
f = open("omnetpp.tmp","w")
f.write("[General]\n")
f.write("repeat = " + str(options.repeat) + "\n")
for k in sorted(ini.keys()):
f.write(k + " = " + ini[k] + "\n")
f.close();
has_output = 0
print "path to CastaliaBint is : " + pathToCastaliaBin
if sys.version_info > (2,7):
data = subprocess.check_output([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")
#data = subprocess.check_output(["/home/utar/Desktop/Castalia/CastaliaBin", '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")
else:
data = subprocess.Popen([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General'], stdout=subprocess.PIPE).communicate()[0].split("\n")
if len(data) > 6: data = data[6]
else:
data = ""
m = r_totalrun.match(data)
print "r_totalrun is : " + str(r_totalrun)
if (m):
runs = "/" + m.group(1)
else:
print "WARNING: unable to determine total simulation runs"
runs = ""
结果,输出显示了这个:
警告:无法确定总模拟运行
焦点在于:
if sys.version_info > (2,7):
data = subprocess.check_output([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")
花了一些时间搞清楚问题,据了解,变量数据通过使用print函数显示以下输出:
数据是['[选项错误]选项< -f>不承认','{at /src/Console.cpp::parse()[line:134]}',“,”]
我意识到CastaliaBin以某种方式执行位于Fuzzylite的src文件下的Console.cpp !!!
变量pathToCastaliaBin实际上是/ home / utar / Desktop / Castalia / CastaliaBin的路径,其中CastaliaBin是可执行文件。
对于Fuzzylite库未包含在Castalia Simulator中的正常情况,当我在命令行中键入CastaliaBin时,它将显示如下:Before Fuzzylite is included
将Fuzzylite与Castalia链接后,显示: After Fuzzylite is included
如您所见,CastaliaBin以某种方式执行Fuzzylite中的代码!
所以我希望有人可以伸出援助之手。我非常感激。在此先感谢!!!
答案 0 :(得分:0)
完整地解释您的问题并自行调查的好工作。
从你得到的输出中,似乎当你运行import unittest
import unittest.mock as mock
import mycity.intents.intent_constants as intent_constants
import mycity.mycity_controller as my_controller
import mycity.mycity_request_data_model as req
import mycity.test.test_constants as test_constants
###############################################################################
# TestCase parent class for all intent TestCases, which are integration tests #
# to see if any changes in codebase have broken response-request model. #
# #
# NOTE: Assumes that address has already been set. #
###############################################################################
class IntentBaseCase(unittest.TestCase):
intent_to_test = None
returns_reprompt_text = False
def setUp(self):
self.controller = my_controller
self.request = req.MyCityRequestDataModel()
key = intent_constants.CURRENT_ADDRESS_KEY
self.request._session_attributes[key] = "1000 Dorchester Ave"
self.request.intent_name = self.intent_to_test
def tearDown(self):
self.controller = None
self.request = None
构建Castalia时,它会构建fuzzylite,makemake
基本上运行fuzzylite库的命令行工具。显然这不是你想要的。
确保:
在构建Castalia之前,您根据此库的安装说明构建了fuzzylite。如果成功完成,您应该能够在fuzzylite目录中找到文件名CastaliaBin
或libfuzzylite.a
(或安装过程放置的任何位置。
注意此库文件所在的位置(哪个目录)并将此目录与libfuzzylite.so
开关一起使用。也许图书馆不在-L
找到header-files目录并将其与release/bin/
开关一起使用。不要包含整个fuzzylite目录。查看Fyzzylite's Github repo标题目录似乎是-I
最后here's general info关于在C中编译静态库,这样你就可以获得更好的视角。我怀疑Fuzzylite的安装过程隐藏了大部分内容,但了解一般原则是很好的。
答案 1 :(得分:0)
仔细检查您包含的Fuzzylite项目(.cc和.h) 确保包含文件没有main()函数。 主要功能将与Castalia或Omnetpp项目设置冲突