author | Edouard Tisserant |
Sat, 19 May 2012 19:00:55 +0200 | |
changeset 733 | 915be999f3f0 |
parent 717 | 1c23952dbde1 |
permissions | -rwxr-xr-x |
448 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of Beremiz, a Integrated Development Environment for |
|
5 |
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
|
6 |
# |
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
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 |
|
24 |
||
453 | 25 |
from LPCProto import * |
448 | 26 |
|
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
563
diff
changeset
|
27 |
|
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
563
diff
changeset
|
28 |
|
448 | 29 |
class LPCObject(): |
717 | 30 |
def __init__(self, confnodesroot, comportstr): |
508 | 31 |
self.PLCStatus = "Disconnected" |
717 | 32 |
self.confnodesroot = confnodesroot |
33 |
self.PLCprint = confnodesroot.logger.writeyield |
|
453 | 34 |
self._Idxs = [] |
556
1ad4e7f1e89e
LPC Composer don't send comma at the end of serial port name.
Lolitech
parents:
545
diff
changeset
|
35 |
comport = int(comportstr[3:]) - 1 |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
36 |
try: |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
37 |
self.connect(comportstr) |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
38 |
except Exception,e: |
717 | 39 |
self.confnodesroot.logger.write_error(str(e)+"\n") |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
40 |
self.SerialConnection = None |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
41 |
self.PLCStatus = "Disconnected" |
508 | 42 |
|
43 |
def HandleSerialTransaction(self, transaction): |
|
44 |
if self.SerialConnection is not None: |
|
45 |
try: |
|
46 |
self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction) |
|
47 |
return res |
|
578 | 48 |
except LPCProtoError,e: |
717 | 49 |
self.confnodesroot.logger.write(_("PLC disconnected\n")) |
578 | 50 |
if self.SerialConnection is not None: |
51 |
self.SerialConnection.close() |
|
52 |
self.SerialConnection = None |
|
53 |
self.PLCStatus = "Disconnected" |
|
54 |
return None |
|
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
563
diff
changeset
|
55 |
except Exception,e: |
717 | 56 |
self.confnodesroot.logger.write_warning(str(e)+"\n") |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
57 |
|
448 | 58 |
def StartPLC(self, debug=False): |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
59 |
raise LPCProtoError("Not implemented") |
448 | 60 |
|
61 |
def StopPLC(self): |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
62 |
raise LPCProtoError("Not implemented") |
448 | 63 |
|
64 |
def GetPLCstatus(self): |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
65 |
raise LPCProtoError("Not implemented") |
448 | 66 |
|
67 |
def NewPLC(self, md5sum, data, extrafiles): |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
68 |
raise LPCProtoError("Not implemented") |
448 | 69 |
|
70 |
def MatchMD5(self, MD5): |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
71 |
raise LPCProtoError("Not implemented") |
502 | 72 |
|
73 |
def SetTraceVariablesList(self, idxs): |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
74 |
raise LPCProtoError("Not implemented") |
502 | 75 |
|
448 | 76 |
def GetTraceVariables(self): |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
525
diff
changeset
|
77 |
raise LPCProtoError("Not implemented") |
448 | 78 |