-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpump_library.py
More file actions
123 lines (106 loc) · 3.33 KB
/
Copy pathpump_library.py
File metadata and controls
123 lines (106 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# -*-coding:utf-8 -*-
# *****************************
# COPYRIGHT 2019 Smiths Medical.
# Created Date: 2019-11
# Author: Li Wang
# Description: This library is used for test automation on pump, including C9 Syringe and C9 LVP pump.
# *****************************
import os
import sys
current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(current_dir)
sys.path.append("..")
from PumpLibrary.Keywords import *
from version import VERSION
from SerialDevice.pump_connect import *
from ParserProtocol.protocol_invoker import *
from global_attributes import setCommandFormat
class PumpLibrary(
Info,
Infusion,
InfusionParameter,
DeviceReport,
HistoryLog,
InfusionSetting,
Maintenance,
SafetySetting,
SystemSetting,
Alarm,
Bolus,
Priming,
Motor,
Sensor,
):
ROBOT_LIBRARY_SCOPE = "GLOBAL"
ROBOT_LIBRARY_VERSION = VERSION
def __init__(self):
for base in PumpLibrary.__bases__:
base.__init__(self)
self.commandFormat = "Protocol"
self.parser_invoker = None
self.sequence_id = 0
self.port = None
self.connectObj = None
self.product_id = PRODUCT_ID
setCommandFormat(self.commandFormat)
self.dllParser(lvp_project_dll_path)
def buildConnect(self, pump, connect_way):
"""
Build connection with pump, decide connection object and way.
Two connection objects are provided now: C9LVP,C9
Three connection ways are provided now: COM, IO, Ethernet
:param pump: the pump, such as C9LVP and C9
:param connect_way: the connect way, such as com or ethernet.
:return: None
Examples:
| Build Connect | C9LVP | COM |
"""
self.connectObj = PumpConnect(pump, connect_way).connect()
def setCommandFormat(self, command_format):
"""
Set request command format
Two ways are provided now: String and Hex, the default is String.
:param command_format: command format, such as string command or dll commands.
:return: None
Examples:
| Decide Send Way | Pump |
"""
self.commandFormat = command_format
setCommandFormat(self.commandFormat)
def breakConnect(self):
"""
Break the serial connection.
:return: None
"""
self.connectObj.close()
def dllParser(self, dll_path=r'.\ProtocolParser\ProtocolParser_x64.dll'):
"""
Choose the protocol file.
:param path: The absolute path of the file.
:return: None
"""
if os.path.exists(dll_path):
self.parser_invoker = ProtocolParserInvoker(dll_path)
print(self.parser_invoker.get_infusion_mode_command_bytes(1, 2))
else:
print("Error, Wrong Dll File.")
return self.parser_invoker
def productID(self, product_id):
"""
Choose the product id to use in dll.
:param product_id:
Graseby™ C9: 0x01
Graseby™ C9LVP: 0x02
:return:None
"""
self.product_id = product_id
if __name__ == "__main__":
lvp = PumpLibrary()
lvp.buildConnect("C9LVP", "COM")
lvp.setCommandFormat("Hex")
lvp.productID(0x02)
"""
"""
print("--" * 50)
lvp.start_infusion()
print("--" * 50)