void ReCalculateAll()
        {
            double widthfactor = firstlineup.ActualWidth / 24;

            if (this.DataContext != null)
            {
                MonitorDataModel data = this.DataContext as MonitorDataModel;
                firstlineup.Children.Clear();
                firstlinedown.Children.Clear();
                secondlineup.Children.Clear();
                secondlinedown.Children.Clear();

                foreach (Train train in data.SubWayLines[0].Trains)
                {
                    Image image = new Image();
                    image.Cursor   = Cursors.Hand;
                    image.Width    = 10;
                    image.Tag      = train;
                    image.Height   = 10;
                    image.Stretch  = Stretch.Fill;
                    image.Source   = new BitmapImage(new Uri("/MonitorPlatform;component/Resource/Car_Normal.png", UriKind.RelativeOrAbsolute));
                    image.MouseUp += new MouseButtonEventHandler(image_MouseUp);
                    double orgin_car_posX = widthfactor * (train.Location - 0.5) - image.Width / 2;  //first(train.Location);
                    if (train.IsDown)
                    {
                        firstlinedown.Children.Add(image);
                    }
                    else
                    {
                        firstlineup.Children.Add(image);
                    }
                    Canvas.SetTop(image, 5);
                    Canvas.SetLeft(image, orgin_car_posX);
                }

                foreach (Train train in data.SubWayLines[1].Trains)
                {
                    Image image = new Image();
                    image.Cursor   = Cursors.Hand;
                    image.Tag      = train;
                    image.Width    = 10;
                    image.Height   = 10;
                    image.Stretch  = Stretch.Fill;
                    image.MouseUp += new MouseButtonEventHandler(image_MouseUp);
                    image.Source   = new BitmapImage(new Uri("/MonitorPlatform;component/Resource/Car_Normal.png", UriKind.RelativeOrAbsolute));

                    double orgin_car_posX = widthfactor * (train.Location - 0.5) - image.Width / 2;  //first(train.Location);
                    if (train.IsDown)
                    {
                        secondlinedown.Children.Add(image);
                    }
                    else
                    {
                        secondlineup.Children.Add(image);
                    }
                    Canvas.SetTop(image, 5);
                    Canvas.SetLeft(image, orgin_car_posX);
                }
            }
        }
 public TrafficRight()
 {
     InitializeComponent();
     grid.ItemsSource             = MonitorDataModel.Instance().CurrrentLine.History_Stations;
     grid.View.FocusedRowChanged += new DevExpress.Xpf.Grid.FocusedRowChangedEventHandler(View_FocusedRowChanged);
     grid.View.FocusedRowHandle   = 0;
 }
        void image_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Train trainin = (sender as Image).Tag as Train;

            MonitorDataModel.Instance().CurrentTrain = trainin;
            WindowManager.Instance.ShowTrainLocationCenter();
        }
 public EquipmentStatusLeft()
 {
     InitializeComponent();
     bigsection           = (Style)Application.Current.TryFindResource("BigPopupSection");
     bigsectionwithout    = (Style)Application.Current.TryFindResource("BigPopupWithoutBorderSection");
     line1Border.MouseUp += new MouseButtonEventHandler(line1Border_MouseUp);
     line2Border.MouseUp += new MouseButtonEventHandler(line2Border_MouseUp);
     MonitorDataModel.Instance().CurrrentLine = MonitorDataModel.Instance().SubWayLines[0];
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     LoadPoints();
     this.WindowState = WindowState.Maximized;
     this.WindowStyle = System.Windows.WindowStyle.None;
     this.DataContext = MonitorDataModel.Instance();
     DataCenter.Instance.UpdateTrainLocationEvent += new DataCenter.UpdateTrainLocation(Instance_UpdateTrainLocationEvent);
     this.SizeChanged += new SizeChangedEventHandler(TrainLocationCenter_SizeChanged);
 }
        public TrainLocationCenter()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(TrainLocationCenter_Loaded);
            LoadPoints();
            DataCenter.Instance.UpdateTrainLocationEvent += new DataCenter.UpdateTrainLocation(Instance_UpdateTrainLocationEvent);
            this.SizeChanged += new SizeChangedEventHandler(TrainLocationCenter_SizeChanged);
            MonitorDataModel.Instance().CurrentTrainChangedEvent += new MonitorDataModel.CurrentTrainChanged(TrainLocationCenter_CurrentTrainChangedEvent);
        }
Exemplo n.º 7
0
        public void SetDataSource()
        {
            if (this.lines == null || this.datePicker1 == null || this.status == null || this.type == null || this.grade == null)
            {
                return;
            }
            ObservableCollection <EventData>    source   = new ObservableCollection <EventData>();
            ObservableCollection <StationInOut> troubles = new ObservableCollection <StationInOut>();

            troubles.Add(new StationInOut()
            {
                Name = "1号线", Number = MonitorDataModel.Instance().SubWayLines[0].EventDatas.Count
            });
            troubles.Add(new StationInOut()
            {
                Name = "2号线", Number = MonitorDataModel.Instance().SubWayLines[1].EventDatas.Count
            });

            IEnumerable <EventData> data1 = null;
            IEnumerable <EventData> data2 = null;
            string       selectedText     = "";
            ComboBoxItem cbi = (ComboBoxItem)lines.SelectedItem;

            if (cbi != null)
            {
                selectedText = cbi.Content.ToString();
            }
            //Status:0-已处理,1-未处里,2-忽略
            if (selectedText == "1号线" || selectedText == "全部" || selectedText == "")
            {
                data1 = FilterByTime(FilterByStatus(FilterByType(FilterByGrade(MonitorDataModel.Instance().SubWayLines[0].EventDatas))));
            }
            if (selectedText == "2号线" || selectedText == "全部" || selectedText == "")
            {
                data2 = FilterByTime(FilterByStatus(FilterByType(FilterByGrade(MonitorDataModel.Instance().SubWayLines[1].EventDatas))));
            }
            source.Clear();
            if (data1 != null)
            {
                foreach (EventData eve in data1)
                {
                    source.Add(eve);
                }
            }
            if (data2 != null)
            {
                foreach (EventData eve in data2)
                {
                    source.Add(eve);
                }
            }
            this.gridEvent.ItemsSource      = source;
            this.lineEventChart.ItemsSource = troubles;
        }
        void line1Border_MouseUp(object sender, MouseButtonEventArgs e)
        {
            txtLineNumber.Text          = "1";
            line1Border.Style           = bigsection;
            line2Border.Style           = bigsectionwithout;
            borderLineNumber.Background = new SolidColorBrush(Colors.Green);
            Line1Status sta = new Line1Status();

            sta.DataContext   = MonitorDataModel.Instance().SubWayLines[0].StaTroubles;
            borderLines.Child = new Line1Status();
            MonitorDataModel.Instance().CurrrentLine = MonitorDataModel.Instance().SubWayLines[0];
        }
        public void TestMonitorDataModelJSONConstructor()
        {
            string           param   = "{param:[{\"Result\":\"Test123\"},{\"MonitorTimestamp\":\"2015-04-01 15:02:55.177\"},{\"ObjectID\":\"TEstOBject\"},{\"AgentNr\":\"123\"},]}";
            DateTime         time    = DateTime.Parse("2015-04-01 15:02:55.177");
            JObject          jobject = JObject.Parse(param);
            MonitorDataModel monitor = new MonitorDataModel(jobject);

            Assert.AreEqual("Test123", monitor.Result);
            Assert.AreEqual(time, monitor.MonitorTimestamp);
            Assert.AreEqual("TEstOBject", monitor.ObjectID);
            Assert.AreEqual(123, monitor.AgentID);
        }
        public void SendSNMPData(MonitorDataModel dataToShow)
        {
            try
            {
                IHubContext context = GlobalHost.ConnectionManager.GetHubContext <SNMPDataHub>();

                context.Clients.Group("Agent_General").receiveData(JObject.FromObject(dataToShow, this.GetSerializer()));
            }
            catch (Exception exc)
            {
                BusinessLayer.ExceptionHandling.ExceptionCore.HandleException(BusinessLayer.ExceptionHandling.ExceptionCategory.Normal, exc);
            }
        }
        public void TestMonitorDataModelGetSet()
        {
            DateTime         Now   = DateTime.Now;
            MonitorDataModel model = new MonitorDataModel();

            model.AgentID          = 12;
            model.ObjectID         = "1.132.3";
            model.MonitorTimestamp = Now;
            model.Result           = "Result";

            Assert.AreEqual(12, model.AgentID);
            Assert.AreEqual("1.132.3", model.ObjectID);
            Assert.AreEqual(Now, model.MonitorTimestamp);
            Assert.AreEqual("Result", model.Result);
        }
Exemplo n.º 12
0
        private MonitorDataModel ConvertToMonitorData(Event eve)
        {
            var model = new MonitorDataModel
            {
                Name   = eve.Name,
                Source = eve.Source,
                Time   = eve.Time,
                Type   = eve.Type
            };

            JObject obj = JObject.Parse(eve.Body);

            model.ImageUrl = (string)obj["snapshot"];
            model.VideoUrl = (string)obj["video"];
            return(model);
        }
        public void SetPropByCurrentTrain()
        {
            Train t = MonitorDataModel.Instance().CurrentTrain;

            if (t != null)
            {
                DateTime now = DateTime.Now;
                txtCurrentDate.Text = now.ToString("yyyy-MM-dd");

                SubLine line = MonitorDataModel.Instance().SubWayLines[t.LineNo];
                stationGrid.ItemsSource = line.Stations;
                double nextstationID;
                if (t.IsDown)
                {
                    if (line.Stations.Count > (int)t.Location && (int)t.Location >= 0)
                    {
                        Station next = line.Stations[(int)t.Location];
                        this.txtNextStation.Text        = next.Name;
                        this.txtEstimateArrivaTime.Text = now.AddMinutes(next.DownFirstTime).ToString("HH:mm");
                        this.txtPlanArriveTime.Text     = this.txtEstimateArrivaTime.Text;
                    }
                    else
                    {
                        this.txtNextStation.Text        = "终点站";
                        this.txtPlanArriveTime.Text     = now.ToString("HH:mm");
                        this.txtEstimateArrivaTime.Text = now.ToString("HH:mm");
                    }
                }
                else
                {
                    nextstationID = t.Location - 2;
                    if (line.Stations.Count > (int)(t.Location - 2) && (int)(t.Location - 2) >= 0)
                    {
                        Station next = line.Stations[(int)t.Location - 2];
                        this.txtNextStation.Text        = next.Name;
                        this.txtEstimateArrivaTime.Text = now.AddMinutes(next.UpFirstTime).ToString("HH:mm");
                        this.txtPlanArriveTime.Text     = this.txtEstimateArrivaTime.Text;
                    }
                    else
                    {
                        this.txtNextStation.Text        = "终点站";
                        this.txtPlanArriveTime.Text     = now.ToString("HH:mm");
                        this.txtEstimateArrivaTime.Text = now.ToString("HH:mm");
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void ReCalculateAll()
        {
            int    orign_height = 739;
            int    orign_width  = 1709;
            double widthfactor  = this.ActualWidth / orign_width;
            double heightfactor = this.ActualHeight / orign_height;

            infoborder.Children.Clear();
            foreach (Train train in MonitorDataModel.Instance().SubWayLines[0].Trains)
            {
                DrawTrain(train, widthfactor, heightfactor);
            }
            foreach (Train train in MonitorDataModel.Instance().SubWayLines[1].Trains)
            {
                DrawTrain(train, widthfactor, heightfactor);
            }
        }
        public EquipmentStatusCenter()
        {
            InitializeComponent();

            gridStation.ItemsSource             = MonitorDataModel.Instance().SubWayLines[0].Stations;
            gridStation.View.FocusedRowChanged += new DevExpress.Xpf.Grid.FocusedRowChangedEventHandler(View_FocusedRowChanged);
            chk_AFC.Click    += new RoutedEventHandler(chk_AFC_Click);
            chk_FAS.Click    += new RoutedEventHandler(chk_AFC_Click);
            chk_BAS.Click    += new RoutedEventHandler(chk_AFC_Click);
            chk_PSCADA.Click += new RoutedEventHandler(chk_AFC_Click);
            chk_PSD.Click    += new RoutedEventHandler(chk_AFC_Click);
            chk_PIS.Click    += new RoutedEventHandler(chk_AFC_Click);
            chk_PA.Click     += new RoutedEventHandler(chk_AFC_Click);

            chk_CC.Click      += new RoutedEventHandler(chk_Type_Click);
            chk_Train.Click   += new RoutedEventHandler(chk_Type_Click);
            chk_Station.Click += new RoutedEventHandler(chk_Type_Click);
            chk_Other.Click   += new RoutedEventHandler(chk_Type_Click);
        }
        public void SetGridSource()
        {
            if (gridStation == null)
            {
                return;
            }
            var condition = GetCheckedType();

            int line = 0;

            if (chkLine.IsChecked.HasValue)
            {
                line = chkLine.IsChecked.Value?0:1;
            }
            var stations = MonitorDataModel.Instance().SubWayLines[line].Stations;


            this.gridStation.ItemsSource = stations.Where(x => condition.Contains(x.SType));
        }
        void View_FocusedRowChanged(object sender, DevExpress.Xpf.Grid.FocusedRowChangedEventArgs e)
        {
            int lineid = 0;

            if (chkLine.IsChecked.HasValue)
            {
                if (chkLine.IsChecked.Value)
                {
                    lineid = 0;
                }
                else
                {
                    lineid = 1;
                }
            }
            //string name = griddetail.View.FocusedRowData.CellData[0].Value.ToString();
            if (e.NewRow == null)
            {
                return;
            }
            Station s = e.NewRow as Station; //line.Stations.SingleOrDefault(x => x.Name == name);

            if (s != null)
            {
                DataCenter.Instance.UpdateEquipmentDetailCenter(s.StaGUID, GetSelectChk(), lineid);

                griddetail.ItemsSource = s.Equipments;

                MonitorDataModel.Instance().CurrentStation = s;
                if (s.Name.Contains("广济南路"))
                {
                    WindowManager.Instance.ShowEquipmentRight();
                }
                else
                {
                    WindowManager.Instance.CloseEquipmentRight();
                }
            }
        }
Exemplo n.º 18
0
        private void chkLine_Click(object sender, RoutedEventArgs e)
        {
            if (grid == null)
            {
                return;
            }
            bool isfirstline = true;

            if (chkLine.IsChecked.HasValue)
            {
                isfirstline = chkLine.IsChecked.Value;
            }

            if (isfirstline)
            {
                grid.ItemsSource = MonitorDataModel.Instance().SubWayLines[0].History_Stations;
            }
            else
            {
                grid.ItemsSource = MonitorDataModel.Instance().SubWayLines[1].History_Stations;
            }
            grid.View.FocusedRowHandle = 0;
        }
Exemplo n.º 19
0
        void UpdateStationInfor(object sender, int subway)
        {
            stationinfo.IsOpen          = true;
            stationinfo.PlacementTarget = sender as UIElement;
            SubLine line  = MonitorDataModel.Instance().SubWayLines[subway];
            string  name  = (sender as Canvas).Name;
            int     index = int.Parse(name.Substring(name.IndexOf("_") + 1));
            Station s     = line.Stations[index - 1];

            stationName.Text = s.Name;
            inNumber.Text    = s.InNumber.ToString();
            outNumber.Text   = s.OutNumber.ToString();

            if (subway == 0)
            {
                sublinename.Text         = "1";
                sublineBorder.Background = new SolidColorBrush(Colors.Green);
            }
            else
            {
                sublinename.Text         = "2";
                sublineBorder.Background = new SolidColorBrush(Colors.Red);
            }
        }
Exemplo n.º 20
0
        public void ReCalculateAll()
        {
            //5-1300
            //7-1300
            int orgin_firstlineheight  = 83;
            int orgin_secondlineheight = 141;
            int orgin_thirdlineheight  = 206;
            int orgin_forthlineheight  = 262;

            orgin_1_length = (1315 - orgin_1_start) / 23.0;
            orgin_2_length = (1315 - orgin_2_start) / 21.0;
            widthfactor    = traingrid.ActualWidth / orignwidth;
            heightfactor   = traingrid.ActualHeight / orginheight;

            calwidth  = (int)(20 * widthfactor);
            calheight = (int)(22 * heightfactor);

            firstlineposY  = (int)(orgin_firstlineheight * heightfactor);
            secondlineposY = (int)(orgin_secondlineheight * heightfactor);
            thirdlineposY  = (int)(orgin_thirdlineheight * heightfactor);
            forthlineposY  = (int)(orgin_forthlineheight * heightfactor);

            cal first  = (x) => orgin_1_start + orgin_1_length * (x - 1);
            cal second = (x) => orgin_2_start + orgin_2_length * (x - 1);

            if (this.DataContext != null)
            {
                MonitorDataModel data = this.DataContext as MonitorDataModel;
                traingrid.Children.Clear();

                foreach (Train train in data.SubWayLines[0].Trains)
                {
                    Image image = new Image();
                    image.Width   = calwidth;
                    image.Height  = calheight;
                    image.Stretch = Stretch.Fill;
                    image.Source  = new BitmapImage(new Uri("/MonitorPlatform;component/Resource/Car_Normal.png", UriKind.RelativeOrAbsolute));
                    traingrid.Children.Add(image);
                    double orgin_car_posX = orgin_1_start + orgin_1_length * (train.Location - 1);  //first(train.Location);
                    if (train.IsDown)
                    {
                        Canvas.SetTop(image, firstlineposY);
                        Canvas.SetLeft(image, orgin_car_posX * widthfactor);
                    }
                    else
                    {
                        Canvas.SetTop(image, secondlineposY);
                        Canvas.SetLeft(image, orgin_car_posX * widthfactor);
                    }
                }

                foreach (Train train in data.SubWayLines[1].Trains)
                {
                    Image image = new Image();
                    image.Width   = calwidth;
                    image.Height  = calheight;
                    image.Stretch = Stretch.Fill;
                    image.Source  = new BitmapImage(new Uri("/MonitorPlatform;component/Resource/Car_Normal.png", UriKind.RelativeOrAbsolute));
                    traingrid.Children.Add(image);
                    double orgin_car_posX = orgin_2_start + orgin_2_length * (train.Location - 1);
                    if (train.IsDown)
                    {
                        Canvas.SetTop(image, thirdlineposY);
                        Canvas.SetLeft(image, orgin_car_posX * widthfactor);
                    }
                    else
                    {
                        Canvas.SetTop(image, forthlineposY);
                        Canvas.SetLeft(image, orgin_car_posX * widthfactor);
                    }
                }
            }
        }
        void EquipmentStatusRight_Loaded(object sender, RoutedEventArgs e)
        {
            Station station = MonitorDataModel.Instance().CurrentStation;

            DrawEquipment(station);
        }
Exemplo n.º 22
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            IAppSetting   appSetting   = new AppSetting();
            string        requestBody  = await new StreamReader(req.Body).ReadToEndAsync();
            IStorageProxy storageProxy = new StorageProxy(appSetting.StorageConnectionString);
            await storageProxy.WriteTable(appSetting.LogTableName, requestBody);

            if (string.IsNullOrEmpty(requestBody))
            {
                return(new StatusCodeResult(404));
            }
            List <MonitorDataModel> monitorDatas = new List <MonitorDataModel>();

            try
            {
                var singleMonitorDatas = requestBody.ConvertToObj <List <SingleMonitorDataContract> >();
                foreach (var singleMonitorData in singleMonitorDatas)
                {
                    foreach (var data in singleMonitorData.Data.IData)
                    {
                        var device             = singleMonitorData.Data.DName.Split(',');
                        MonitorDataModel model = new MonitorDataModel
                        {
                            Id          = Guid.NewGuid().ToString(),
                            GatewayId   = singleMonitorData.GSN,
                            DeviceId    = singleMonitorData.Data.DId,
                            DeviceName  = device[0],
                            DeviceType  = device.Length == 2 ? device[1] : string.Empty,
                            MonitorId   = data.IId,
                            MonitorName = data.IName,
                            MonitorType = data.IType,
                            Unit        = data.IUnit,
                            Value       = data.IValue,
                            IsScan      = false,
                            Timestamp   = DateTime.Now
                        };
                        monitorDatas.Add(model);
                    }
                }
            }
            catch (Exception)
            {
                var multpleMonitorDatas = requestBody.ConvertToObj <List <MultipleMonitorDataContract> >();
                foreach (var multpleMonitorData in multpleMonitorDatas)
                {
                    foreach (var monitorData in multpleMonitorData.Data)
                    {
                        var device = monitorData.DName.Split(',');
                        foreach (var data in monitorData.IData)
                        {
                            MonitorDataModel model = new MonitorDataModel
                            {
                                Id          = Guid.NewGuid().ToString(),
                                GatewayId   = multpleMonitorData.GSN,
                                DeviceId    = monitorData.DId,
                                DeviceName  = device[0],
                                DeviceType  = device.Length == 2 ? device[1] : string.Empty,
                                MonitorId   = data.IId,
                                MonitorName = data.IName,
                                MonitorType = data.IType,
                                Unit        = data.IUnit,
                                Value       = data.IValue,
                                IsScan      = false,
                                Timestamp   = DateTime.Now
                            };
                            monitorDatas.Add(model);
                        }
                    }
                }
            }
            MongoHelper mongoHelper = new MongoHelper(appSetting.MongoDBConnectionString, appSetting.MongoDBName);

            foreach (var data in monitorDatas)
            {
                mongoHelper.InsertOne <MonitorDataModel>(appSetting.MongoCollectionName, data);
            }

            //TODO:insert monitor data to database
            //using (SqlHelper helper = new SqlHelper(connectionString))
            //{
            //    string sql = "insert into ....";
            //    helper.ExecuteNonQuery(sql, CommandType.Text);
            //}
            return(new OkObjectResult($"Hello, IoTManager"));
        }
Exemplo n.º 23
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     this.WindowState = WindowState.Maximized;
     this.WindowStyle = System.Windows.WindowStyle.None;
     this.DataContext = MonitorDataModel.Instance();
 }