コード例 #1
0
        private void UpdateBusListPanels() //외부 쓰레드에서 호출되는 함수
        {
            BusThread_RunningState += 1;

            while (BusThread_RunningState < 3)
            {
                BusInfo.UpdateBusInfoList();

                foreach (BusListPanel b in BusListPanelList)
                {
                    this.Dispatcher.Invoke(new de(() => b.SetPanelBusInfo(BusInfo.FindByBusName(b.BusName.Content.ToString()))));
                }

                Update057();

                Thread.Sleep(base_.BUS_UPDATE_TERM);
            }

            BusThread_RunningState += 1;
            d.write($"UpdateBusListPanels() Termination, BusThread_RunningState={BusThread_RunningState}");
        }
コード例 #2
0
        private void Update057() //외부 쓰레드에서 호출되는 함수, UpdateBusLIstPanels()로부터 호출받음.
        {
            //UpdateBusInfoList() 했다고 가정
            //BusInfo.PrintBusInfoList();
            var bsinfo = BusInfo.FindByBusName("057");

            if (bsinfo != null)
            {
                if (!bsinfo.bustime.Contains("잠시 후") && LastBus057time.Contains("잠시 후")) //버스 도착 순간
                {
                    d.write("[057watcher] 057 arrived");
                    d.write("[057watcher] Starting new term counter");

                    Bus057TermCountThread.StartCount();

                    this.Dispatcher.Invoke(new de(Bus057PanelNormalMode));
                    Bus057DetectionCount += 1;
                }

                if (bsinfo.bustime.Contains("잠시 후"))
                {
                    this.Dispatcher.Invoke(new de(Bus057PanelActiveMode));

                    if (bsinfo.bustime.Contains("잠시 후") && !LastBus057time.Contains("잠시 후") && Bus057TermCountThread.Started)
                    {
                        base_.Update057Average(Bus057TermCountThread.Count + 60 * 2);
                        d.write($"[057watcher] term counter stopped, term={Bus057TermCountThread.Count + 60 * 2}sec, saving result.");
                        Bus057TermCountThread.StopCount();
                    }
                }

                LastBus057time = bsinfo.bustime;
            }
            else
            {
                d.write("[057watcher] null string received, ignoring");
            }
        }
コード例 #3
0
        public BusInfoPage()
        {
            InitializeComponent();

            this.IsVisibleChanged += (object sender, DependencyPropertyChangedEventArgs e) => //sender, e는 사실상 사용되지 않는다.
            {
                if (this.Visibility == Visibility.Hidden)
                {
                    StopUpdate();
                }
            };

            //업데이트
            BusInfo.UpdateBusInfoList();
            // base_.Update057Average(0, true); //app.xaml에서 담당.
            // base_.UpdateBusShowList();

            //Bus057Panel 2개 추가

            MainGrid.Children.Add(Bus057ActivePanel);
            MainGrid.Children.Add(Bus057NormalPanel);

            Bus057PanelNormalMode();


            //4개의 BusListPanel

            int bus_list_panel_add_cnt = 0;

            foreach (string i in base_.BUS_SHOW_LIST)
            {
                var fb = BusInfo.FindByBusName(i);

                if (fb != null)
                {
                    BusListPanel b = new BusListPanel();
                    b.SetPanelBusInfo(fb);
                    MainGrid.Children.Add(b);

                    //todo: 4개 이상 버스 있을시 전환효과.

                    b.Margin = new Thickness(

                        this.Width - b.Width, //left, 여기서부터 시계방향으로 돌아감
                        TopPanel.Height + bus_list_panel_add_cnt * b.Height,
                        0,
                        this.Height - (TopPanel.Height + bus_list_panel_add_cnt * b.Height + b.Height)

                        );



                    BusListPanelList.Add(b);
                    bus_list_panel_add_cnt += 1;
                }
            }

            //업데이트 쓰레드 설정
            BusListPanelsUpdateThread = new Thread(UpdateBusListPanels);
            BusListPanelsUpdateThread.Start();

            Thread.Sleep(base_.BUS_FIRST_START_WAIT_TIME);

            Bus057UpdateThread = new Thread(Update057Text);
            Bus057UpdateThread.Start();
        }