예제 #1
0
 public void InitTscData(TscInfo ti)
 {
     TscData td = new TscData();
     Node node = new Node(ti.Ip, ti.Name, ti.Version, ti.Port);
     td.Node = node;
     Application.Current.Properties[Define.TSC_DATA] = td;
     try
     {
         td.ListSchedule = TscDataUtils.GetSchedule();
         td.ListPlan = TscDataUtils.GetPlan();
         td.ListModule = TscDataUtils.GetModule();
         td.ListPhase = TscDataUtils.GetPhase();
         try
         {
             td.ListCollision = TscDataUtils.GetCollision();
             td.Node.sProtocol = "GBT_V32";
         }
         catch(Exception ex)
         {
             td.ListCollision = TscDataUtils.GetCollision16();
             td.Node.sProtocol = "GBT_V16";
         }
         
         td.ListDetector = TscDataUtils.GetDetector();
         td.ListChannel = TscDataUtils.GetChannel();
         td.ListEventLog = TscDataUtils.GetEventLog();
         td.ListPattern = TscDataUtils.GetPattern();
         try
         {
             td.ListStagePattern = TscDataUtils.GetStagePattern();
         }
         catch(Exception ex)
         {
             td.ListStagePattern = TscDataUtils.GetStagePattern16();
         }
         
         td.ListOverlapPhase = TscDataUtils.GetOverlapPhase();
         
         td.ListPhaseToDirec = TscDataUtils.GetPhaseToDirec();
         td.ListLampCheck = TscDataUtils.GetLampCheck();
         currentTI = null;
         
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         MessageBox.Show("信号机为16相位,协议无法匹配!");
     }
     
 }
예제 #2
0
        /// <summary>
        /// 返回检测器灵敏度等级2块1-8通道
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static List<byte> GetSensitivityAdv22(Node n)
        {
            List<byte> lb = new List<byte>();
            byte[] ba = Udp.recvUdp(n.sIpAddress, n.iPort, Define.GET_DETECTOR_SENSITIVITY_2_9_16);
            lb = ba.ToList<byte>();
            return lb;

        }
예제 #3
0
        /// <summary>
        /// 设置检测器灵敏 度
        /// </summary>
        /// <param name="borad"></param>
        /// <param name="se"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Message SetSensitivityAdv(byte[] se, Node n)
        {
            Message m = new Message();

            byte[] hex11 = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            byte[] hex12 = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            byte[] hex21 = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            byte[] hex22 = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            Stream s11 = new MemoryStream();
            s11.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            

            s11.WriteByte(se[0]);
            s11.WriteByte(se[1]);
            s11.WriteByte(se[2]);
            s11.WriteByte(se[3]);
            s11.Position = 0;
            int count11 = s11.Read(hex11, 0, hex11.Length);
            if (count11 > 0)
            {
                    hex11[3] = 0x0b;
                    hex11[4] = 0x00;
                    Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex11);
            }
            Stream s12 = new MemoryStream();
            s12.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            s12.WriteByte(se[4]);
            s12.WriteByte(se[5]);
            s12.WriteByte(se[6]);
            s12.WriteByte(se[7]);
            s12.Position = 0;

            int count12 = s12.Read(hex12, 0, hex12.Length);
            if(count12>0)
            {
                hex12[3] = 0x0c;
                hex12[4] = 0x00;
                Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex12);
            }

            Stream s21 = new MemoryStream();
            s21.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            s21.WriteByte(se[8]);
            s21.WriteByte(se[9]);
            s21.WriteByte(se[10]);
            s21.WriteByte(se[11]);
            s21.Position = 0;

            int count21 = s21.Read(hex21, 0, hex21.Length);
            if (count21 > 0)
            {
                hex21[3] = 0x0b;
                hex21[4] = 0x01;
                Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex21);
            }

            Stream s22 = new MemoryStream();
            s22.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            s22.WriteByte(se[12]);
            s22.WriteByte(se[13]);
            s22.WriteByte(se[14]);
            s22.WriteByte(se[15]);
            s22.Position = 0;

            int count22 = s22.Read(hex22, 0, hex22.Length);
            if (count22 > 0)
            {
                hex22[3] = 0x0c;
                hex22[4] = 0x01;
                Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex22);
            }
            return m;
        }
예제 #4
0
        /// <summary>
        /// 检测器第二块板 9- 16通道设置方法
        /// </summary>
        /// <param name="se"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Message SetSensitivityAdv22(byte[] se, Node n)
        {
            Message m = new Message();

            byte[] hex = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            Stream s = new MemoryStream();
            bool b = false;
            s.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            s.WriteByte(se[0]);
            s.WriteByte(se[1]);
            s.WriteByte(se[2]);
            s.WriteByte(se[3]);
            s.Position = 0;
            int count = s.Read(hex, 0, hex.Length);
            if (count > 0)
            {
                hex[3] = 0x0c;
                hex[4] = 0x01;
                b = Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
            }
            if (b == true)
            {
                m.flag = true;
                m.msg = "检测器1板1-8通道灵敏度设置成功";
                m.obj = "Detecotr";
            }
            else
            {
                m.flag = false;
                m.msg = "检测器1板1-8通道灵敏度设置失败";
                m.obj = "Detecotr";
            }
            return m;
        }
예제 #5
0
        /// <summary>
        /// 设置检测器灵敏 度
        /// </summary>
        /// <param name="borad"></param>
        /// <param name="se"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Message SetSensitivity(int borad, byte se,Node n)
        {
            Message m = new Message();

            byte[] hex = new byte[Define.DETECTOR_SENSITIVITY.Length + 4];
            Stream s = new MemoryStream();
            s.Write(Define.DETECTOR_SENSITIVITY, 0, Define.DETECTOR_SENSITIVITY.Length);
            byte sen = se;
            sen = (byte)(sen | se << 4);

            s.WriteByte(sen);
            s.WriteByte(sen);
            s.WriteByte(sen);
            s.WriteByte(sen);
            s.Position = 0;
            int count = s.Read(hex, 0, hex.Length);
            if(count > 0)
            {
                if (borad == 1)
                {
                    hex[3] = 0x0b;
                    hex[4] = 0x00;
                    Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
                    hex[3] = 0x0c;
                    hex[4] = 0x00;
                    Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
                }
                if (borad == 2)
                {
                    hex[3] = 0x0b;
                    hex[4] = 0x01;
                    Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
                    hex[3] = 0x0c;
                    hex[4] = 0x01;
                    Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
                    // Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
                }
            }
            
            return m;
        }
예제 #6
0
 /// <summary>
 /// 检测器灵敏度数值第二块板15-16通道
 /// </summary>
 /// <param name="b"></param>
 /// <param name="n"></param>
 /// <returns></returns>
 public static Message SetSensityvityDig6(byte[] b, Node n)
 {
     Message m = new Message();
     byte[] hex = new byte[Define.SET_DETECTOR_SENSITYVITY_DIG_2_15_16.Length + 7];
     Stream s = new MemoryStream();
     s.Write(Define.SET_DETECTOR_SENSITYVITY_DIG_2_15_16, 0, Define.SET_DETECTOR_SENSITYVITY_DIG_2_15_16.Length);
     s.Write(b, 0, b.Length);
     s.Position = 0;
     int count = s.Read(hex, 0, hex.Length);
     bool bl = false;
     if (count > 0)
     {
         bl = Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
     }
     if (bl == true)
     {
         m.obj = "Detector";
         m.flag = true;
         m.msg = "检测器数值保存成功";
     }
     else
     {
         m.obj = "Detector";
         m.flag = false;
         m.msg = "检测器数值保存失败";
     }
     return m;
 }
예제 #7
0
 /// <summary>
 /// 设置震荡频率
 /// </summary>
 /// <param name="sf"></param>
 /// <param name="n"></param>
 /// <returns></returns>
 public static Message SetOscillatorFrequency(byte sf ,Node n)
 {
     Message m = new Message();
     byte[] hex = new byte[Define.DETECTOR_OSCILLATOR_FREQUENCY.Length + 4];
     Stream s = new MemoryStream();
     s.Write(Define.DETECTOR_OSCILLATOR_FREQUENCY, 0, Define.DETECTOR_OSCILLATOR_FREQUENCY.Length);
     byte sfc = sf;
     sfc = (byte)(sf | sfc << 2);
     sfc = (byte)(sf | sfc << 2);
     sfc = (byte)(sf | sfc << 2);
     s.WriteByte(sfc);
     s.WriteByte(sfc);
     s.WriteByte(sfc);
     s.WriteByte(sfc);
     s.Position = 0;
     int count = s.Read(hex, 0, hex.Length);
     if(count>0)
     {
         
             Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
       
     }
     return m;
 }
예제 #8
0
        /// <summary>
        /// 得到模块状态 
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static byte[] GetModuleStatus(Node n)
        {

            byte[] hex = Udp.recvUdp(n.sIpAddress, n.iPort, Define.MODULE_EVERYONE_STATUS);
            return hex;
        }
예제 #9
0
        /// <summary>
        /// 信号机校时功能
        /// </summary>
        /// <param name="dt"></param>
        public static void Timing(DateTime dt,Node n)
        {
            byte[] hex = { 0x81, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00 };

            DateTime bb = new DateTime(1970, 1, 1, 0, 0, 0);
            TimeSpan t3 = dt - bb;
            int kd = (int)t3.TotalSeconds;

            byte[] btime = System.BitConverter.GetBytes(kd);
            hex[3] = btime[3];
            hex[4] = btime[2];
            hex[5] = btime[1];
            hex[6] = btime[0];
            Udp.sendUdpNoReciveData(n.sIpAddress, n.iPort, hex);
        }
예제 #10
0
        /// <summary>
        /// 返回信号机的门,电压,温度等信息
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static byte[] GetControllerStatus(Node n)
        {
            return Udp.recvUdp(n.sIpAddress, n.iPort, Define.GET_CONTROLLER_STATUS);

        }