我正在为octoprint服务器编程一个opc服务器。 opc服务器必须与octoprint服务器进行通信。一种opc方法是通过在opc客户端gui上传递stl文件的路径来发出切片过程。由于我是这一部分的菜鸟,所以我不知道如何定义输入参数的名称和类型。
inargs = []
for name, dtype in {"File Path": VariantType.String,
"Output Path": VariantType.String,
"Config File": VariantType.String,
"Auto Upload": VariantType.Boolean}.items():
# inarg = ua.Argument()
# inarg.Name = name
inargs.append(dtype)
outargs = [VariantType.String, VariantType.Boolean]
self.sliceStl: Node = self.processData.add_method(self.addrSpace, "Slice STL", self._sliceStl, inargs, outargs)
@uamethod
def _sliceStl(self, parent, filePath: str="~/Uploads/CalibrationCube.stl",
outputPath: str="~/GCODE/",
configFile: str="~/Slic3r/tevo_config.ini",
autoUpload=True,
select=False,
_print=False):
if not filePath.endswith(".stl"):
raise Exception("Slic3rError: File must have *.stl format!")
command = f"~/Slic3r/slic3r {filePath} " \
f"--load {configFile} -o {outputPath} " \
"--output-filename-format [input_filename_base].gcode"
os.system(command)
if autoUpload:
return self._uploadGcode(filePath.replace(".stl", ".gcode"), select, print)
else:
return True
在opc-client gui OPC Client Gui Method Form中调用sliceStl()时,将弹出一个带有4个输入字段的表单。但是它们都没有名称或类型。我希望每个输入字段都具有名称和数据类型。