editors/DebugViewer.py
branch1.1 Korean release
changeset 1384 02fe382c4511
parent 1365 debc97102b23
child 1431 df59be5afb08
equal deleted inserted replaced
1280:72a826dfcfbb 1384:02fe382c4511
   104         # debugging
   104         # debugging
   105         if self.SubscribeTick and self.Debug:
   105         if self.SubscribeTick and self.Debug:
   106             
   106             
   107             # Subscribe tick to new data producer
   107             # Subscribe tick to new data producer
   108             if producer is not None:
   108             if producer is not None:
   109                 producer.SubscribeDebugIECVariable("__tick__", self)
   109                 producer.SubscribeDebugIECVariable("__tick__", self, True)
   110             
   110             
   111             # Unsubscribe tick from old data producer
   111             # Unsubscribe tick from old data producer
   112             if getattr(self, "DataProducer", None) is not None:
   112             if getattr(self, "DataProducer", None) is not None:
   113                 self.DataProducer.UnsubscribeDebugIECVariable("__tick__", self)
   113                 self.DataProducer.UnsubscribeDebugIECVariable("__tick__", self)
   114         
   114         
   132             consumer.Inhibit(inhibit)
   132             consumer.Inhibit(inhibit)
   133         
   133         
   134         # Save inhibit flag
   134         # Save inhibit flag
   135         self.Inhibited = inhibit
   135         self.Inhibited = inhibit
   136     
   136     
   137     def AddDataConsumer(self, iec_path, consumer):
   137     def AddDataConsumer(self, iec_path, consumer, buffer_list=False):
   138         """
   138         """
   139         Subscribe data consumer to DataProducer
   139         Subscribe data consumer to DataProducer
   140         @param iec_path: Path in PLC of variable needed by data consumer
   140         @param iec_path: Path in PLC of variable needed by data consumer
   141         @param consumer: Data consumer to subscribe
   141         @param consumer: Data consumer to subscribe
   142         @return: List of value already received [(tick, data),...] (None if
   142         @return: List of value already received [(tick, data),...] (None if
   146         if self.DataProducer is None:
   146         if self.DataProducer is None:
   147             return None
   147             return None
   148         
   148         
   149         # Subscribe data consumer to DataProducer
   149         # Subscribe data consumer to DataProducer
   150         result = self.DataProducer.SubscribeDebugIECVariable(
   150         result = self.DataProducer.SubscribeDebugIECVariable(
   151                         iec_path, consumer)
   151                         iec_path, consumer, buffer_list)
   152         if result is not None and consumer != self:
   152         if result is not None and consumer != self:
   153             
   153             
   154             # Store data consumer if successfully subscribed and inform
   154             # Store data consumer if successfully subscribed and inform
   155             # consumer of variable data type
   155             # consumer of variable data type
   156             self.DataConsumers[consumer] = iec_path
   156             self.DataConsumers[consumer] = iec_path
   176         Called to Subscribe all data consumers contained in DebugViewer.
   176         Called to Subscribe all data consumers contained in DebugViewer.
   177         May be overridden by inherited classes.
   177         May be overridden by inherited classes.
   178         """
   178         """
   179         # Subscribe tick if needed
   179         # Subscribe tick if needed
   180         if self.SubscribeTick and self.Debug and self.DataProducer is not None:
   180         if self.SubscribeTick and self.Debug and self.DataProducer is not None:
   181             self.DataProducer.SubscribeDebugIECVariable("__tick__", self)
   181             self.DataProducer.SubscribeDebugIECVariable("__tick__", self, True)
   182     
   182     
   183     def UnsubscribeAllDataConsumers(self, tick=True):
   183     def UnsubscribeAllDataConsumers(self, tick=True):
   184         """
   184         """
   185         Called to Unsubscribe all data consumers.
   185         Called to Unsubscribe all data consumers.
   186         """
   186         """
   212                 return data_type
   212                 return data_type
   213             
   213             
   214             # Search for variable informations in project data
   214             # Search for variable informations in project data
   215             infos = self.DataProducer.GetInstanceInfos(iec_path)
   215             infos = self.DataProducer.GetInstanceInfos(iec_path)
   216             if infos is not None:
   216             if infos is not None:
   217                 return infos["type"]
   217                 return infos.type
   218         
   218         
   219         return None
   219         return None
   220     
   220     
   221     def IsNumType(self, data_type):
   221     def IsNumType(self, data_type):
   222         """
   222         """
   244         @param iec_path: Path in PLC of variable to release
   244         @param iec_path: Path in PLC of variable to release
   245         """
   245         """
   246         if self.DataProducer is not None:
   246         if self.DataProducer is not None:
   247             self.DataProducer.ReleaseDebugIECVariable(iec_path)
   247             self.DataProducer.ReleaseDebugIECVariable(iec_path)
   248     
   248     
   249     def NewDataAvailable(self, tick, *args, **kwargs):
   249     def NewDataAvailable(self, ticks, *args, **kwargs):
   250         """
   250         """
   251         Called by DataProducer for each tick captured
   251         Called by DataProducer for each tick captured
   252         @param tick: PLC tick captured
   252         @param tick: PLC tick captured
   253         All other parameters are passed to refresh function 
   253         All other parameters are passed to refresh function 
   254         """
   254         """