398 if self.Value != self.PreviousValue: |
398 if self.Value != self.PreviousValue: |
399 self.Refresh() |
399 self.Refresh() |
400 self.SpreadCurrent() |
400 self.SpreadCurrent() |
401 |
401 |
402 def SpreadCurrent(self): |
402 def SpreadCurrent(self): |
403 spreading = self.Input.ReceivingCurrent() |
403 if self.Parent.Debug: |
404 if self.Value is not None: |
404 if self.Value is None: |
|
405 self.Value = False |
|
406 spreading = self.Input.ReceivingCurrent() |
405 if self.Type == CONTACT_NORMAL: |
407 if self.Type == CONTACT_NORMAL: |
406 spreading &= self.Value |
408 spreading &= self.Value |
407 elif self.Type == CONTACT_REVERSE: |
409 elif self.Type == CONTACT_REVERSE: |
408 spreading &= not self.Value |
410 spreading &= not self.Value |
409 elif self.Type == CONTACT_RISING: |
411 elif self.Type == CONTACT_RISING: |
410 spreading &= self.Value and not self.PreviousValue |
412 spreading &= self.Value and not self.PreviousValue |
411 elif self.Type == CONTACT_FALLING: |
413 elif self.Type == CONTACT_FALLING: |
412 spreading &= self.Value and not self.PreviousValue |
414 spreading &= self.Value and not self.PreviousValue |
413 else: |
415 else: |
414 spreading = False |
416 spreading = False |
415 if spreading and not self.PreviousSpreading: |
417 if spreading and not self.PreviousSpreading: |
416 self.Output.SpreadCurrent(True) |
418 self.Output.SpreadCurrent(True) |
417 elif not spreading and self.PreviousSpreading: |
419 elif not spreading and self.PreviousSpreading: |
418 self.Output.SpreadCurrent(False) |
420 self.Output.SpreadCurrent(False) |
419 self.PreviousSpreading = spreading |
421 self.PreviousSpreading = spreading |
420 |
422 |
421 # Make a clone of this LD_Contact |
423 # Make a clone of this LD_Contact |
422 def Clone(self, parent, id = None, pos = None): |
424 def Clone(self, parent, id = None, pos = None): |
423 contact = LD_Contact(parent, self.Type, self.Name, id) |
425 contact = LD_Contact(parent, self.Type, self.Name, id) |
424 contact.SetSize(self.Size[0], self.Size[1]) |
426 contact.SetSize(self.Size[0], self.Size[1]) |
685 self.Input = None |
687 self.Input = None |
686 if self.Output is not None: |
688 if self.Output is not None: |
687 self.Output.Flush() |
689 self.Output.Flush() |
688 self.Output = None |
690 self.Output = None |
689 |
691 |
690 def SetValue(self, value): |
|
691 if self.Value != value: |
|
692 self.Value = value |
|
693 self.Refresh() |
|
694 |
|
695 def SpreadCurrent(self): |
692 def SpreadCurrent(self): |
696 self.PreviousValue = self.Value |
693 if self.Parent.Debug: |
697 self.Value = self.Input.ReceivingCurrent() |
694 self.PreviousValue = self.Value |
698 if self.Value and not self.PreviousValue: |
695 self.Value = self.Input.ReceivingCurrent() |
699 self.Output.SpreadCurrent(True) |
696 if self.Value and not self.PreviousValue: |
700 elif not self.Value and self.PreviousValue: |
697 self.Output.SpreadCurrent(True) |
701 self.Output.SpreadCurrent(False) |
698 elif not self.Value and self.PreviousValue: |
702 if self.Value != self.PreviousValue: |
699 self.Output.SpreadCurrent(False) |
703 self.Refresh() |
700 if self.Value != self.PreviousValue: |
|
701 self.Refresh() |
704 |
702 |
705 # Make a clone of this LD_Coil |
703 # Make a clone of this LD_Coil |
706 def Clone(self, parent, id = None, pos = None): |
704 def Clone(self, parent, id = None, pos = None): |
707 coil = LD_Coil(parent, self.Type, self.Name, id) |
705 coil = LD_Coil(parent, self.Type, self.Name, id) |
708 coil.SetSize(self.Size[0], self.Size[1]) |
706 coil.SetSize(self.Size[0], self.Size[1]) |