equal
deleted
inserted
replaced
22 #License along with this library; if not, write to the Free Software |
22 #License along with this library; if not, write to the Free Software |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
25 from LPCProto import * |
25 from LPCProto import * |
26 |
26 |
|
27 |
|
28 |
27 class LPCObject(): |
29 class LPCObject(): |
28 def __init__(self, pluginsroot, comportstr): |
30 def __init__(self, pluginsroot, comportstr): |
29 self.PLCStatus = "Disconnected" |
31 self.PLCStatus = "Disconnected" |
30 self.pluginsroot = pluginsroot |
32 self.pluginsroot = pluginsroot |
31 self.PLCprint = pluginsroot.logger.write |
33 self.PLCprint = pluginsroot.logger.writeyield |
32 self._Idxs = [] |
34 self._Idxs = [] |
33 comport = int(comportstr[3:]) - 1 |
35 comport = int(comportstr[3:]) - 1 |
34 try: |
36 try: |
35 self.connect(comportstr) |
37 self.connect(comportstr) |
36 except Exception,e: |
38 except Exception,e: |
41 def HandleSerialTransaction(self, transaction): |
43 def HandleSerialTransaction(self, transaction): |
42 if self.SerialConnection is not None: |
44 if self.SerialConnection is not None: |
43 try: |
45 try: |
44 self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction) |
46 self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction) |
45 return res |
47 return res |
46 except LPCProtoError,e: |
48 except Exception,e: |
47 self.pluginsroot.logger.write_error(str(e)+"\n") |
49 self.pluginsroot.logger.write_error(str(e)+"\n") |
48 self.SerialConnection.close() |
50 self.SerialConnection.close() |
49 self.SerialConnection = None |
51 self.SerialConnection = None |
50 self.PLCStatus = "Disconnected" |
52 self.PLCStatus = "Disconnected" |
51 return None |
53 return None |