Exemple #1
0
        //刷新状态
        public void RefreshStates()
        {
            foreach (CraftModel craft in (LocalApi.GetCraftsList(new CraftListRequest())).Crafts)
            {
                string craftShortNo = CommonHelper.GetCraftShortNO(craft.CraftNO);
                StateCycle.StateCycleItem stateCycleItem = this.stateCycleItems.FirstOrDefault <StateCycle.StateCycleItem>(m => m.Name == craftShortNo);
                if (stateCycleItem != null)
                {
                    MainPage.StateCycleItemData stateCycleItemData = (MainPage.StateCycleItemData)stateCycleItem.Tag;
                    if (stateCycleItemData != null)
                    {
                        stateCycleItemData.CraftDID = craft.CraftDID;
                        stateCycleItemData.CraftNO  = craft.CraftNO;
                    }
                    stateCycleItem.State = craft.State;
                }
            }
            ProductionLineProbablyGetResponse probablyGetResponse = LocalApi.Execute(new ProductionLineProbablyGetRequest()
            {
                DID = 1
            });

            if (probablyGetResponse.ProductionLineProbably != null)
            {
                //this.lineProbably.BindData(probablyGetResponse.ProductionLineProbably);
                this.stateCycle.Setup(this.stateCycleItems);
            }
        }
        public async void RefreshStates()
        {
            foreach (ProcessModel process in (await ClientHelper.ExecuteAsync <ProcessListResponse>(new ProcessListRequest()
            {
                CraftDID = this.CraftDID
            })).Processes)
            {
                string shortNo = CommonHelper.GetProcessShortNO(process.ProcessNO);
                StateCycle.StateCycleItem stateCycleItem = this.stateCycleItems.FirstOrDefault <StateCycle.StateCycleItem>((Func <StateCycle.StateCycleItem, bool>)(m => m.Name == shortNo));
                if (stateCycleItem != null)
                {
                    stateCycleItem.State = process.State;
                    stateCycleItem.Tag   = process.ProcessDID;
                }
            }
            this.stateCycle.Setup(this.stateCycleItems);
            CraftProbablyGetResponse probablyGetResponse = await ClientHelper.ExecuteAsync <CraftProbablyGetResponse>((IRequest <CraftProbablyGetResponse>) new CraftProbablyGetRequest()
            {
                CraftDID = this.CraftDID
            });

            if (probablyGetResponse.CraftProbably != null)
            {
                this.craftProbably.BindData(probablyGetResponse.CraftProbably);
            }

            PLCStateListResponse stateListResponse = await ClientHelper.ExecuteAsync <PLCStateListResponse>((IRequest <PLCStateListResponse>) new PLCStateListRequest()
            {
                CraftDID = this.CraftDID
            });

            if (stateListResponse.PLCStates == null)
            {
                return;
            }
            this.plcList.BindData(stateListResponse.PLCStates);
        }
        public void RefreshStates()
        {
            foreach (ProcessModel process in (LocalApi.Execute(new ProcessListRequest()
            {
                CraftDID = this.CraftDID
            })).Processes)
            {
                string shortNo = CommonHelper.GetProcessShortNO(process.ProcessNO);
                StateCycle.StateCycleItem stateCycleItem = this.stateCycleItems.FirstOrDefault <StateCycle.StateCycleItem>(m => m.Name == shortNo);
                if (stateCycleItem != null)
                {
                    //设备状态
                    stateCycleItem.State = process.State;
                    stateCycleItem.Tag   = process.ProcessDID;
                }
            }
            this.stateCycle.Setup(this.stateCycleItems);

            PLCStateListResponse stateListResponse = LocalApi.Execute(new PLCStateListRequest()
            {
                CraftDID = this.CraftDID
            });

            if (stateListResponse.PLCStates == null)
            {
                return;
            }
            this.plcList.BindData(stateListResponse.PLCStates);

            AlarmCheckResponse alarmCheckResponse = LocalApi.AlarmExecute(new AlarmCheckRequest()
            {
            });
            DataProductionResponse DataProductionResponse = LocalApi.VulnerableExecute(new DataProductionRequest()
            {
            });

            Vulnerable_U = DataProductionResponse.CheckVulnerables.Select(m => m.Used).ToArray();
            Vulnerable_E = DataProductionResponse.CheckVulnerables.Select(m => m.Expect).ToArray();
            AlarmCheck   = alarmCheckResponse.AlarmCheck.Select(m => m.AlarmCheck).ToArray();
            FacilityDid  = alarmCheckResponse.AlarmCheck.Select(m => m.FacilityDid).ToArray();
            AlarmDid     = alarmCheckResponse.AlarmCheck.Select(m => m.AlarmDid).ToArray();
            for (int i = 0; i < Vulnerable_E.Length; i++)
            {
                if (Vulnerable_U[i] == Vulnerable_E[i])
                {
                    VulnerableFlag = i + 1;
                    Box(VulnerableFlag);
                }
            }
            if (AlarmFlag == 0)
            {
                if (FacilityDid[0] == "701")
                {
                    if (AlarmCheck[0] == "0x0D0D01")
                    {
                        MessageBox.Show("电芯检测批量不合格", "警告");
                        AlarmFlag = 1;
                        if (AlarmDid.Length != 0)
                        {
                            LastDid = AlarmDid[0];
                        }
                        else
                        {
                            LastDid = 0;
                        }
                    }
                }
            }
            if (AlarmDid.Length != 0)
            {
                if (AlarmDid[0] != LastDid)
                {
                    AlarmFlag = 0;
                }
            }
        }
        public void RefreshStates()
        {
            foreach (ProcessModel process in (LocalApi.Execute(new ProcessListRequest()
            {
                CraftDID = this.CraftDID
            })).Processes)
            {
                string shortNo = CommonHelper.GetProcessShortNO(process.ProcessNO);
                StateCycle.StateCycleItem stateCycleItem = this.stateCycleItems.FirstOrDefault <StateCycle.StateCycleItem>(m => m.Name == shortNo);
                if (stateCycleItem != null)
                {
                    //设备状态
                    stateCycleItem.State = process.State;
                    stateCycleItem.Tag   = process.ProcessDID;
                }
            }
            this.stateCycle.Setup(this.stateCycleItems);
            ThreadPool.QueueUserWorkItem(o =>
            {
                code = FactoryCheckDialog.EndProductNo;
                CraftProbablyGetResponse probablyGetResponse = LocalApi.Execute(new CraftProbablyGetRequest()
                {
                    CraftDID = this.CraftDID, code = this.code
                });
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(() =>
                {
                    if (probablyGetResponse.CraftProbably != null)
                    {
                        this.craftProbably.BindData(probablyGetResponse.CraftProbably);
                    }
                }));
            });

            PLCStateListResponse stateListResponse = LocalApi.Execute(new PLCStateListRequest()
            {
                CraftDID = this.CraftDID
            });

            if (stateListResponse.PLCStates == null)
            {
                return;
            }
            this.plcList.BindData(stateListResponse.PLCStates);

            AlarmCheckResponse alarmCheckResponse = LocalApi.AlarmExecute(new AlarmCheckRequest()
            {
            });
            DataProductionResponse DataProductionResponse = LocalApi.VulnerableExecute(new DataProductionRequest()
            {
            });

            Vulnerable_U = DataProductionResponse.CheckVulnerables.Select(m => m.Used).ToArray();
            Vulnerable_E = DataProductionResponse.CheckVulnerables.Select(m => m.Expect).ToArray();
            AlarmCheck   = alarmCheckResponse.AlarmCheck.Select(m => m.AlarmCheck).ToArray();
            FacilityDid  = alarmCheckResponse.AlarmCheck.Select(m => m.FacilityDid).ToArray();
            AlarmDid     = alarmCheckResponse.AlarmCheck.Select(m => m.AlarmDid).ToArray();
            for (int i = 0; i < Vulnerable_E.Length; i++)
            {
                if (Vulnerable_U[i] == Vulnerable_E[i])
                {
                    VulnerableFlag = i + 1;
                    Box(VulnerableFlag);
                }
            }
            if (AlarmFlag == 0)
            {
                if (FacilityDid[0] == "701")
                {
                    if (AlarmCheck[0] == "0x0D0D01")
                    {
                        MessageBox.Show("电芯检测批量不合格", "警告");
                        AlarmFlag = 1;
                        if (AlarmDid.Length != 0)
                        {
                            LastDid = AlarmDid[0];
                        }
                        else
                        {
                            LastDid = 0;
                        }
                    }
                }
            }
            if (AlarmDid.Length != 0)
            {
                if (AlarmDid[0] != LastDid)
                {
                    AlarmFlag = 0;
                }
            }
        }