virtual public void UpdateMonData() { mondata_old.Copy(mondata); mondata = CreateMonDate(signLen); ReadIO(); if (g_jifenQueue.Count >= g_jifennum) { g_jifenQueue.RemoveAt(0); } g_jifenQueue.Add(mondata.GetSignals(SignalType.GAN)); if (x_jifenQueue.Count >= max_x_jifennum) { x_jifenQueue.RemoveAt(0); } x_jifenQueue.Add(mondata.GetSignals(SignalType.XIAN)); CSignals gsign = JiFen(g_jifenQueue.ToArray(), g_jifennum, SignalType.GAN, ganlen); CSignals xsign = XJiFen(x_jifenQueue.ToArray(), SignalType.XIAN, xianlen); mondata.SetSignals(SignalType.GAN, gsign); mondata.SetSignals(SignalType.XIAN, xsign); mondata_cur.Copy(mondata); }
public virtual void Notify(IMonData data) { CSignals g = data.GetSignals(SignalType.GAN); for (int i = 0; i < g.Length; i++) { try { gan[i].Stat = g[i]; } catch (NullReferenceException nilRefe) { } } CSignals x = data.GetSignals(SignalType.XIAN); for (int i = 0; i < x.Length; i++) { try { xian[i].Stat = x[i]; } catch (NullReferenceException nilRefe) { } } }
public bool Equals(IMonData src) { for (int i = 0; i < GAN_LENGTH; i++) { if (Gan[i] != src.GetSignal(SignalType.GAN, i)) { return(false); } } for (int i = 0; i < XIAN_LENGTH; i++) { if (Xian[i] != src.GetSignal(SignalType.XIAN, i)) { return(false); } } for (int i = 0; i < CHE_LENGTH; i++) { if (Che[i] != src.GetSignal(SignalType.CHE, i)) { return(false); } } return(true); }
public void Notify(IMonData data) { if (!oldData.Equals(data)) { Console.Write(Environment.NewLine); Console.Write("Che:\t"); for (int i = 0; i < signLen.CHE_LENGTH; i++) { Console.Write("{0}\t", data.GetSignal(SignalType.CHE, i)); } Console.Write(Environment.NewLine); Console.Write("Xian:\t"); for (int i = 0; i < signLen.XIAN_LENGTH; i++) { Console.Write("{0}\t", data.GetSignal(SignalType.XIAN, i)); } Console.Write(Environment.NewLine); Console.Write("Gan:\t"); for (int i = 0; i < signLen.GAN_LENGTH; i++) { Console.Write("{0}\t", data.GetSignal(SignalType.GAN, i)); } Console.Write(Environment.NewLine); } oldData.Copy(data); }
public BaseExamTranslator(ISignalMonitor monitor) { oldData = monitor.CreateMonDate(monitor.SignalLength); this.monitor = monitor; this.monitor.RegMonitor(this); _examTOThread = new Thread(new ThreadStart(ExamTimeOut)); _stateTOThread = new Thread(new ThreadStart(StateTimeOut)); }
public CJKYBaseMonitor(CSettings settings) { commonSettings = settings; SignalConfigures sigConf = settings.SignConfig; iorport = sigConf.IOReaderPort; iowport = sigConf.IOWritterPort; printerport = sigConf.PrinterPort; g_jifennum = sigConf.GanJiFen; x_jifennum = sigConf.XianJiFen; lx_jifennum = sigConf.LXianJiFen; if (g_jifennum < 2 || g_jifennum > 100) { g_jifennum = 2; } if (x_jifennum < 2 || x_jifennum > 100) { x_jifennum = 2; } if (lx_jifennum < 2 || lx_jifennum > 100) { lx_jifennum = 2; } max_x_jifennum = Math.Max(x_jifennum, lx_jifennum); signLen = new SignLength(); signLen.GAN_LENGTH = ganlen = sigConf.GanLength; signLen.XIAN_LENGTH = xianlen = sigConf.XianLength; signLen.CHE_LENGTH = chelen = sigConf.CheLength; readIOLoopTime = sigConf.ReadIOLoopTime; mondata = CreateMonDate(signLen); mondata_cur = CreateMonDate(signLen); mondata_old = CreateMonDate(signLen); g_jifenQueue = new List <CSignals>(g_jifennum); x_jifenQueue = new List <CSignals>(max_x_jifennum); adminPBGan = sigConf.AdminPBGan; adminPBXian = sigConf.AdminPBXian; adminQFGan = sigConf.AdminQFGan; adminQFXian = sigConf.AdminQFXian; PBChe = sigConf.PBChe; PBGan = sigConf.PBGan; PBXian = sigConf.PBXian; ganpos = sigConf.GanPosition; xianpos = sigConf.XianPosition; chepos = sigConf.ChePosition; ApplyCommonSettings(); mythread = new Thread(Monitor); regobj = new ArrayList(); }
public virtual void Notify(IMonData data) { //杆信号 CSignals g = data.GetSignals(SignalType.GAN); string strGanState = "杆:"; for (int i = 0; i < g.Length; i++) { if (g[i] != -1) { strGanState = strGanState + " " + g[i]; } else { strGanState = strGanState + " " + g[i]; } } SetText(gan_label, strGanState); //线信号 CSignals x = data.GetSignals(SignalType.XIAN); string strXianState = "线:"; for (int i = 0; i < x.Length; i++) { if (x[i] != -1) { strXianState = strXianState + " " + x[i]; } else { strXianState = strXianState + " " + x[i]; } } SetText(xian_label, strXianState); //车信号 CSignals c = data.GetSignals(SignalType.CHE); if (c[0] == 1) { SetText(che_label, "车: 前进"); } if (c[1] == 1) { SetText(che_label, "车: 后退"); } if (c[2] == 1) { SetText(che_label, "车: 停车"); } if (c[3] == 1) { SetText(che_label, "车: 熄火"); } }
public void Copy(IMonData isrc) { CMonData src = (CMonData)isrc; for (int i = 0; i < xinhaocount; i++) { this.gan[i] = src.gan[i]; this.xian[i] = src.xian[i]; if (i < 4) { this.che[i] = src.che[i]; } } }
protected override void ReadIO() { IMonData mod = mondata; sbyte tmpreturn = 0; CSignals gs = mod.GetSignals(SignalType.GAN); CSignals xs = mod.GetSignals(SignalType.XIAN); CSignals cs = mod.GetSignals(SignalType.CHE); for (int i = 0; i < readIOLoopTime; i++) { iorw.write(iowport, (byte)i); Thread.Sleep(lvbodelaytime); tmpreturn = (sbyte)iorw.read(iorport); if (i < ganlen) { gs[i] = readbit(tmpreturn, (sbyte)ganpos); } if (i < xianlen) { xs[i] = readbit(tmpreturn, (sbyte)xianpos); } if (i < chelen) { cs[i] = readbit(tmpreturn, (sbyte)chepos); } } //信号处理 sbyte[] garr = mod.GetSignals(SignalType.GAN).SignalArray; sbyte[] xarr = mod.GetSignals(SignalType.XIAN).SignalArray; sbyte[] carr = mod.GetSignals(SignalType.CHE).SignalArray; xarr[6] = garr[3]; xarr[7] = garr[5]; //取反 mondata_qf(ref garr, adminQFGan); mondata_qf(ref xarr, adminQFXian); //管理员屏蔽 mondata_adminpb(ref garr, adminPBGan); mondata_adminpb(ref xarr, adminPBXian); //屏蔽 mondata_pb(ref carr, SignalType.CHE, PBChe); mondata_pb(ref garr, SignalType.GAN, PBGan); mondata_pb(ref xarr, SignalType.XIAN, PBXian); }
public bool Equals(IMonData isrc) { CMonData src = (CMonData)isrc; for (int i = 0; i < xinhaocount; i++) { if (this.xian[i] != src.xian[i] || this.gan[i] != src.gan[i]) { return(false); } if (i < 4) { if (this.che[i] != src.che[i]) { return(false); } } } return(true); }
public void Notify(IMonData idata) { CMonData data = (CMonData)idata; //Log.WriteCMonData(data); for (int i = 0; i < data.che.Length; i++) { if (data.che[i] == 1) { picBoxChe[i].BackColor = Color.Green; } else { picBoxChe[i].BackColor = Color.Red; } } for (int i = 0; i < data.gan.Length; i++) { if (data.gan[i] == 1) { picBoxGan[i].BackColor = Color.Green; } else { picBoxGan[i].BackColor = Color.Red; } } for (int i = 0; i < data.xian.Length; i++) { if (data.xian[i] == 1) { picBoxXian[i].BackColor = Color.Green; } else { picBoxXian[i].BackColor = Color.Red; } } }
public void Notify(IMonData data) { //Log.WriteCMonData(data); for (int i = 0; i < data.GetSignals(SignalType.CHE).Length; i++) { if (data.GetSignal(SignalType.CHE, i) == 1) { picBoxChe[i].BackColor = Color.Green; } else { picBoxChe[i].BackColor = Color.Red; } } for (int i = 0; i < data.GetSignals(SignalType.GAN).Length; i++) { if (data.GetSignal(SignalType.GAN, i) == 1) { picBoxGan[i].BackColor = Color.Green; } else { picBoxGan[i].BackColor = Color.Red; } } for (int i = 0; i < data.GetSignals(SignalType.XIAN).Length; i++) { if (data.GetSignal(SignalType.XIAN, i) == 1) { picBoxXian[i].BackColor = Color.Green; } else { picBoxXian[i].BackColor = Color.Red; } } }
private bool checkSignals() { IMonData tempData = monitor.CurrData; SignLength sigLen = monitor.SignalLength; CSignals ganSig = tempData.GetSignals(SignalType.GAN); for (int i = 0; i < sigLen.GAN_LENGTH; i++) { if (ganSig[i] == 0) { return(false); } } CSignals xianSig = tempData.GetSignals(SignalType.XIAN); for (int i = 0; i < sigLen.XIAN_LENGTH; i++) { if (xianSig[i] == 0) { return(false); } } return(true); }
virtual public void OnStateChange(IMonData mondata) { }
public void Copy(IMonData src) { Gan = src.GetSignals(SignalType.GAN); Xian = src.GetSignals(SignalType.XIAN); Che = src.GetSignals(SignalType.CHE); }
public void Notify(IMonData idata) { CMonData data = (CMonData)idata; for (int i = 0; i < 9; i++) { if (data.xian[i] != oldData.xian[i]) { SignalEvent handler; if (data.xian[i] == 1) { handler = LeaveXianEvent; } else { handler = BlockXianEvent; } handler(this, new SignalEventArgs(SignalType.XIAN, i)); } if (data.gan[i] != oldData.gan[i]) { SignalEvent handler; if (data.gan[i] == 0) { handler = HitGanEvent; } else { handler = ResetGanEvent; } handler(this, new SignalEventArgs(SignalType.GAN, i)); } if (i < 4) { if (data.che[i] != oldData.che[i]) { if (data.che[i] == 1) { EventHandler handler = CarStopEvent; switch (i) { case 0: handler = CarMoveForwardEvent; break; case 1: handler = CarMoveBackEvent; break; case 2: handler = CarStopEvent; break; case 3: handler = CarFlameoutEvent; break; } handler(this, new EventArgs()); } } } } oldData.Copy(data); }
public override void Notify(IMonData data) { base.Notify(data); xian[6].Stat = xian[7].Stat = xian[8].Stat = xian[3].Stat; }
public override void Notify(CExam exam) { if (!exam.Passed) { //若要改变出错时模型车位置,请调整此处代码。 //可再为每种ResultType添加switch(exam.Message.Index), //以细化针对不同杆线错误时,模型车的位置 switch (exam.Message.TypeOfResult) { case ResultType.Gan: che.SetWeizhi(gan[exam.Message.Index].X, gan[exam.Message.Index].Y); break; case ResultType.Xian: switch (exam.Message.Index) { case 0: case 2: che.SetWeizhi(xian[exam.Message.Index].X1, che.Y); break; case 1: case 3: case 4: che.SetWeizhi(che.X, xian[exam.Message.Index].Y1); break; } break; case ResultType.ZT: che.SetWeizhi(che.X, che.Y); break; case ResultType.XH: che.SetWeizhi(che.X, che.Y); break; case ResultType.LXC: che.SetWeizhi(che.X, che.Y); break; case ResultType.TimeOut: che.SetWeizhi(che.X, che.Y); break; default: break; } } IMonData data = monitor.CurrData; CSignals g = data.GetSignals(SignalType.GAN); for (int i = 0; i < g.Length; i++) { gan[i].Stat = g[i]; } CSignals x = data.GetSignals(SignalType.XIAN); for (int i = 0; i < x.Length; i++) { xian[i].Stat = x[i]; } if (this.picBoxModelBackGround.InvokeRequired) { NotifyDelegate doNotify = new NotifyDelegate(DoNotify); this.picBoxModelBackGround.Invoke(doNotify); } else { DoNotify(); } }
virtual public void Notify(IMonData data) { if (monitor.Ready) { CSignals oldx = oldData.GetSignals(SignalType.XIAN); for (int i = 0; i < monitor.SignalLength.XIAN_LENGTH; i++) { CSignals sig = data.GetSignals(SignalType.XIAN); if (sig[i] != oldx[i]) { SignalEvent handler; if (sig[i] == 1) { handler = LeaveXianEvent; } else { handler = BlockXianEvent; } handler(this, new SignalEventArgs(SignalType.XIAN, i)); } } CSignals oldg = oldData.GetSignals(SignalType.GAN); for (int i = 0; i < monitor.SignalLength.GAN_LENGTH; i++) { CSignals sig = data.GetSignals(SignalType.GAN); if (sig[i] != oldg[i]) { SignalEvent handler; if (sig[i] == 0) { handler = HitGanEvent; } else { handler = ResetGanEvent; } handler(this, new SignalEventArgs(SignalType.GAN, i)); } } CSignals oldc = oldData.GetSignals(SignalType.CHE); for (int i = 0; i < monitor.SignalLength.CHE_LENGTH; i++) { CSignals sig = data.GetSignals(SignalType.CHE); if (sig[i] != oldc[i]) { if (sig[i] == 1) { EventHandler handler = CarStopEvent; switch (i) { case (int)BaseCarSignalEnum.FORWARD: handler = CarMoveForwardEvent; break; case (int)BaseCarSignalEnum.BACK: handler = CarMoveBackEvent; break; case (int)BaseCarSignalEnum.STOP: handler = CarStopEvent; break; case (int)BaseCarSignalEnum.FLAMEOUT: handler = CarFlameoutEvent; break; } handler(this, new EventArgs()); } } } } else { monitor.Ready = true; } oldData.Copy(data); }
private bool alarm;//报警标志,在timer中控制报警 #region IMonObserver Members public void Notify(IMonData data) { //Log.WriteCMonData(data); if (IsStartTest) { alarm = false; if (IsSignalGanXian) { //车 if (IsSignalCar) { for (int i = 0; i < data.GetSignals(SignalType.CHE).Length; i++) { if (data.GetSignal(SignalType.CHE, i) == 1) { picBoxChe[i].BackColor = Color.Green; } else { picBoxChe[i].BackColor = Color.Red; } } } //杆 if (IsSiganlGan) { for (int i = 0; i < data.GetSignals(SignalType.GAN).Length; i++) { if (i == gxNumber - 1) { if (data.GetSignal(SignalType.GAN, i) == 1) { picBoxGan[i].BackColor = Color.Green; } else { picBoxGan[i].BackColor = Color.Red; alarm = true; } } } } //线 if (IsSignalXian) { for (int i = 0; i < data.GetSignals(SignalType.XIAN).Length; i++) { if (i == gxNumber - 1) { if (data.GetSignal(SignalType.XIAN, i) == 1) { picBoxXian[i].BackColor = Color.Green; } else { picBoxXian[i].BackColor = Color.Red; alarm = true; } } } } } else { //车 for (int i = 0; i < data.GetSignals(SignalType.CHE).Length; i++) { if (data.GetSignal(SignalType.CHE, i) == 1) { picBoxChe[i].BackColor = Color.Green; } else { picBoxChe[i].BackColor = Color.Red; } } //杆 for (int i = 0; i < data.GetSignals(SignalType.GAN).Length; i++) { if (data.GetSignal(SignalType.GAN, i) == 1) { picBoxGan[i].BackColor = Color.Green; } else { picBoxGan[i].BackColor = Color.Red; alarm = true; } } //线 for (int i = 0; i < data.GetSignals(SignalType.XIAN).Length; i++) { if (data.GetSignal(SignalType.XIAN, i) == 1) { picBoxXian[i].BackColor = Color.Green; } else { picBoxXian[i].BackColor = Color.Red; alarm = true; } } } } }