Пример #1
0
        /// <summary>
        /// 刷新显示数据
        /// </summary>
        /// <param name="rest"></param>
        public static void Show(string str)
        {
            var rest        = JsonConvert.DeserializeObject <Rest <List <MesMqParam> > >(str);
            var dataDetails = new List <DataDetail>();

            foreach (var param in rest.data)
            {
                var detail = new DataDetail();
                detail.MachineID       = param.MachineID;
                detail.CollectedTime   = param.CollectedTime;
                detail.ParameterCodeID = param.ParameterCodeID;
                detail.CollectedValue  = param.CollectedValue;
                dataDetails.Add(detail);
            }
            if (dataDetails == null || dataDetails.Count <= 0 ||
                machineProductionInfo == null)
            {
                return;
            }

            foreach (var dataDetail in dataDetails)
            {
                if (currentMachineID == dataDetail.MachineID)
                {
                    machineProductionInfo.AddDataDetail(dataDetail);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 读取并更新生产数据
 /// </summary>
 /// <param name="state"></param>
 private void ReadAndUpdateProductionInfo(object state)
 {
     while (true)
     {
         if (dataDetailList.Count > 0)
         {
             DataDetail dataDetail = null;
             lock (dataDetailLock) {
                 dataDetail = dataDetailList[0];
                 dataDetailList.RemoveAt(0);
             }
             if (dataDetail != null)
             {
                 AddSampleValue(dataDetail);
             }
         }
         Thread.Sleep(5); // 线程稍微睡眠,防止CPU占用过高
     }
 }
Пример #3
0
        /// <summary>
        /// 添加采集数据
        /// </summary>
        private void AddSampleValue(DataDetail dataDetail)
        {
            switch (dataDetail.ParameterCodeID)
            {
            case 2:     // od值
                if ((DateTime.Now - lastOuterDiameterRecvTime).TotalMilliseconds > 300)
                {
                    OuterDiameter = dataDetail.CollectedValue;
                    OnDoublePropertyChanged(2, ParseDateTime(dataDetail.CollectedTime),
                                            dataDetail.CollectedValue);

                    lastOuterDiameterRecvTime = DateTime.Now;
                }
                break;

            case 3:     // 现场温度
                Temperature = dataDetail.CollectedValue;
                break;

            case 4:     // 现场湿度
                Humidity = dataDetail.CollectedValue;
                break;

            case 34:     // 计米实测值(PLC上的米数)
                Meter = dataDetail.CollectedValue;
                break;

            case 9:     // 放线张力
                Firststress = dataDetail.CollectedValue;
                break;

            case 13:     // 一段温度显示值
                Temperature1 = dataDetail.CollectedValue;
                break;

            case 15:     // 二段温度显示值
                Temperature2 = dataDetail.CollectedValue;
                break;

            case 17:     // 三段温度显示值
                Temperature3 = dataDetail.CollectedValue;
                break;

            case 19:     // 四段温度显示值
                Temperature4 = dataDetail.CollectedValue;
                break;

            case 21:     // 五段温度显示值
                Temperature5 = dataDetail.CollectedValue;
                break;

            case 23:     // 六段温度显示值
                Temperature6 = dataDetail.CollectedValue;
                break;

            case 25:     // 颈部温度显示值
                Temperature7 = dataDetail.CollectedValue;
                break;

            case 27:     // 机头温度显示值
                Temperature8 = dataDetail.CollectedValue;
                break;

            case 29:     // 眼模温度显示值
                Temperature9 = dataDetail.CollectedValue;
                break;

            case 31:     // 水槽温度显示值
                Temperature10 = dataDetail.CollectedValue;
                break;

            case 35:     // 主机电机转速
                if (dataDetail.CollectedValue >= 0 &&
                    dataDetail.CollectedValue < GlobalConstants.GlobalUpper)
                {
                    MotorVelocity = dataDetail.CollectedValue;
                }
                break;

            case 38:     // 线速度
                if (dataDetail.CollectedValue >= 0 &&
                    dataDetail.CollectedValue < GlobalConstants.GlobalUpper)
                {
                    LineVelocity = dataDetail.CollectedValue;
                }
                break;

            case 40:     // 火花检出
                SparkValue = (int)dataDetail.CollectedValue;
                break;

            case 42:     // 铜线OD(导体直径)
                InnerDiameter = dataDetail.CollectedValue;
                OnDoublePropertyChanged(42, ParseDateTime(dataDetail.CollectedTime),
                                        dataDetail.CollectedValue);
                break;

            case 800:
                SparkVoltage = dataDetail.CollectedValue;
                break;
            }
        }
Пример #4
0
 /// <summary>
 /// 添加DataDetail
 /// </summary>
 /// <param name="dataDetail"></param>
 public void AddDataDetail(DataDetail dataDetail)
 {
     lock (dataDetailLock) {
         dataDetailList.Add(dataDetail);
     }
 }