20import RapidCodeHelpers
as helpers
22rapidcode_dir = helpers.find_rapid_code_directory()
25os.add_dll_directory(
"c:\\Program Files (x86)\\INtime\\bin")
28sys.path.append(rapidcode_dir)
33def print_topology(controller:RapidCode.MotionController):
35 overview =
"EtherCAT: {} Nodes, {} {}".format(controller.NetworkNodeCountGet(), controller.NetworkTypeGet(), controller.NetworkStateGet())
36 stringBuilder.append(overview)
39 for i
in range(controller.NetworkNodeCountGet()):
40 io = controller.IOGet(i)
41 helpers.check_errors(io)
42 if(io.NetworkNode.Exists()):
43 Nodes.append(io.NetworkNode)
47 stringBuilder.append(
"")
48 stringBuilder.append(
"Node[{}] - {} ______________________________________________".format(node.NumberGet(), node.NameGet()))
49 stringBuilder.append(
" Vendor: {} ".format(node.VendorNameGet() +
"Product: {}".format(node.ProductNameGet())))
50 stringBuilder.append(
" VendorID: 0x{:08X} ProductCode: 0x{:08X}".format(node.VendorIdGet(), node.ProductCodeGet()))
51 stringBuilder.append(
" HardwareRev: 0x{:08X} SerialNumber: {}".format(node.RevisionGet(), node.SerialNumberGet()))
52 stringBuilder.append(
" StationAlias: 0x{:08X} AxisCount: {}".format(node.StationAliasGet(), node.AxisCountGet()))
53 stringBuilder.append(
" SegmentCount: {}".format(node.SegmentCountGet()))
54 stringBuilder.append(
" DI: {} DO: {} AI: {} AO: {}".format(node.DigitalInCountGet(), node.DigitalOutCountGet(), node.AnalogInCountGet(), node.AnalogOutCountGet()))
56 stringBuilder.append(
"")
57 pdoInputs = controller.NetworkInputCountGet()
58 stringBuilder.append(
"NetworkInputs count: {} _________________________________".format(pdoInputs))
59 for i
in range(pdoInputs):
60 stringBuilder.append(
" [{}] - {} Bits: {}".format(i, controller.NetworkInputNameGet(i).ljust(70), controller.NetworkInputBitSizeGet(i)))
62 pdoOutputs = controller.NetworkOutputCountGet()
63 stringBuilder.append(
"NetworkOutputs count: {} _________________________________".format(pdoOutputs))
64 for i
in range(pdoOutputs):
65 stringBuilder.append(
" [{}] - {} Bits: {}".format(i, controller.NetworkOutputNameGet(i).ljust(70), controller.NetworkOutputBitSizeGet(i)))
67 print(
"\n".join(stringBuilder))
72 print(
"Hello, RapidCode.")
74 motionController:RapidCode.MotionController = RapidCode.MotionController.CreateFromSoftware(rapidcode_dir)
75 print(
"This object is a "+str(type(motionController)))
78 print(
"MotionController creation error count: ", motionController.ErrorLogCountGet())
79 helpers.check_errors(motionController)
81 print(
"RapidCode Version: ", motionController.VersionGet())
82 print(
"Serial Number: ", motionController.SerialNumberGet())
83 print(
"Axis Count: ", motionController.AxisCountGet())
85 if motionController.NetworkStateGet() == RapidCode.RSINetworkState_RSINetworkStateOPERATIONAL:
86 print_topology(motionController)
91if __name__ ==
'__main__':