Exemplo n.º 1
0
        private void DeviceStartTest(DeviceShortMessageLine line)
        {
            //有正在测试的器件,则需要等待
            if (NowTestDevice != null)
            {
                MessageDialog dialog = new MessageDialog("有器件正在测试,请等待......");
                dialog.ShowDialog();
            }
            //如果没有,则可以使用这个器件开始测试
            else
            {
                if (BottomPart.Unity.IsConnect())
                {
                    MessageDialog dialog = new MessageDialog(String.Format("喷油泵型号 : {0}\n是否开始测试?", line.GetEquType()), true);

                    //同意开始测试
                    if (dialog.ShowDialog().Value)
                    {
                        line.SetTesting(true);
                        NowTestDevice = line;
                        StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(line.GetID());
                        model.Id = line.GetID();

                        //注册接受事件代理
                        ITrans.UnityIns.Add_GetMeeageDel(this.RecieveData);


                        ITrans.UnityIns.SendMeesageAsync(model.ToString(), ITrans.CommandEnum.REQUIRE, (result, data, commmand) =>
                        {
                            this.Dispatcher.Invoke(new Action(() =>
                            {
                                if (result)
                                {
                                    BottomPart.Log("发送喷油泵标准测试数据成功", LogMessage.LevelEnum.Important);
                                }
                                else
                                {
                                    BottomPart.Log("发送喷油泵标准测试数据失败", LogMessage.LevelEnum.Important);
                                }
                            }));
                        });
                    }
                }
                //还未连接,则提示
                else
                {
                    MessageDialog dialog = new MessageDialog("测试台未连接,请先连接测试台");
                    dialog.ShowDialog();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 接受数据代理
        /// </summary>
        /// <param name="result"></param>
        /// <param name="data"></param>
        /// <param name="command"></param>
        private void RecieveData(bool result, String data, ITrans.CommandEnum command)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                //接受到了数据
                if (command == ITrans.CommandEnum.RESULT)
                {
                    HistoryModel model = new HistoryModel(data);

                    if (model.Id == NowTestDevice.GetID())
                    {
                        int index = -1;
                        StandardDeviceDesModel sdd = DBControler.UnityIns.GetSSDesTotalRecord(NowTestDevice.GetID());

                        //测试状态取消
                        NowTestDevice.SetTesting(false);
                        NowTestDevice = null;

                        CombinaPara(sdd, model);

                        BottomPart.Log("接受结果数据成功", LogMessage.LevelEnum.Important);

                        index    = DBControler.UnityIns.AddHistoryRecord(model);
                        model.Id = index;

                        if (index > 0)
                        {
                            BottomPart.Log("保存测试数据成功", LogMessage.LevelEnum.Important);
                            MainWindow.MWindow.AddAHistoryLine(model);
                        }
                        else
                        {
                            BottomPart.Log("保存测试数据失败", LogMessage.LevelEnum.Error);
                        }
                    }
                    else
                    {
                        BottomPart.Log("接受结果数据与当前测试数据ID不匹配", LogMessage.LevelEnum.Error);
                    }
                }
            }));
        }