def __init__(self, parent, variable, store_data=False): """ Constructor @param parent: Reference to debug variable panel @param variable: Path of variable to debug """ DebugDataConsumer.__init__(self) self.Parent = parent self.Variable = variable self.StoreData = store_data # Get Variable data type self.RefreshVariableType()
def __init__(self, parent, type, name, id=None): Graphic_Element.__init__(self, parent) DebugDataConsumer.__init__(self) self.Type = type self.Name = name self.Id = id self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) self.Highlights = {} # Create an input and output connector self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) self.PreviousValue = False self.PreviousSpreading = False self.RefreshNameSize() self.RefreshTypeSize()
def __init__(self, parent, type, name, id = None): Graphic_Element.__init__(self, parent) DebugDataConsumer.__init__(self) self.Type = type self.Name = name self.Id = id self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) self.Highlights = {} # Create an input and output connector self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) self.PreviousValue = False self.PreviousSpreading = False self.RefreshNameSize() self.RefreshTypeSize()
def NewValues(self, ticks, values): """ Function called by debug thread when a new debug value is available @param tick: PLC tick when value was captured @param value: Value captured @param forced: Forced flag, True if value is forced (default: False) """ DebugDataConsumer.NewValues(self, ticks[-1], values[-1], raw=None) if self.Data is not None: if self.VariableType in ["STRING", "WSTRING"]: last_raw_data = (self.RawData[-1] if len(self.RawData) > 0 else None) last_raw_data_idx = len(self.RawData) - 1 data_values = [] for tick, (value, forced) in list(zip(ticks, values)): # Translate forced flag to float for storing in Data table forced_value = float(forced) if self.VariableType in ["STRING", "WSTRING"]: # String data value is CRC num_value = (binascii.crc32(value) & STRING_CRC_MASK) elif self.VariableType in ["TIME", "TOD", "DT", "DATE"]: # Numeric value of time type variables # is represented in seconds num_value = float(value.total_seconds()) else: num_value = float(value) # Update variable range values self.MinValue = (min(self.MinValue, num_value) if self.MinValue is not None else num_value) self.MaxValue = (max(self.MaxValue, num_value) if self.MaxValue is not None else num_value) # In the case of string variables, we store raw string value and # forced flag in raw data table. Only changes in this two values # are stored. Index to the corresponding raw value is stored in # data third column if self.VariableType in ["STRING", "WSTRING"]: raw_data = (value, forced_value) if len(self.RawData) == 0 or last_raw_data != raw_data: last_raw_data_idx += 1 last_raw_data = raw_data self.RawData.append(raw_data) extra_value = last_raw_data_idx # In other case, data third column is forced flag else: extra_value = forced_value data_values.append([float(tick), num_value, extra_value]) # Add New data to stored data table self.Data = numpy.append(self.Data, data_values, axis=0) # Signal to debug variable panel to refresh self.Parent.HasNewData = True