private void UserControl_Loaded(object sender, RoutedEventArgs e) { try { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { return; } //t.ListPlan; List<Schedule> ls = t.ListSchedule; List<int> li = new List<int>(); foreach (Schedule s in ls) { if (!li.Contains(s.ucId) && s.ucId != 0) li.Add(s.ucId); } cbxScheduleId.ItemsSource = li; List<Plan> lp = t.ListPlan; foreach (Plan p in lp) { if (p.ucId >= 1 && p.ucId <= 20) { sldPlanId.Value = p.ucId; cbxScheduleId.SelectedItem = Convert.ToInt32(p.ucScheduleId); ushort month = p.usMonthFlag; uint day = p.ulDayFlag; DateTime datetime = DateTime.Now; //for (int i = 1; i <= 12; i++) //{ // if (((month >> i) & 0x01) == 0x01) // { // for (int j = 1; j <= 31; j++) // { // if (((day >> j) & 0x01) == 0x01) // { // try // { // calendar.SelectedDates.Add(new DateTime(datetime.Year, i, j)); // } // catch (Exception ex) // { // continue; // } // } // } // } //} //break; } } } catch(Exception ex ) { } }
private void InitSchedule() { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { return; } List<Schedule> ls = t.ListSchedule; //scheduleDataGrid.ItemsSource = ls; initSldScheduleId(ls); // // t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<ScheduleCtrl> lsc = new List<ScheduleCtrl>(); lsc.Add(new ScheduleCtrl() { name = "自主控制", value = (byte)0 }); lsc.Add(new ScheduleCtrl() { name = "关灯", value = (byte)1 }); lsc.Add(new ScheduleCtrl() { name = "闪光", value = 2 }); lsc.Add(new ScheduleCtrl() { name = "全红", value = 3 }); lsc.Add(new ScheduleCtrl() { name = "感应", value = 6 }); lsc.Add(new ScheduleCtrl() { name = "单点优化", value = 8 }); lsc.Add(new ScheduleCtrl() { name = "主从线控", value = 11 }); lsc.Add(new ScheduleCtrl() { name = "系统优化", value = 12 }); lsc.Add(new ScheduleCtrl() { name = "干预控制", value = 13 }); cbxucCtrl.ItemsSource = lsc; List<Pattern> lp = t.ListPattern; ucTimePatternId.ItemsSource = lp; List<ScheduleAuxOut> lsao = new List<ScheduleAuxOut>(); lsao.Add(new ScheduleAuxOut() { name = "辉度控制", value = 8 }); lsao.Add(new ScheduleAuxOut() { name = "无功能", value = 0 }); List<ScheduleSpecialOut> lsso = new List<ScheduleSpecialOut>(); lsso.Add(new ScheduleSpecialOut() { name = "无特殊功能", value = 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相位,协议无法匹配!"); } }
private void Button_Click_1(object sender, System.Windows.RoutedEventArgs e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, Define.UPDATE_TSC_START); Thread.Sleep(500); int result = FtpHelper.UploadFtp(tbxFileName.Text, t.Node.sIpAddress, Define.FTP_NAME, Define.FTP_PASSWD); Thread.Sleep(500); if(result == 0) { Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, Define.UPDATE_TSC_FINISH); MessageBox.Show("升级成功!"); } else if (result == -2) { //升级失败后,不要发送完成指令 //Udp.sendUdpNoReciveData(t.Node.sIpAddress, t.Node.iPort, Define.UPDATE_TSC_FINISH); MessageBox.Show("上传失败"); } }
private void SetCorrectPhaseToOverlapPhase(CheckComboBox ccb,int opUcId) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); foreach (OverlapPhase op in t.ListOverlapPhase) { if (op.ucId == opUcId) { List<byte> lb = new List<byte>(); foreach (Object o in ccb.SelectedItems) { Phase po = (Phase)o; lb.Add(po.ucId);//po.ucId } op.ucCorrectPhase = lb.ToArray<byte>(); } } }
private void tbxMinGreenTime_TextChanged(object sender, TextChangedEventArgs e) { TextBox tb = sender as TextBox; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<Phase> lp = t.ListPhase; foreach (Phase p in lp) { if (p.ucId == currentPhaseId) { p.ucPedestrianClear = Convert.ToByte(tb.Text); } } }
private void cbxPhaseOption_SelectionChanged(object sender, SelectionChangedEventArgs e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<Phase> lp = t.ListPhase; ComboBox cb = sender as ComboBox; PhaseOption po = (PhaseOption)cb.SelectedValue; foreach (Phase p in lp) { if (p.ucId == currentPhaseId) { p.ucType = Convert.ToByte(po.ucOption); } } }
/// <summary> /// 设置检测器,在哪个位置都有不同的定义 /// 1、路口最外面的是 战略 /// 2、路口外到内 第二个是感应 /// 3、路口外到内 第三个是战术 /// 4、路口 外到内第四个是请求 /// </summary> /// <param name="i"></param> /// <param name="direc"></param> /// <param name="type"></param> public void SetDetector(int i ,byte direc,int type) { tscui.Models.Detector d = new Models.Detector(); t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); bool newDetector = true; List<Models.Detector> ld = t.ListDetector; foreach (Models.Detector det in ld) { if (det.ucDetectorId == i) { det.ucDetectorId = Convert.ToByte(i); //det.ucDetFlag = GetDetFlag(type,direc); det.ucDirect = GetDirecByte(direc); //det.ucOptionFlag = GetOptionByCheckbox(); det.ucPhaseId = GetPhaseIdByDirec(direc); // det.ucSaturationOccupy = d.ucSaturationOccupy; //det.ucValidTime = Convert.ToByte(tbkVaildTime.Text); //det.usSaturationFlow = d.usSaturationFlow; newDetector = false; break; } } if (newDetector == true) { d.ucDetectorId = Convert.ToByte(i); d.ucPhaseId = GetPhaseIdByDirec(direc); d.ucDetFlag = GetDetFlag(type,direc); d.ucDirect = GetDirecByte(direc); d.ucValidTime = Convert.ToByte(tbkVaildTime.Text); d.ucOptionFlag = GetOptionByCheckbox(); d.usSaturationFlow = 0; d.ucSaturationOccupy = 0; newDetector = true; ld.Add(d); } }
private void p4_Checked(object sender, RoutedEventArgs e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<Phase> lp = t.ListPhase; displayPhase(4, lp); currentPhaseId = 4; Utils.Utils.SetPhaseOverlapPhaseType(Define.SELECTED_PHASE_OVERLAP_TYPE_PHASE); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if(t == null) { return; } ThreadPool.QueueUserWorkItem(DispatcherInitAllDetector); //Thread tDispatcherInitAllDetector = new Thread(DispatcherInitAllDetector); //tDispatcherInitAllDetector.IsBackground = true; //tDispatcherInitAllDetector.Start(); // Console.WriteLine(111); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { td = (TscData)Application.Current.Properties[Define.TSC_DATA]; if (td == null) { return; } else { ipAddress.Text = td.Node.sIpAddress; } }
private void clearStageByDeleteStage(TscData t,StageItem si) { List<StagePattern> lsp = t.ListStagePattern; foreach(StagePattern sp in lsp) { if(sldStagePatternId.Value == sp.ucStagePatternId) { if (sp.ucStageNo == Convert.ToByte(si.lblNumber.Content)) { sp.ucStageNo = 0; sp.ucGreenTime = 0; sp.ucOption = 0; sp.ucRedTime = 0; sp.ucYellowTime = 0; sp.usAllowPhase = 0; } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { initCollisionItemList(); /// 这个必需放在最前面,以便将初始化collision的数组。后面的几个方法都用到了此数组 hiddenCollision(); //将当前collision 设置为第一个collisionItem currentCollision = collision1; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if(t == null) { return; } Thread tCollisionId = new Thread(DispatcherInitCollisionId); tCollisionId.IsBackground = true; tCollisionId.Start(); //initCollisionId(); Thread tDispatcherInitDirecBigAndSmall = new Thread(DispatcherInitDirecBigAndSmall); tDispatcherInitDirecBigAndSmall.IsBackground = true; tDispatcherInitDirecBigAndSmall.Start(); //initDirecBigAndSmall(); Thread tDispatcherInitDirecPhaseLight = new Thread(DispatcherInitDirecPhaseLight); tDispatcherInitDirecPhaseLight.IsBackground = true; tDispatcherInitDirecPhaseLight.Start(); //initDirecPhaseLight(); Thread tDispatcherInitDirecCollisionPhaseRedLight = new Thread(DispatcherInitDirecCollisionPhaseRedLight); tDispatcherInitDirecCollisionPhaseRedLight.IsBackground = true; tDispatcherInitDirecCollisionPhaseRedLight.Start(); //initDirecCollisionPhaseRedLight(); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if(t == null) { return; } ThreadPool.QueueUserWorkItem(DispatcherInitSchedule); }
private void sldScheduleId_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); scheduleDataGrid.ItemsSource = initSchedule2DataGrid(t.ListSchedule); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { try { this._loading.Visibility = System.Windows.Visibility.Visible; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if(t == null) { return; } List<Plan> lp = t.ListPlan; List<Schedule> ls = t.ListSchedule; List<byte> lb = new List<byte>(); foreach (Schedule s in ls) { if (!lb.Contains(s.ucId) && s.ucEventId != 0) { lb.Add(s.ucId); } } cbxScheduleId.ItemsSource = lb; foreach (Plan p in lp) { if (p.ucId >= 31 && p.ucId <= 40) { lbxPlanId.Items.Add(p.ucId); cbxScheduleId.SelectedItem = p.ucScheduleId; initMonth(p.usMonthFlag); break; } } this._loading.Visibility = System.Windows.Visibility.Collapsed; } catch(Exception ex) { } }
/// <summary> /// 显示表单数据到界面上 /// </summary> /// <param name="id"></param> public void displayOneDetector(int id) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<Models.Detector> ld = t.ListDetector; foreach(Models.Detector d in ld) { if(id == d.ucDetectorId) { tbkPhaseId.Text = Convert.ToString(d.ucPhaseId); byte detf = d.ucDetFlag; if ((detf & 0x10) == 0x10) { rbnStategy.IsChecked = true; } if ((detf & 0x40) == 0x40) { rbnReaction.IsChecked = true; } if ((detf & 0x80) == 0x80) { rbnRequest.IsChecked = true; } if ((detf & 0x20) == 0x20) { rbnTactics.IsChecked = true; } if ((detf & 0x01) == 0x01) { rbnCar.IsChecked = true; } if ((detf & 0x02) == 0x02) { rbnBike.IsChecked = true; } if ((detf & 0x04) == 0x04) { rbnBus.IsChecked = true; } if ((detf & 0x08) == 0x08) { rbnPedestrain.IsChecked = true; } tbkVaildTime.Text = Convert.ToString(d.ucValidTime); tbxFlow.Text = Convert.ToString(d.usSaturationFlow); tbxOccupany.Text = Convert.ToString(d.ucSaturationOccupy); byte opt = d.ucOptionFlag; if ((opt & 0x01) == 0x01) { cbxCarType.IsChecked = true; } else { cbxCarType.IsChecked = false; } if ((opt & 0x02) == 0x02) { cbxKeyRoad.IsChecked = true; } else { cbxKeyRoad.IsChecked = false; } if ((opt & 0x04) == 0x04) { cbxFlow.IsChecked = true; } else { cbxFlow.IsChecked = false; } if ((opt & 0x08) == 0x08) { cbxOccupancy.IsChecked = true; } else { cbxOccupancy.IsChecked = false; } if ((opt & 0x10) == 0x10) { cbxSpeed.IsChecked = true; } else { cbxSpeed.IsChecked = false; } if ((opt & 0x20) == 0x20) { cbxQueun.IsChecked = true; } else { cbxQueun.IsChecked = false; } } } }
private void sldPlanId_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { //tbkMessage.Inlines.Add(new Run("这是测试1")); //tbkMessage.Inlines.Add(new LineBreak()); tbkMessage.Foreground = new SolidColorBrush(Colors.RoyalBlue); t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<Plan> lp = t.ListPlan; foreach(Plan p in lp) { if(p.ucId >=1 && p.ucId <=20) { ushort month = p.usMonthFlag; uint day = p.ulDayFlag; for (int i = 1; i <= 12; i++) { if (((month >> i) & 0x01) == 0x01) { string sday = ""; for (int j = 1; j <= 31; j++) { if (((day >> j) & 0x01) == 0x01) { sday = sday + " " + j; } } // str = "月份:【" + i + "】 - 日子:【" + sday + "】"; tbkMessage.Inlines.Add(new Run("编号:【" + p.ucId + "】 " + "月份:【" + i + "】 - 日子:【" + sday + "】" + " 时段:【" + p.ucScheduleId + "】")); tbkMessage.Inlines.Add(new LineBreak()); } } } } }
/// <summary> /// 初始化数据 /// </summary> /// <param name="t"></param> private void initStageAttriable(TscData t) { try { List<PhaseToDirec> lptd = t.ListPhaseToDirec; List<Pattern> lp = t.ListPattern; List<StagePattern> lsp = t.ListStagePattern; foreach (Pattern p in lp) { tbxCycle.Text = p.ucCycleTime.ToString(); cbxCoordination.SelectedItem = p.ucCoorPhase; tbxOffset.Text = p.ucOffset.ToString(); sldStagePatternId.Value = p.ucStagePatternId; foreach (StagePattern sp in lsp) { if (sp.ucStageNo != 0) { visiableStage(sp); //stage 默认是不显示的。只有存在的情况下才显示出来。ucStageNo为0不存在。 uint ap = sp.usAllowPhase; for (int i = 0; i < 32; i++) { if (((ap >> i) & 0x01) == 0x01) { foreach (PhaseToDirec ptd in lptd) { if (ptd.ucPhase != 0) { if (ptd.ucPhase == (i + 1)) { //初始化 InitStageDirec(ptd, sp); } } else { initDirecArrow(ptd, sp); } } } } sldGreenTime.Value = sp.ucGreenTime; sldYellowTime.Value = sp.ucYellowTime; sldRedTime.Value = sp.ucRedTime; cbxReaction.IsChecked = true;//sp.ucOption; // sp.ucStageNo 各个阶段编号,已经固定生成 } } sldSchemeId.Value = p.ucPatternId; //sldSchemeId有一个valuechanged事件。必需要放到其它属性之后 。不然会存在 问题 break; //第一条方案记录,及些方案数据的stagepatternid 相关的stagepattern 数据列出。 其它不进行显示 } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 将主相位在小图上,用绿色灯显示出来 /// 每个小图,就一个主相位绿灯 /// </summary> /// <param name="lptd"></param> /// <param name="lc"></param> private void initDirecPhaseLight() { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { return; } List<tscui.Models.Collision> lc = t.ListCollision; List<PhaseToDirec> lptd = t.ListPhaseToDirec; foreach(PhaseToDirec ptd in lptd) { foreach (tscui.Models.Collision c in lc) { if (c.ucPhaseId == ptd.ucPhase) { if (c.ucPhaseId == 1) { initGreenPhaseDirec(collision1,ptd); } if (c.ucPhaseId == 2) { initGreenPhaseDirec(collision2, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 3) { initGreenPhaseDirec(collision3, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 4) { initGreenPhaseDirec(collision4, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 5) { initGreenPhaseDirec(collision5, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 6) { initGreenPhaseDirec(collision6, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 7) { initGreenPhaseDirec(collision7, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 8) { initGreenPhaseDirec(collision8, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 9) { initGreenPhaseDirec(collision9, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 10) { initGreenPhaseDirec(collision10, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 11) { initGreenPhaseDirec(collision11, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 12) { initGreenPhaseDirec(collision12, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 13) { initGreenPhaseDirec(collision13, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 14) { initGreenPhaseDirec(collision14, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 15) { initGreenPhaseDirec(collision15, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 16) { initGreenPhaseDirec(collision16, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 17) { initGreenPhaseDirec(collision17, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 18) { initGreenPhaseDirec(collision18, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 19) { initGreenPhaseDirec(collision19, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 20) { initGreenPhaseDirec(collision20, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 21) { initGreenPhaseDirec(collision21, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 22) { initGreenPhaseDirec(collision22, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 23) { initGreenPhaseDirec(collision23, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 24) { initGreenPhaseDirec(collision24, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 25) { initGreenPhaseDirec(collision25, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 26) { initGreenPhaseDirec(collision26, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 27) { initGreenPhaseDirec(collision27, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 28) { initGreenPhaseDirec(collision28, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 29) { initGreenPhaseDirec(collision29, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 30) { initGreenPhaseDirec(collision30, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 31) { initGreenPhaseDirec(collision31, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } if (c.ucPhaseId == 32) { initGreenPhaseDirec(collision32, ptd); uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, collision1); } } } } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { //初始化当前阶段 currentStage = stage1; //初始化各个阶段的编号 Thread tStageNum = new Thread(DispatcherInitStageNum); tStageNum.IsBackground = true; tStageNum.Start(); // initStageNumber(); Thread tStageItem = new Thread(DispatcherInitStageItem); tStageItem.IsBackground = true; tStageItem.Start(); // initStageItemList(); Thread tCoordination = new Thread(DispatcherInitCoordination); tCoordination.IsBackground = true; tCoordination.Start(); //initcbxCoordination(); //初始化所有数据到界面上 t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { MessageBox.Show("请选择一台信号机后,切换到此界面!"); return; } //initStageAttriable(t); }
private void SaveDetector(object state) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Message m = TscDataUtils.SetDetector(t.ListDetector); }
private void sldRedTime_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { try { /// Thread.Sleep(500); Slider sld = sender as Slider; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); List<StagePattern> lsp = t.ListStagePattern; foreach (StagePattern sp in lsp) { if (currentStage != null) { if (Convert.ToByte(currentStage.lblNumber.Content) == sp.ucStageNo) { sp.ucRedTime = Convert.ToByte(sld.Value); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SetOverlapPhaseToChannel(ComboBox cb,byte id) { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); Channel cc= (Channel)cb.SelectedValue; byte cId = Convert.ToByte(cc.ucId); List<Channel> lc = t.ListChannel; foreach (Channel c in lc) { if (c.ucId == cId) { c.ucSourcePhase = id; } } }
/// <summary> /// 将绿冲突的相关冲突相位红色显示出来 /// </summary> /// <param name="lptd"></param> /// <param name="lc"></param> private void initDirecCollisionPhaseRedLight() { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { return; } List<tscui.Models.Collision> lc = t.ListCollision; List<PhaseToDirec> lptd = t.ListPhaseToDirec; //foreach(PhaseToDirec ptd in lptd) //{ foreach (tscui.Models.Collision c in lc) { //if (c.ucPhaseId == ptd.ucPhase) //{ foreach(CollisionItem ci in lci) { if (Convert.ToByte(ci.lblId.Content) == c.ucPhaseId) { uint cf = c.ucCollisionFlag; for (int i = 0; i < 32; i++) { if (((cf >> i) & 0x01) == 0x01) { foreach (PhaseToDirec ptd in lptd) { if (ptd.ucPhase == (i + 1)) initRedPhaseDirec(ptd, ci); } } } } } //initRedPhaseDirec(ptd) //} } //} }
private void tbxTailRed_SelectionChanged(object sender, RoutedEventArgs e) { TextBox tb = sender as TextBox; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); foreach (OverlapPhase op in t.ListOverlapPhase) { if (op.ucId == currentOverlapPhase) { op.ucTailRed = Convert.ToByte(tb.Text); } } }
/// <summary> /// 初始化小图上的ID,此ID采用collision的相位ID。 /// 并将其显示出来 /// </summary> /// <param name="lc"></param> private void initCollisionId() { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); if (t == null) { return; } List<tscui.Models.Collision> lc = t.ListCollision; List<PhaseToDirec> lptd = t.ListPhaseToDirec; foreach(PhaseToDirec ptd in lptd) { if (ptd.ucPhase != 0) { foreach (tscui.Models.Collision c in lc) { if (c.ucPhaseId == 1 && ptd.ucPhase == c.ucPhaseId) { collision1.lblId.Content = c.ucPhaseId; collision1.Visibility = Visibility.Visible; } if (c.ucPhaseId == 2 && ptd.ucPhase == c.ucPhaseId) { collision2.lblId.Content = c.ucPhaseId; collision2.Visibility = Visibility.Visible; } if (c.ucPhaseId == 3 && ptd.ucPhase == c.ucPhaseId) { collision3.lblId.Content = c.ucPhaseId; collision3.Visibility = Visibility.Visible; } if (c.ucPhaseId == 4 && ptd.ucPhase == c.ucPhaseId) { collision4.lblId.Content = c.ucPhaseId; collision4.Visibility = Visibility.Visible; } if (c.ucPhaseId == 5 && ptd.ucPhase == c.ucPhaseId) { collision5.lblId.Content = c.ucPhaseId; collision5.Visibility = Visibility.Visible; } if (c.ucPhaseId == 6 && ptd.ucPhase == c.ucPhaseId) { collision6.lblId.Content = c.ucPhaseId; collision6.Visibility = Visibility.Visible; } if (c.ucPhaseId == 7 && ptd.ucPhase == c.ucPhaseId) { collision7.lblId.Content = c.ucPhaseId; collision7.Visibility = Visibility.Visible; } if (c.ucPhaseId == 8 && ptd.ucPhase == c.ucPhaseId) { collision8.lblId.Content = c.ucPhaseId; collision8.Visibility = Visibility.Visible; } if (c.ucPhaseId == 9 && ptd.ucPhase == c.ucPhaseId) { collision9.lblId.Content = c.ucPhaseId; collision9.Visibility = Visibility.Visible; } if (c.ucPhaseId == 10 && ptd.ucPhase == c.ucPhaseId) { collision10.lblId.Content = c.ucPhaseId; collision10.Visibility = Visibility.Visible; } if (c.ucPhaseId == 11 && ptd.ucPhase == c.ucPhaseId) { collision11.lblId.Content = c.ucPhaseId; collision11.Visibility = Visibility.Visible; } if (c.ucPhaseId == 12 && ptd.ucPhase == c.ucPhaseId) { collision12.lblId.Content = c.ucPhaseId; collision12.Visibility = Visibility.Visible; } if (c.ucPhaseId == 13 && ptd.ucPhase == c.ucPhaseId) { collision13.lblId.Content = c.ucPhaseId; collision13.Visibility = Visibility.Visible; } if (c.ucPhaseId == 14 && ptd.ucPhase == c.ucPhaseId) { collision14.lblId.Content = c.ucPhaseId; collision14.Visibility = Visibility.Visible; } if (c.ucPhaseId == 15 && ptd.ucPhase == c.ucPhaseId) { collision15.lblId.Content = c.ucPhaseId; collision15.Visibility = Visibility.Visible; } if (c.ucPhaseId == 16 && ptd.ucPhase == c.ucPhaseId) { collision16.lblId.Content = c.ucPhaseId; collision16.Visibility = Visibility.Visible; } if (c.ucPhaseId == 17 && ptd.ucPhase == c.ucPhaseId) { collision17.lblId.Content = c.ucPhaseId; collision17.Visibility = Visibility.Visible; } if (c.ucPhaseId == 18 && ptd.ucPhase == c.ucPhaseId) { collision18.lblId.Content = c.ucPhaseId; collision18.Visibility = Visibility.Visible; } if (c.ucPhaseId == 19 && ptd.ucPhase == c.ucPhaseId) { collision19.lblId.Content = c.ucPhaseId; collision19.Visibility = Visibility.Visible; } if (c.ucPhaseId == 20 && ptd.ucPhase == c.ucPhaseId) { collision20.lblId.Content = c.ucPhaseId; collision20.Visibility = Visibility.Visible; } if (c.ucPhaseId == 21 && ptd.ucPhase == c.ucPhaseId) { collision21.lblId.Content = c.ucPhaseId; collision21.Visibility = Visibility.Visible; } if (c.ucPhaseId == 22 && ptd.ucPhase == c.ucPhaseId) { collision22.lblId.Content = c.ucPhaseId; collision22.Visibility = Visibility.Visible; } if (c.ucPhaseId == 23 && ptd.ucPhase == c.ucPhaseId) { collision23.lblId.Content = c.ucPhaseId; collision23.Visibility = Visibility.Visible; } if (c.ucPhaseId == 24 && ptd.ucPhase == c.ucPhaseId) { collision24.lblId.Content = c.ucPhaseId; collision24.Visibility = Visibility.Visible; } if (c.ucPhaseId == 25 && ptd.ucPhase == c.ucPhaseId) { collision25.lblId.Content = c.ucPhaseId; collision25.Visibility = Visibility.Visible; } if (c.ucPhaseId == 26 && ptd.ucPhase == c.ucPhaseId) { collision26.lblId.Content = c.ucPhaseId; collision26.Visibility = Visibility.Visible; } if (c.ucPhaseId == 27 && ptd.ucPhase == c.ucPhaseId) { collision27.lblId.Content = c.ucPhaseId; collision27.Visibility = Visibility.Visible; } if (c.ucPhaseId == 28 && ptd.ucPhase == c.ucPhaseId) { collision28.lblId.Content = c.ucPhaseId; collision28.Visibility = Visibility.Visible; } if (c.ucPhaseId == 29 && ptd.ucPhase == c.ucPhaseId) { collision29.lblId.Content = c.ucPhaseId; collision29.Visibility = Visibility.Visible; } if (c.ucPhaseId == 30 && ptd.ucPhase == c.ucPhaseId) { collision30.lblId.Content = c.ucPhaseId; collision30.Visibility = Visibility.Visible; } if (c.ucPhaseId == 31 && ptd.ucPhase == c.ucPhaseId) { collision31.lblId.Content = c.ucPhaseId; collision31.Visibility = Visibility.Visible; } if (c.ucPhaseId == 32 && ptd.ucPhase == c.ucPhaseId) { collision32.lblId.Content = c.ucPhaseId; collision32.Visibility = Visibility.Visible; } } } } }
private void cbxOperateType_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox cb = sender as ComboBox; OverlapPhaseType opt = (OverlapPhaseType)cb.SelectedValue; t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); foreach (OverlapPhase op in t.ListOverlapPhase) { if (op.ucId == currentOverlapPhase) { op.ucTailRed = Convert.ToByte(opt.value); } } }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { try { td = (TscData)Application.Current.Properties[Define.TSC_DATA]; initScheduleId(); if (td == null) { return; } List<Plan> lp = td.ListPlan; foreach(Plan p in lp) { //如果没有数据不会进入 if (p.ucId>=21 && p.ucId <=30) { ///Summer.IsChecked = true; lbxPlanId.Items.Add(p.ucId); //initWeekdayDisplay(p.ucWeekFlag); } } cbxScheduleId.SelectedItem = (byte)1; } catch(Exception ex) { //MessageBox.Show(ex.ToString()); //ApexBroker.GetShell().ShowPopup(new FailePopup()); } }
private void DisplayOverlapPhase(byte id) { try { t = Utils.Utils.GetTscDataByApplicationCurrentProperties(); foreach (OverlapPhase op in t.ListOverlapPhase) { if (id == 1) { for (int a = 0; a < op.ucIncludePhase.Length; a++) { if (op.ucIncludePhase[a] != 0) { ccbIncludePhase1.Items.Add(op.ucIncludePhase[a]); } } for (int a = 0; a < op.ucCorrectPhase.Length; a++) { if (op.ucCorrectPhase[a] != 0) { ccbCorrectPhase.Items.Add(op.ucCorrectPhase[a]); } } tbxYellowTime.Text = Convert.ToString(op.ucTailYellow); tbxRedTime.Text = Convert.ToString(op.ucTailRed); tbxTailGreen.Text = Convert.ToString(op.ucTailGreen); cbxOperateType.SelectedValue = op.ucOperateType; } } } catch(Exception ex ) { //Xceed.Wpf.Toolkit.MessageBox.Show("请重新选择一个跟随相位"); } }