public override bool Equals(object o) { if (o is x1) { x1 obj = o as x1; if (this == obj) { return(true); } if (obj == null) { return(false); } if (this.ID != obj.ID) { return(false); } if (this.GUID != obj.GUID) { return(false); } return(true); } return(false); }
private void closeswitch(x1 x) { lock (wss_lock) { String rtuid = rtu[x.HCD]; String cmd = "{\"ctp\":1,\"uid\":\"service\",\"utp\":1,\"rtu\": \"" + rtuid + "\",\"op\":\"4D\",\"value\":\"0000\",\"serial\":\"" + x.GUID + "\"}"; wss.Send(cmd); Console.WriteLine(x.ETM + "发送关闭阀门命令..."); } }
private void JihuaThread() { while (!exit) { getrtu(); x1 x = null; DateTime now = DateTime.Now; now = now.AddSeconds(0 - now.Second); now = now.AddMilliseconds(0 - now.Millisecond); lock (_lock) { foreach (x1 a in start) { DateTime s = Convert.ToDateTime(a.STM); if (s >= now) { continue; } x = a; break; } } if (x != null) { DateTime s = Convert.ToDateTime(x.STM); if ((s == (now))) { lock (_lock) { x.initretry(); pending.Add(x); start.Remove(x); } } else if (s < now) { if (s > (now - ts)) { lock (_lock) { x.initretry(); pending.Add(x); start.Remove(x); } } else { lock (_lock) { outdate.Add(x); start.Remove(x); } } } } x = null; lock (_lock) { foreach (x1 a in end) { DateTime s = Convert.ToDateTime(a.ETM); if (s >= now) { continue; } x = a; break; } } if (x != null) { DateTime s = Convert.ToDateTime(x.ETM); lock (_lock) { x.initretry(); pendinge.Add(x); end.Remove(x); } } /* * lock (wss_lock) * { * if (!wss.IsAlive) * wss.Connect(); * } */ lock (_lock) { foreach (x1 o in pending) { if (o.retry()) { openswitch(o); } else if (o.getretry() > 3) { pending.Remove(o); outdate.Add(o); break; } } foreach (x1 o in pendinge) { if (o.retry()) { closeswitch(o); } else if (o.getretry() > 3) { pendinge.Remove(o); outdate.Add(o); break; } } } Thread.Sleep(1); } }