/// <summary> /// 设置相位方向 表 /// </summary> /// <param name="lptd"></param> /// <returns></returns> public static Message SetPhaseToDirec(List<PhaseToDirec> lptd) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message msg = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.PHASE_DIREC_BYTE_SIZE * Define.PHASE_DIREC_RESULT_LEN + Define.SET_PHASE_DIREC_RESPONSE.Length+1]; Stream s = new MemoryStream(); s.Write(Define.SET_PHASE_DIREC_RESPONSE, 0, Define.SET_PHASE_DIREC_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.PHASE_DIREC_RESULT_LEN)); foreach (PhaseToDirec ptd in lptd) { byte id = ptd.ucId; s.WriteByte(id); byte phase = ptd.ucPhase; s.WriteByte(phase); byte op = ptd.ucOverlapPhase; s.WriteByte(op); byte rc = ptd.ucRoadCnt; s.WriteByte(rc); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { msg.flag = true; msg.msg = "设置方向属性成功!"; msg.obj = "PhaseToDirec"; } else { msg.flag = false; msg.msg = "设置方向属性失败!"; msg.obj = "PhaseToDirec"; } } return msg; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
public static Message SetTiming(DateTime dt) { Message m = new Message(); TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); double idt = Utils.Utils.ConvertDateTimeInt(dt); DateTime dttt = Utils.Utils.ConvertIntDateTime(idt); byte[] ba = System.BitConverter.GetBytes(idt); byte[] bb = ba.Reverse().ToArray<byte>(); byte[] hex = new byte[Define.TSC_DEV_TIMING.Length + 4]; Stream s = new MemoryStream(); s.Write(Define.TSC_DEV_TIMING, 0, Define.TSC_DEV_TIMING.Length); s.Write(bb, 0, bb.Length); s.Position = 0; int count = s.Read(hex, 0, hex.Length); bool b = false; if(count >0) { b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); } if(b == true) { m.flag = true; m.msg = "校时成功!"; m.obj = "Timing"; } else { m.flag = true; m.msg = "校时失败!"; m.obj = "Timing"; } return m; }
/// <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; }
public static Message SetStagePattern16(List<StagePattern> lsp) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = new Message(); ////字节 长度,需要加2 ,因为。数据长度需要2个字段表示,二维数组。 byte[] hex = new byte[Define.STAGE_PATTERN_BYTE_SIZE_16 * (Define.STAGEPATTERN_RESULT_LEN * Define.STAGE_RESULT_LEN) + Define.SET_STAGEPATTERN_RESPONSE.Length + 2]; Stream s = new MemoryStream(); s.Write(Define.SET_STAGEPATTERN_RESPONSE, 0, Define.SET_STAGEPATTERN_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.STAGEPATTERN_RESULT_LEN)); s.WriteByte(Convert.ToByte(Define.STAGE_RESULT_LEN)); foreach (StagePattern sp in lsp) { byte id = sp.ucStagePatternId; s.WriteByte(id); byte stageno = sp.ucStageNo; s.WriteByte(stageno); byte[] ap = System.BitConverter.GetBytes(sp.usAllowPhase); ap = ap.Reverse().ToArray(); s.Write(ap, 0, ap.Length); byte green = sp.ucGreenTime; s.WriteByte(green); byte yellow = sp.ucYellowTime; s.WriteByte(yellow); byte red = sp.ucRedTime; s.WriteByte(red); byte opt = sp.ucOption; s.WriteByte(opt); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存阶段配时方案数据成功!"; m.obj = "Pattern"; } else { m.flag = false; m.msg = "保存阶段配时方案数据失败!"; m.obj = "Pattern"; } } return m; }
/// <summary> /// 设置跟随相位 /// </summary> /// <param name="lop"></param> /// <returns></returns> public static Message SetOverlapPhase(List<OverlapPhase> lop) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.OVERLAPPHASE_BYTE_SIZE * Define.OVERLAPPHASE_RESULT_LEN + Define.SET_OVERLAPPHASE_RESPONSE.Length+ 1]; Stream s = new MemoryStream(); s.Write(Define.SET_OVERLAPPHASE_RESPONSE, 0, Define.SET_OVERLAPPHASE_RESPONSE.Length); s.WriteByte(Convert.ToByte(lop.Count)); foreach (OverlapPhase op in lop) { byte id = op.ucId; s.WriteByte(id); byte ot = op.ucOperateType; s.WriteByte(ot); byte ipl = op.ucIncludePhaseLen; s.WriteByte(ipl); byte[] ip = op.ucIncludePhase; s.Write(ip, 0, ip.Length); byte cpl = op.ucCorrectPhaseLen; s.WriteByte(cpl); byte[] cp = op.ucCorrectPhase; s.Write(cp, 0, cp.Length); byte green = op.ucTailGreen; s.WriteByte(green); byte yellow = op.ucTailYellow; s.WriteByte(yellow); byte red = op.ucTailRed; s.WriteByte(red); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存跟随相位数据成功!"; m.obj = "Pattern"; } else { m.flag = false; m.msg = "保存跟随相位数据失败!"; m.obj = "Pattern"; } } return m; }
public static Message SetChannel(List<Channel> lc) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.CHANNEL_BYTE_SIZE*Define.CHANNEL_RESULT_LEN+Define.SET_CHANNEL_RESPONSE.Length + 1]; Stream s = new MemoryStream(); s.Write(Define.SET_CHANNEL_RESPONSE, 0, Define.SET_CHANNEL_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.CHANNEL_RESULT_LEN)); foreach (Channel c in lc) { byte id = c.ucId; s.WriteByte(id); byte sp = c.ucSourcePhase; s.WriteByte(sp); byte af = c.ucFlashAuto; s.WriteByte(af); byte type = c.ucType; s.WriteByte(type); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存通道数据成功!"; m.obj = "Channel"; } else { m.flag = false; m.msg = "保存通道数据失败!"; m.obj = "Channel"; } } return m; }
public static Message SetPattern(List<Pattern> lp) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.PATTERN_BYTE_SIZE * lp.Count + Define.SET_PATTERN_RESPONSE.Length + 1 ]; Stream s = new MemoryStream(); s.Write(Define.SET_PATTERN_RESPONSE, 0, Define.SET_PATTERN_RESPONSE.Length); s.WriteByte(Convert.ToByte(lp.Count)); foreach(Pattern p in lp) { byte id = p.ucPatternId; s.WriteByte(id); byte cyc = p.ucCycleTime; s.WriteByte(cyc); byte r = p.ucOffset; s.WriteByte(r); byte coor = p.ucCoorPhase; s.WriteByte(coor); byte stageid = p.ucStagePatternId; s.WriteByte(stageid); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存配时方案数据成功!"; m.obj = "Pattern"; } else { m.flag = false; m.msg = "保存配时方案数据失败!"; m.obj = "Pattern"; } } return m; }
public static Message SetSchedule(List<Schedule> ls) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = new Message(); //字节 长度,需要加2 ,因为。数据长度需要2个字段表示。 byte[] hex = new byte[Define.SCHEDULE_BYTE_SIZE * (Define.SCHEDULE_RESULT_LEN*Define.SCHEDULE_EVENT_RESULT_LEN) + Define.SET_SCHEDULE_RESPONSE.Length + 2]; Stream s = new MemoryStream(); s.Write(Define.SET_SCHEDULE_RESPONSE, 0, Define.SET_SCHEDULE_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.SCHEDULE_RESULT_LEN)); s.WriteByte(Convert.ToByte(Define.SCHEDULE_EVENT_RESULT_LEN)); foreach (Schedule sc in ls) { byte id = sc.ucId; s.WriteByte(id); byte eventid = sc.ucEventId; s.WriteByte(eventid); byte hour = sc.ucHour; s.WriteByte(hour); byte min = sc.ucMin; s.WriteByte(min); byte ctrl = sc.ucCtrl; s.WriteByte(ctrl); byte patterntime = sc.ucTimePatternId; s.WriteByte(patterntime); byte opt = sc.ucAuxOut; s.WriteByte(opt); byte sp = sc.ucSpecialOut; s.WriteByte(sp); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存时段数据成功!"; m.obj = "Schedule"; } else { m.flag = false; m.msg = "保存时段数据失败!"; m.obj = "Schedule"; } } return m; }
public static Message SetPlanByCalendar(List<Plan> lp) { Message m = new Message(); TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); byte[] hex = new byte[Define.PLAN_BYTE_SIZE * lp.Count + Define.SET_PLAN_RESPONSE.Length + 1]; Stream s = new MemoryStream(); s.Write(Define.SET_PLAN_RESPONSE, 0, Define.SET_PLAN_RESPONSE.Length); s.WriteByte(Convert.ToByte(lp.Count)); foreach (Plan p in lp) { byte id = p.ucId; s.WriteByte(id); byte[] month = System.BitConverter.GetBytes(p.usMonthFlag); month = month.Reverse().ToArray(); s.Write(month, 0, month.Length); byte week = p.ucWeekFlag; s.WriteByte(week); byte[] day = System.BitConverter.GetBytes(p.ulDayFlag); day = day.Reverse().ToArray(); s.Write(day, 0, day.Length); byte schedule = p.ucScheduleId; s.WriteByte(schedule); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { m.flag = true; m.msg = "保存时基数据成功!"; m.obj = "Plan"; } else { m.flag = false; m.msg = "保存时基数据失败!"; m.obj = "Plan"; } } return m; }
public static Message SetDetector(List<Detector> ld) { Message msg = new Message(); TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.DETECTOR_BYTE_SIZE*Define.DETECTOR_RESULT_LEN + Define.SET_DETECTOR_RESPONSE.Length +1]; Stream s = new MemoryStream(); s.Write(Define.SET_DETECTOR_RESPONSE,0,Define.SET_DETECTOR_RESPONSE.Length); s.WriteByte(Convert.ToByte(ld.Count)); foreach (Detector d in ld) { byte id = d.ucDetectorId; s.WriteByte(id); byte phaseid = d.ucPhaseId; s.WriteByte(phaseid); byte type = d.ucDetFlag; s.WriteByte(type); byte dirc = d.ucDirect; s.WriteByte(dirc); byte time = d.ucValidTime; s.WriteByte(time); byte opt = d.ucOptionFlag; s.WriteByte(opt); byte[] flow = System.BitConverter.GetBytes(d.usSaturationFlow); flow = flow.Reverse().ToArray(); s.Write(flow, 0, flow.Length); byte occupy = d.ucSaturationOccupy; s.WriteByte(occupy); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { msg.flag = true; msg.msg = "发送检测器数据成功!"; msg.obj = "Detector"; } else { msg.flag = false; msg.msg = "发送检测器数据失败!"; msg.obj = "Detector"; } } return msg; }
public static Message SetCollision(List<Collision> lc) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message msg = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.COLLISION_BYTE_SIZE*Define.COLLISION_RESULT_LENGTH+Define.SET_COLLISION_RESPONSE.Length + 1]; Stream s = new MemoryStream(); s.Write(Define.SET_COLLISION_RESPONSE,0,Define.SET_COLLISION_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.COLLISION_RESULT_LENGTH)); foreach (Collision c in lc) { byte id = c.ucPhaseId; s.WriteByte(id); byte[] flag = System.BitConverter.GetBytes(c.ucCollisionFlag); flag = flag.Reverse().ToArray(); s.Write(flag, 0, flag.Length); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0 ) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { msg.flag = true; msg.msg = "设置相位冲突属性成功!"; msg.obj = "Collision"; } else { msg.flag = false; msg.msg = "设置相位冲突属性失败!"; msg.obj = "Collision"; } } return msg; }
public static Message SetPhase(List<Phase> lp) { TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message msg = new Message(); //字节 长度,需要加1 ,因为。数据长度需要一个字段表示。 byte[] hex = new byte[Define.PHASE_BYTE_SIZE * Define.PHASE_RESULT_LEN + Define.SET_PHASE_RESPONSE.Length + 1]; Stream s = new MemoryStream(); s.Write(Define.SET_PHASE_RESPONSE, 0, Define.SET_PHASE_RESPONSE.Length); s.WriteByte(Convert.ToByte(Define.PHASE_RESULT_LEN)); foreach (Phase ptd in lp) { byte id = ptd.ucId; s.WriteByte(id); byte pg = ptd.ucPedestrianGreen; s.WriteByte(pg); byte pc = ptd.ucPedestrianClear; s.WriteByte(pc); byte mg = ptd.ucMinGreen; s.WriteByte(mg); byte gdu = ptd.ucGreenDelayUnit; s.WriteByte(gdu); byte mg1 = ptd.ucMaxGreen1; s.WriteByte(mg1); byte mg2 = ptd.ucMaxGreen2; s.WriteByte(mg2); byte fg = ptd.ucFixedGreen; s.WriteByte(fg); byte gf = ptd.ucGreenFlash; s.WriteByte(gf); byte type = ptd.ucType; s.WriteByte(type); byte opt = ptd.ucOption; s.WriteByte(opt); byte ext = ptd.ucExtend; s.WriteByte(ext); } s.Position = 0; int count = s.Read(hex, 0, hex.Length); if (count > 0) { bool b = Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, hex); if (b) { msg.flag = true; msg.msg = "设置相位属性成功!"; msg.obj = "Phase"; } else { msg.flag = false; msg.msg = "设置相位属性失败!"; msg.obj = "Phase"; } } return msg; }