コード例 #1
0
ファイル: SimComm.cs プロジェクト: yesuj17/WeatherWeb
        public bool ReadMachineRealTimeData()
        {
            foreach (KeyValuePair <int, SimMachine> d in _dicSimMachine)
            {
                MachineRealTimeData realTimeData = new MachineRealTimeData();
                realTimeData.MachineID  = d.Key;
                realTimeData.MotorInfos = new List <MotorInfo>();

                SimMachine simMachine = d.Value;

                int[] drivingCurrents  = simMachine.GetDrivingCurrent();
                int[] hoistingCurrents = simMachine.GetHoistingCurrent();
                int[] forkCurrents     = simMachine.GetForkCurrent();

                DateTime dt = DateTime.UtcNow;
                for (int i = 0; i < drivingCurrents.Length; i++)
                {
                    DateTime newDT = dt.AddSeconds((i + 1) - drivingCurrents.Length);
                    realTimeData.MotorInfos.Add(
                        new MotorInfo(
                            newDT.ToString("o"),
                            drivingCurrents[i],
                            hoistingCurrents[i],
                            forkCurrents[i]));
                }

                if (_dicMachineRealTimeData.ContainsKey(d.Key) == true)
                {
                    _dicMachineRealTimeData[d.Key] = realTimeData;
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: ServerComm.cs プロジェクト: yesuj17/WeatherWeb
        public bool SendMachineRealTimeData(MachineRealTimeData data)
        {
            if (data == null)
            {
                return(false);
            }

            string jsonString = data.Serializer();

            InsertSendQueue("MA/addMachineRealTimeData", jsonString);

            return(true);
        }
コード例 #3
0
        private void RealTimeWatcher()
        {
            UIHelper.LogInfo(string.Format("RealTime Data를 {0}주기로 수집", _realTimeCollectInterval));

            int count      = 0;
            int checkCount = _realTimeCollectInterval / 100;

            while (!_shouldStop)
            {
                if (count < checkCount)
                {
                    // Wait
                    Thread.Sleep(100);

                    count++;
                    continue;
                }
                count = 0;

                // Collect Data from DB
                if (_machineInterface.ReadMachineRealTimeData() == false)
                {
                    UIHelper.UpdateDBCommStatus(false);
                    continue;
                }

                UIHelper.UpdateDBCommStatus(true);

                foreach (MachineInfo mInfo in _listMachineInfo)
                {
                    MachineRealTimeData rtData = _machineInterface.GetMachineRealTimeData(mInfo.ID);

                    _serverComm.SendMachineRealTimeData(rtData);
                }
            }

            UIHelper.LogInfo("RealTime Data 수집 종료");
        }