-
-
Save BUBAIMITRA2018/0ebd48e99a71ef4d9f0c7adf6f43bb4a to your computer and use it in GitHub Desktop.
alldevice class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import callallmotor1D_V1 | |
import callallmotor2D_V1 | |
import callallsov1S_V1 | |
import callallsov2S_V1 | |
import calallanalog_V1 | |
import calallcontrolvalves_V1 | |
import callallvibrofeeder_V1 | |
import callallconveyor_V1 | |
import calallABPdrives_V1 | |
import threading | |
import copy | |
import copyreg | |
import multiprocessing | |
import pandas as pd | |
class AllDevices: | |
def __init__(self,comobject,logger): | |
self.mylock = threading.Lock() | |
self._comobject = comobject | |
dfM1D = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Motor1D') | |
dfM2D = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Motor2D') | |
dfsov1S = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Valve1S') | |
dfsov2S = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Valve2S') | |
dfanalog = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='AnalogTx') | |
dfcontrolvalve = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='ControlValves') | |
dfvibrofeeder = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='VibroFeeder') | |
dfconveyor = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Conveyor') | |
dfdrives = pd.read_excel(r'D:\OPCUA\Working_VF1.xls', sheet_name='Drive') | |
self.allmotor1dobjects = callallmotor1D_V1.Cal_AllMotor1D(dfM1D, comobject, logger) | |
self.allmotor2dobjects = callallmotor2D_V1.Cal_AllMotor2D(dfM2D,comobject,logger) | |
self.allsov1sobjects = callallsov1S_V1.Cal_AllSov1S(dfsov1S,comobject,logger) | |
self.allsov2sobjects = callallsov2S_V1.Cal_AllSov2S(dfsov2S, comobject,logger) | |
self.allanalogobjects = calallanalog_V1.Cal_AllAnalogInputs(dfanalog,comobject,logger) | |
self.allcontrolvalveobjects = calallcontrolvalves_V1.Cal_AllControlValve(dfcontrolvalve,comobject,logger) | |
self.allvibrofeederobjects = callallvibrofeeder_V1.Cal_AllVibroFeeder(dfvibrofeeder,comobject,logger) | |
self.allconveyorobjects = callallconveyor_V1.Cal_AllConveyor1D(dfconveyor,comobject,logger) | |
self.allabbdrivesobjects = calallABPdrives_V1.Cal_AllDrives(dfdrives, comobject,logger) | |
# copyreg.pickle(AllDevices,pickle_alldevice) | |
def __getstate__(self): | |
# Copy the object's state from self.__dict__ which contains | |
# all our instance attributes. Always use the dict.copy() | |
# method to avoid modifying the original state. | |
state = vars(self).copy() | |
# Remove the unpicklable entries. | |
del state['mylock'] | |
return state | |
def __setstate__(self, state): | |
# Restore instance attributes. | |
vars(self).update(state) | |
def __deepcopy__(self, memo): | |
newself = self.__class__.__new__(self.__class__) | |
for name, value in vars(self).items(): | |
if name != 'mylock': | |
value = copy.deepcopy(value) | |
setattr(newself, name, value) | |
return newself | |
@property | |
def allmotor1d(self): | |
return self.allmotor1dobjects | |
@property | |
def allsov1s(self): | |
return self.allsov1sobjects | |
@property | |
def allsov2s(self): | |
return self.allsov2sobjects | |
@property | |
def allanalog(self): | |
return self.allanalogobjects | |
@property | |
def allcontrolvalve(self): | |
return self.allcontrolvalveobjects | |
@property | |
def allvibrofeeder(self): | |
return self.allvibrofeederobjects | |
@property | |
def allconveyor(self): | |
return self.allconveyorobjects | |
@property | |
def allabbdrive(self): | |
return self.allabbdrivesobjects | |
def unpickle_alldevice(state): | |
self = AllDevices.__new__(AllDevices) | |
vars(self).update(state) | |
self.mylock = threading.Lock() | |
return self | |
def pickle_alldevice(ad): | |
state = vars(ad).copy() | |
del state['mylock'] | |
print("Hi") | |
return unpickle_alldevice,(state,) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment