示例#1
0
        /// <summary>
        /// currentJudge()内部开启的线程ThreadStart
        /// </summary>
        private void currentJudgeThreadStart()
        {
            if (!ColorimeterControlServiceImpl.threadRecvDataFlag)  // 如果线程已关闭(flag=flase),break
            {
                return;
            }

            if (!queue.IsEmpty)
            {
                // 队列中的lab
                Transporter.ParsedData currentParsedData = queue.ElementAt(queue.Count - 1);
                // 获取标准颜色值 std l a b
                getStandardColor();

                if (absColorStd == null)
                {
                    return;
                }
                csDomain.std_L  = l_star.ToString();
                csDomain.std_a  = a_star.ToString();
                csDomain.std_b  = b_star.ToString();
                spiDomain.std_L = l_star.ToString();
                spiDomain.std_a = a_star.ToString();
                spiDomain.std_b = b_star.ToString();

                /// ---------------计算deltaL deltaA deltaB deltaE------------------------///
                float deltaL_f = currentParsedData.l - l_star;
                float deltaA_f = currentParsedData.a - a_star;
                float deltaB_f = currentParsedData.b - b_star;
                // 绑定到domain
                spiDomain.deltaL = Math.Round(deltaL_f, 2).ToString();
                spiDomain.deltaA = Math.Round(deltaA_f, 2).ToString();
                spiDomain.deltaB = Math.Round(deltaB_f, 2).ToString();
                spiDomain.deltaE = Math.Round(Math.Sqrt(
                                                  Math.Pow(deltaL_f, 2) +
                                                  Math.Pow(deltaA_f, 2) +
                                                  Math.Pow(deltaB_f, 2)), 2).ToString();

                // 加入delta数据队列
                deltaDataQueue.Enqueue(new DeltaData()
                {
                    deltaL = double.Parse(spiDomain.deltaL),
                    deltaA = double.Parse(spiDomain.deltaA),
                    deltaB = double.Parse(spiDomain.deltaB),
                    deltaE = double.Parse(spiDomain.deltaE)
                });
                // 如果ERP查询到colorcode并且在本地放行标准表中有colorcode对应数据delta l a b e
                if (spiDomain.colorCode != "正在查询colorcode" && !string.IsNullOrEmpty(spiDomain.colorCode) && getDeltaAndCFlag)
                {
                    InvkeMethod(spiDomain.deltaL, spiDomain.deltaA, spiDomain.deltaB, spiDomain.deltaE, spiDomain.length);
                    insertToDB(); // 存入实时数据表,TODO 数据库汇中卷取长度间隔相邻小于1米的值只保留1个。
                    // 将检测和相关有效值写入PLC
                    //  writeEffectiveValueInPlc();
                }
            }
        }
示例#2
0
        /// <summary>
        /// 判断检测数据是否 合格,两个检测标准,同时满足。
        /// 2.根据上下位置颜色检测偏差值,判定。
        /// </summary>
        /// <returns>Δ(l,a,b,e)是否报警</returns>
        private void secondJudgeIfWarning(
            out bool secondJudgeL,
            out bool secondJudgeA,
            out bool secondJudgeB,
            out bool secondJudgeE)
        {
            // 如果当前没有位置4的值,说明第一次处于1,2,3位置,直接返回,没有第二种检测。
            if (float.IsNaN(index3_l))
            {
                secondJudgeL = secondJudgeA = secondJudgeB = secondJudgeE = true;
                return;
            }

            Transporter.ParsedData data = queue.ElementAt(queue.Count - 1);
            float height    = data.height;
            float current_l = data.l;
            float current_a = data.a;
            float current_b = data.b;
            float current_e = (float)Math.Sqrt(Math.Pow((double)current_a, 2) +
                                               Math.Pow((double)current_b, 2) + Math.Pow((double)current_l, 2));

            secondJudgeL = secondJudgeA = secondJudgeB = secondJudgeE = true; // 只是为了编译通过,后面一定会更改值

            if (height.Equals(300f))
            {
                index3_a = current_a;
                index3_b = current_b;
                index3_l = current_l;
                index3_e = (float)Math.Sqrt(Math.Pow((double)index3_a, 2) +
                                            Math.Pow((double)index3_b, 2) + Math.Pow((double)index3_l, 2));
            }
            else if (height.Equals(400f))
            {
                index4_a = current_a;
                index4_b = current_b;
                index4_l = current_l;
                index4_e = (float)Math.Sqrt(Math.Pow((double)index4_a, 2) +
                                            Math.Pow((double)index4_b, 2) + Math.Pow((double)index4_l, 2));
            }
            if (height.Equals(300f) || height.Equals(200f) || height.Equals(100f))
            {
                secondJudgeL = Math.Abs((decimal)(current_l - index3_l)) - Math.Abs(csDomain.deltaL_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeA = Math.Abs((decimal)(current_a - index3_a)) - Math.Abs(csDomain.deltaA_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeB = Math.Abs((decimal)(current_b - index3_b)) - Math.Abs(csDomain.deltaB_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeE = Math.Abs((decimal)(current_e - index3_e)) - Math.Abs(csDomain.deltaE_std.ToDecimal()) >= 0 ? true : false;
            }
            else if (height.Equals(600f) || height.Equals(500f) || height.Equals(400f))
            {
                secondJudgeL = Math.Abs((decimal)(current_l - index4_l)) - Math.Abs(csDomain.deltaL_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeA = Math.Abs((decimal)(current_a - index4_a)) - Math.Abs(csDomain.deltaA_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeB = Math.Abs((decimal)(current_b - index4_b)) - Math.Abs(csDomain.deltaB_std.ToDecimal()) >= 0 ? true : false;
                secondJudgeE = Math.Abs((decimal)(current_e - index4_e)) - Math.Abs(csDomain.deltaE_std.ToDecimal()) >= 0 ? true : false;
            }
        }