在freeopcua服务器中定义输入参数类型和-name

时间:2018-12-28 09:25:59

标签: python-3.x opc-ua octoprint

我正在为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个输入字段的表单。但是它们都没有名称或类型。我希望每个输入字段都具有名称和数据类型。

0 个答案:

没有答案