internal int UpdatePortStatus(eSECS1_PORT_STATUS ef, eSECS1_PORT_STATUS et) { int result; lock (this.syncObject) { if (this.portstatus == ef) { this.Logger.Debug(string.Format("Update Port Status from {0} to {1}", ef, et)); this.portstatus = et; result = 0; } else { this.Logger.Debug(string.Format("Update Port Status from {0} to {1}, but now is: {2}", ef, et, this.portstatus)); result = 1; } } return(result); }
internal void Initialize() { this.timer = new SECS1Timer(this.SECS1Para.T1, this.SECS1Para.T2, (long)this.SECS1Para.T3, (long)this.SECS1Para.T4, this.SECS1Para.SerialPort); this.timer.OnSECS1Timeout += new SECS1Timer.OnTimeout(this.OnTimeout); this.timer.Logger = this.Logger; this.eventExecutor = new SECS1EventExecutor(this.SECS1Para.SerialPort, this); this.eventExecutor.OnSECS1Event += new SECS1Port.SECS1EventHandler(this.eventExecutor_OnSECS1Event); this.eventExecutor.Logger = this.Logger; this.writer = new SECS1Writer(this.SECS1Para.SerialPort, this); this.writer.Logger = this.Logger; this.reader = new SECS1Reader(this.SECS1Para.SerialPort, this, this.writer, this.eventExecutor); this.reader.Logger = this.Logger; this.commport = new CommPort(); this.commport.CommSetting.baudRate = this.SECS1Para.Baudrate; this.commport.CommSetting.port = this.SECS1Para.SerialPort; this.commport.DataReceived += new CommPort.DataReceivedHandler(this.DataReceived); this.portstatus = eSECS1_PORT_STATUS.PortIdle; this.writer.Start(); this.timer.Start(); this.eventExecutor.Start(); this.commport.Open(); }