connectors/LPC/LPCObject.py
changeset 734 5c42cafaee15
parent 733 915be999f3f0
child 735 d9f4ecee761d
equal deleted inserted replaced
733:915be999f3f0 734:5c42cafaee15
     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 
       
    25 from LPCProto import *
       
    26 
       
    27 
       
    28 
       
    29 class LPCObject():
       
    30     def __init__(self, confnodesroot, comportstr):
       
    31         self.PLCStatus = "Disconnected"
       
    32         self.confnodesroot = confnodesroot
       
    33         self.PLCprint = confnodesroot.logger.writeyield
       
    34         self._Idxs = []
       
    35         comport = int(comportstr[3:]) - 1
       
    36         try:
       
    37             self.connect(comportstr)
       
    38         except Exception,e:
       
    39             self.confnodesroot.logger.write_error(str(e)+"\n")
       
    40             self.SerialConnection = None
       
    41             self.PLCStatus = "Disconnected"
       
    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
       
    48             except LPCProtoError,e:
       
    49                 self.confnodesroot.logger.write(_("PLC disconnected\n"))
       
    50                 if self.SerialConnection is not None:
       
    51                     self.SerialConnection.close()
       
    52                     self.SerialConnection = None
       
    53                 self.PLCStatus = "Disconnected"
       
    54                 return None
       
    55             except Exception,e:
       
    56                 self.confnodesroot.logger.write_warning(str(e)+"\n")
       
    57         
       
    58     def StartPLC(self, debug=False):
       
    59         raise LPCProtoError("Not implemented")
       
    60             
       
    61     def StopPLC(self):
       
    62         raise LPCProtoError("Not implemented")
       
    63 
       
    64     def GetPLCstatus(self):
       
    65         raise LPCProtoError("Not implemented")
       
    66     
       
    67     def NewPLC(self, md5sum, data, extrafiles):
       
    68         raise LPCProtoError("Not implemented")
       
    69 
       
    70     def MatchMD5(self, MD5):
       
    71         raise LPCProtoError("Not implemented")
       
    72 
       
    73     def SetTraceVariablesList(self, idxs):
       
    74         raise LPCProtoError("Not implemented")
       
    75 
       
    76     def GetTraceVariables(self):
       
    77         raise LPCProtoError("Not implemented")
       
    78