Edouard@0: #!/usr/bin/env python Edouard@0: # -*- coding: utf-8 -*- Edouard@0: Edouard@0: #This file is part of Beremiz, a Integrated Development Environment for Edouard@0: #programming IEC 61131-3 automates supporting plcopen standard and CanFestival. Edouard@0: # Edouard@0: #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD Edouard@0: # Edouard@0: #See COPYING file for copyrights details. Edouard@0: # Edouard@0: #This library is free software; you can redistribute it and/or Edouard@0: #modify it under the terms of the GNU General Public Edouard@0: #License as published by the Free Software Foundation; either Edouard@0: #version 2.1 of the License, or (at your option) any later version. Edouard@0: # Edouard@0: #This library is distributed in the hope that it will be useful, Edouard@0: #but WITHOUT ANY WARRANTY; without even the implied warranty of Edouard@0: #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Edouard@0: #General Public License for more details. Edouard@0: # Edouard@0: #You should have received a copy of the GNU General Public Edouard@0: #License along with this library; if not, write to the Free Software Edouard@0: #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Edouard@0: Edouard@0: from LPCProto import * Edouard@0: Edouard@0: Edouard@0: Edouard@0: class LPCObject(): Edouard@0: def __init__(self, confnodesroot, comportstr): Edouard@0: self.PLCStatus = "Disconnected" Edouard@0: self.confnodesroot = confnodesroot Edouard@0: self.PLCprint = confnodesroot.logger.writeyield Edouard@0: self._Idxs = [] Edouard@0: comport = int(comportstr[3:]) - 1 Edouard@0: try: Edouard@0: self.connect(comportstr) Edouard@0: except Exception,e: Edouard@0: self.confnodesroot.logger.write_error(str(e)+"\n") Edouard@0: self.SerialConnection = None Edouard@0: self.PLCStatus = "Disconnected" Edouard@0: Edouard@0: def HandleSerialTransaction(self, transaction): Edouard@0: if self.SerialConnection is not None: Edouard@0: try: Edouard@0: self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction) Edouard@0: return res Edouard@0: except LPCProtoError,e: Edouard@0: self.confnodesroot.logger.write(_("PLC disconnected\n")) Edouard@0: if self.SerialConnection is not None: Edouard@0: self.SerialConnection.close() Edouard@0: self.SerialConnection = None Edouard@0: self.PLCStatus = "Disconnected" Edouard@0: return None Edouard@0: except Exception,e: Edouard@0: self.confnodesroot.logger.write_warning(str(e)+"\n") Edouard@0: Edouard@0: def StartPLC(self, debug=False): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def StopPLC(self): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def GetPLCstatus(self): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def NewPLC(self, md5sum, data, extrafiles): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def MatchMD5(self, MD5): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def SetTraceVariablesList(self, idxs): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: Edouard@0: def GetTraceVariables(self): Edouard@0: raise LPCProtoError("Not implemented") Edouard@0: