Exemple #1
0
        public StateMonitorPageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            string jsonBaseInfo;

            using (StreamReader sr = new StreamReader(@"baseinfo.cfg", true))
            {
                jsonBaseInfo = sr.ReadToEnd();
            }

            var _baseInfo = JsonConvert.DeserializeObject <BaseInfo>(jsonBaseInfo);
            var fifo      = _baseInfo.SciChartXTimeMax;

            PosSeries = new XyDataSeries <double, double>();
            PosSeries.FifoCapacity   = fifo;
            SpeedSeries              = new XyDataSeries <double, double>();
            SpeedSeries.FifoCapacity = fifo;
            TemSeries = new XyDataSeries <double, double>();
            TemSeries.FifoCapacity   = fifo;
            PressSeries              = new XyDataSeries <double, double>();
            PressSeries.FifoCapacity = fifo;

            LoadedCommand    = new RelayCommand(OnLoaded);
            UnloadedCommand  = new RelayCommand(OnUnloaded);
            StartSciChartCmd = new RelayCommand(OnStartSciChart);
            StopSciChartCmd  = new RelayCommand(OnStopSciChart);

            Messenger.Default.Register <StateMonitorInfo>(this, "StateMonitorInfoMsg", msg =>
            {
                StateMonitorInfo = _mapper.Map <StateMonitorInfo, StateMonitorInfoDto>(msg);
            });

            Messenger.Default.Register <StateMonitorLineChartData>(this, "StateMonitorLineChartDataMsg", OnData);
        }
        public ParaSubCamPageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            LoadedCommand    = new RelayCommand(OnLoaded);
            UnloadedCommand  = new RelayCommand(OnUnloaded);
            StartPos_1SetCmd = new RelayCommand(OnStartPos_1Set);
            StartPos_2SetCmd = new RelayCommand(OnStartPos_2Set);
            StartPos_3SetCmd = new RelayCommand(OnStartPos_3Set);
            StartPos_4SetCmd = new RelayCommand(OnStartPos_4Set);
            EndPos_1SetCmd   = new RelayCommand(OnEndPos_1Set);
            EndPos_2SetCmd   = new RelayCommand(OnEndPos_2Set);
            EndPos_3SetCmd   = new RelayCommand(OnEndPos_3Set);
            EndPos_4SetCmd   = new RelayCommand(OnEndPos_4Set);

            StartArr_1SetCmd = new RelayCommand(OnStartArr_1Set);
            StartArr_2SetCmd = new RelayCommand(OnStartArr_2Set);
            StartArr_3SetCmd = new RelayCommand(OnStartArr_3Set);
            StartArr_4SetCmd = new RelayCommand(OnStartArr_4Set);
            EndArr_1SetCmd   = new RelayCommand(OnEndArr_1Set);
            EndArr_2SetCmd   = new RelayCommand(OnEndArr_2Set);
            EndArr_3SetCmd   = new RelayCommand(OnEndArr_3Set);
            EndArr_4SetCmd   = new RelayCommand(OnEndArr_4Set);

            Enable_1SetCmd = new RelayCommand(OnEnable_1Set);
            Enable_2SetCmd = new RelayCommand(OnEnable_2Set);
            Enable_3SetCmd = new RelayCommand(OnEnable_3Set);
            Enable_4SetCmd = new RelayCommand(OnEnable_4Set);


            Messenger.Default.Register <ParaCamInfo>(this, "ParaCamInfoMsg", msg =>
            {
                ParaCamInfo = _mapper.Map <ParaCamInfo, ParaCamInfoDto>(msg);
            });
        }
        public SParaSubMachinePageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            LoadedCommand   = new RelayCommand(OnLoaded);
            UnloadedCommand = new RelayCommand(OnUnloaded);

            MaxWeightSetCmd               = new RelayCommand(OnMaxWeightSetCmd);
            MaxTemperatureSetCmd          = new RelayCommand(OnMaxTemperatureSetCmd);
            MaxErrorSetCmd                = new RelayCommand(OnMaxErrorSetCmd);
            PressureSensorParaSetCmd      = new RelayCommand(OnPressureSensorParaSetCmd);
            BalanceCylinderAnalogSetCmd   = new RelayCommand(OnBalanceCylinderAnalogSetCmd);
            BalanceCylinderPressureSetCmd = new RelayCommand(OnBalanceCylinderPressureSetCmd);
            OverflowDelaySetCmd           = new RelayCommand(OnOverflowDelaySetCmd);
            PressureDiffParaSetCmd        = new RelayCommand(OnPressureDiffParaSetCmd);
            PressureLowAlarmSetCmd        = new RelayCommand(OnPressureLowAlarmSetCmd);
            LubricateDetectSetCmd         = new RelayCommand(OnLubricateDetectSetCmd);

            Messenger.Default.Register <SParaMachineInfo>(this, "SParaMachineInfoMsg", msg =>
            {
                SParaMachineInfo = _mapper.Map <SParaMachineInfo, SParaMachineInfoDto>(msg);
            });
        }
Exemple #4
0
        public SParaSubLubricatePageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            LoadedCommand   = new RelayCommand(OnLoaded);
            UnloadedCommand = new RelayCommand(OnUnloaded);

            CR_LubricateTimeSetCmd = new RelayCommand(OnCR_LubricateTimeSetCmd);

            CR_SetLubricateIntervalSetCmd = new RelayCommand(OnCR_SetLubricateIntervalSetCmd);

            CR_ActualLubricateIntervalSetCmd = new RelayCommand(OnCR_ActualLubricateIntervalSetCmd);

            CR_LubricateDetectTimeSetCmd = new RelayCommand(OnCR_LubricateDetectTimeSetCmd);

            CR_LubricateTotalNumSetCmd = new RelayCommand(OnCR_LubricateTotalNumSetCmd);

            CR_PowerOnLubricateTimeSetCmd = new RelayCommand(OnCR_PowerOnLubricateTimeSetCmd);

            CR_LubricateDetecteSetCmd = new RelayCommand(OnCR_LubricateDetecteSetCmd);

            AC_LubricateTimeSetCmd = new RelayCommand(OnAC_LubricateTimeSetCmd);

            AC_SetLubricateIntervalSetCmd = new RelayCommand(OnAC_SetLubricateIntervalSetCmd);

            AC_ActualLubricateIntervalSetCmd = new RelayCommand(OnAC_ActualLubricateIntervalSetCmd);

            AC_LubricateDetectTimeSetCmd = new RelayCommand(OnAC_LubricateDetectTimeSetCmd);

            AC_LubricateTotalNumSetCmd = new RelayCommand(OnAC_LubricateTotalNumSetCmd);

            AC_PowerOnLubricateTimeSetCmd = new RelayCommand(OnAC_PowerOnLubricateTimeSetCmd);

            AC_LubricateDetecteSetCmd = new RelayCommand(OnAC_LubricateDetecteSetCmd);

            AC2_LubricateTimeSetCmd = new RelayCommand(OnAC2_LubricateTimeSetCmd);

            AC2_SetLubricateIntervalSetCmd = new RelayCommand(OnAC2_SetLubricateIntervalSetCmd);

            AC2_ActualLubricateIntervalSetCmd = new RelayCommand(OnAC2_ActualLubricateIntervalSetCmd);

            AC2_LubricateDetectTimeSetCmd = new RelayCommand(OnAC2_LubricateDetectTimeSetCmd);

            AC2_LubricateTotalNumSetCmd = new RelayCommand(OnAC2_LubricateTotalNumSetCmd);

            AC2_PowerOnLubricateTimeSetCmd = new RelayCommand(OnAC2_PowerOnLubricateTimeSetCmd);

            AC2_LubricateDetecteSetCmd = new RelayCommand(OnAC2_LubricateDetecteSetCmd);

            GR_LubricateReversingSetCmd = new RelayCommand(OnGR_LubricateReversingSetCmd);

            GR_LubricateDetectTimeSetCmd = new RelayCommand(OnGR_LubricateDetectTimeSetCmd);

            SC_LubricateReversingSetCmd = new RelayCommand(OnSC_LubricateReversingSetCmd);

            OS_TimeSetCmd = new RelayCommand(OnOS_TimeSetCmd);

            OS_IntervalTimeSetCmd = new RelayCommand(OnOS_IntervalTimeSetCmd);

            OS_DelayTimeSetCmd = new RelayCommand(OnOS_DelayTimeSetCmd);

            TS_DelayTimeSetCmd = new RelayCommand(OnTS_DelayTimeSetCmd);

            TS_StopTimeSetCmd = new RelayCommand(OnTS_StopTimeSetCmd);

            TS_RunTimeSetCmd = new RelayCommand(OnTS_RunTimeSetCmd);

            Messenger.Default.Register <SParaLubricateInfo>(this, "SParaLubricateInfoMsg", msg =>
            {
                SParaLubricateInfo = _mapper.Map <SParaLubricateInfo, SParaLubricateInfoDto>(msg);
            });
        }
        public ParaSubProcManagementPageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            LoadedCommand             = new RelayCommand(OnLoaded);
            UnloadedCommand           = new RelayCommand(OnUnloaded);
            RefreshFileCommand        = new RelayCommand(OnRefreshFile);
            SaveToPcCommand           = new RelayCommand(OnSaveToPc);
            LoadAndShowCommand        = new RelayCommand(OnLoadAndShow);
            SaveAndApplicationCommand = new RelayCommand(OnSaveAndApplication);
            FileFolderCommand         = new RelayCommand(OnFileFolder);

            GetProcFiles(CurFileFolder);

            Messenger.Default.Register <RecipesInfo>(this, "ParaRecipesInfoMsg2", msg =>
            {
                foreach (var info in msg.PmcBoms)
                {
                    var rec = RecipesInfos.Where(x => x.Id == info.Id && x.PmcType == true).FirstOrDefault();

                    if (rec == null)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            RecipesInfos.Add(new RecipesInfoItemDto()
                            {
                                Id         = info.Id,
                                PmcType    = true,
                                Name       = info.Name,
                                PmcBomItem = new PmcBomItemRecipesDto()
                                {
                                    Id               = info.Id,
                                    Adr              = info.Adr,
                                    AdrType          = info.AdrType,
                                    Bit              = info.Bit,
                                    ConversionFactor = info.ConversionFactor,
                                    DataType         = info.DataType,
                                    IsRecipes        = info.IsRecipes,
                                    Value            = info.Value
                                }
                            });
                        });
                    }
                    else
                    {
                        rec.Value = info.Value;

                        if (rec.Value != null && rec.FileValue != null)
                        {
                            double v1, v2;
                            var ret_v1 = double.TryParse(rec.Value, out v1);
                            var ret_v2 = double.TryParse(rec.FileValue, out v2);

                            if (ret_v1 == false || ret_v2 == false)
                            {
                                bool v3, v4;
                                var ret_v3 = bool.TryParse(rec.Value, out v3);
                                var ret_v4 = bool.TryParse(rec.FileValue, out v4);

                                if (ret_v3 == true && ret_v4 == true)
                                {
                                    if (v3 == v4)
                                    {
                                        rec.UpDown = 0;
                                    }
                                }
                            }
                            else
                            {
                                rec.UpDown = v1 - v2;
                            }
                        }
                        else
                        {
                            rec.UpDown = null;
                        }
                    }
                }

                foreach (var info in msg.MacroBoms)
                {
                    var rec = RecipesInfos.Where(x => x.Id == info.Id && x.MacroType == true).FirstOrDefault();

                    if (rec == null)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            RecipesInfos.Add(new RecipesInfoItemDto()
                            {
                                Id           = info.Id,
                                Name         = info.Name,
                                MacroType    = true,
                                MacroBomItem = new MacroBomItemRecipesDto()
                                {
                                    Id        = info.Id,
                                    Adr       = info.Adr,
                                    IsRecipes = info.IsRecipes,
                                    Value     = info.Value
                                }
                            });
                        });
                    }
                    else
                    {
                        rec.Value = info.Value;

                        if (rec.Value != null && rec.FileValue != null)
                        {
                            double v1, v2;
                            var ret_v1 = double.TryParse(rec.Value, out v1);
                            var ret_v2 = double.TryParse(rec.FileValue, out v2);

                            if (ret_v1 == false || ret_v2 == false)
                            {
                                bool v3, v4;
                                var ret_v3 = bool.TryParse(rec.Value, out v3);
                                var ret_v4 = bool.TryParse(rec.FileValue, out v4);

                                if (ret_v3 == true && ret_v4 == true)
                                {
                                    if (v3 == v4)
                                    {
                                        rec.UpDown = 0;
                                    }
                                }
                            }
                            else
                            {
                                rec.UpDown = v1 - v2;
                            }
                        }
                        else
                        {
                            rec.UpDown = null;
                        }
                    }
                }

                foreach (var info in RecipesInfos.Where(x => x.PmcType == true))
                {
                    if (msg.PmcBoms.Where(x => x.Id == info.Id).Count() == 0)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            RecipesInfos.Remove(info);
                        });
                    }
                }

                foreach (var info in RecipesInfos.Where(x => x.MacroType == true))
                {
                    if (msg.MacroBoms.Where(x => x.Id == info.Id).Count() == 0)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            RecipesInfos.Remove(info);
                        });
                    }
                }
            });
        }
        public ParaSubDiePartingPageViewModel(IMapper mapper, Fanuc fanuc)
        {
            _fanuc  = fanuc;
            _mapper = mapper;

            LoadedCommand    = new RelayCommand(OnLoaded);
            UnloadedCommand  = new RelayCommand(OnUnloaded);
            StartSciChartCmd = new RelayCommand(OnStartSciChart);

            SectionNumSetCmd          = new RelayCommand(OnSectionNumSet);
            BottomDeadCentreSetCmd    = new RelayCommand(OnBottomDeadCentreSet);
            Speed_TopDeadCentreSetCmd = new RelayCommand(OnSpeed_TopDeadCentreSet);
            TopDeadCentreSetCmd       = new RelayCommand(OnTopDeadCentreSet);

            Pos_1SetCmd = new RelayCommand(OnPos_1Set);
            Pos_2SetCmd = new RelayCommand(OnPos_2Set);
            Pos_3SetCmd = new RelayCommand(OnPos_3Set);
            Pos_4SetCmd = new RelayCommand(OnPos_4Set);
            Pos_5SetCmd = new RelayCommand(OnPos_5Set);
            Pos_6SetCmd = new RelayCommand(OnPos_6Set);
            Pos_7SetCmd = new RelayCommand(OnPos_7Set);
            Pos_8SetCmd = new RelayCommand(OnPos_8Set);

            Speed_1SetCmd = new RelayCommand(OnSpeed_1Set);
            Speed_2SetCmd = new RelayCommand(OnSpeed_2Set);
            Speed_3SetCmd = new RelayCommand(OnSpeed_3Set);
            Speed_4SetCmd = new RelayCommand(OnSpeed_4Set);
            Speed_5SetCmd = new RelayCommand(OnSpeed_5Set);
            Speed_6SetCmd = new RelayCommand(OnSpeed_6Set);
            Speed_7SetCmd = new RelayCommand(OnSpeed_7Set);
            Speed_8SetCmd = new RelayCommand(OnSpeed_8Set);

            BottomDeadCentreSetCmd = new RelayCommand(OnBottomDeadCentreSet);

            for (int i = 0; i < 8; i++)
            {
                ParaDiePartingProcInfoEnables.Add(false);
            }


            Messenger.Default.Register <ParaDiePartingInfo>(this, "ParaDiePartingInfoMsg", msg =>
            {
                ParaDiePartingInfo = _mapper.Map <ParaDiePartingInfo, ParaDiePartingInfoDto>(msg);
            });

            Messenger.Default.Register <ParaDiePartingProcInfo>(this, "ParaDiePartingProcInfoMsg", msg =>
            {
                ParaDiePartingProcInfo = _mapper.Map <ParaDiePartingProcInfo, ParaDiePartingProcInfoDto>(msg);

                for (int i = 0; i < 8; i++)
                {
                    if (i < ParaDiePartingProcInfo.SectionNum)
                    {
                        ParaDiePartingProcInfoEnables[i] = true;
                    }
                    else
                    {
                        ParaDiePartingProcInfoEnables[i] = false;
                    }
                }
            });


            string jsonBaseInfo;

            using (StreamReader sr = new StreamReader(@"baseinfo.cfg", true))
            {
                jsonBaseInfo = sr.ReadToEnd();
            }
            var _baseInfo = JsonConvert.DeserializeObject <BaseInfo>(jsonBaseInfo);
            var fifo      = _baseInfo.SciChartXTimeMax;

            PosSeries = new XyDataSeries <double, double>();
            PosSeries.FifoCapacity   = fifo;
            SpeedSeries              = new XyDataSeries <double, double>();
            SpeedSeries.FifoCapacity = fifo;

            Messenger.Default.Register <StateMonitorLineChartData>(this, "SimulateLineChartDataMsg", OnData);
        }
Exemple #7
0
        public MOPViewModel(IMapper mapper, Fanuc fanuc)
        {
            this._fanuc  = fanuc;
            this._mapper = mapper;

            LoadPageCommand   = new RelayCommand(ON_LoadPageCommand);
            UnLoadPageCommand = new RelayCommand(ON_UnLoadPageCommand);

            CNC_SYSTEM_CMD   = new RelayCommand(ON_CNC_SYSTEM_CMD);
            CNC_MESSAGE_CMD  = new RelayCommand(ON_CNC_MESSAGE_CMD);
            CNC_GRAPH_CMD    = new RelayCommand(ON_CNC_GRAPH_CMD);
            CNC_POSITION_CMD = new RelayCommand(ON_CNC_POSITION_CMD);
            CNC_PROGRAM_CMD  = new RelayCommand(ON_CNC_PROGRAM_CMD);
            CNC_OFFSET_CMD   = new RelayCommand(ON_CNC_OFFSET_CMD);
            CNC_RAM_CMD      = new RelayCommand(ON_CNC_RAM_CMD);


            MOP_AUTO_CMD                  = new RelayCommand(ON_MOP_AUTO_CMD);
            MOP_EDIT_CMD                  = new RelayCommand(ON_MOP_EDIT_CMD);
            MOP_MDI_CMD                   = new RelayCommand(ON_MOP_MDI_CMD);
            MOP_RMT_CMD                   = new RelayCommand(ON_MOP_RMT_CMD);
            MOP_RTN_CMD                   = new RelayCommand(ON_MOP_RTN_CMD);
            MOP_JOG_CMD                   = new RelayCommand(ON_MOP_JOG_CMD);
            MOP_HANDLE_CMD                = new RelayCommand(ON_MOP_HANDLE_CMD);
            MOP_STEP_CMD                  = new RelayCommand(ON_MOP_STEP_CMD);
            MOP_SKIP_CMD                  = new RelayCommand(ON_MOP_SKIP_CMD);
            MOP_OPT_CMD                   = new RelayCommand(ON_MOP_OPT_CMD);
            MOP_DRY_CMD                   = new RelayCommand(ON_MOP_DRY_CMD);
            MOP_AUTOSTART_CMD             = new RelayCommand(ON_MOP_AUTOSTART_CMD);
            MOP_STORAGESTOP_CMD           = new RelayCommand(ON_MOP_STORAGESTOP_CMD);
            MOP_ROLLBACK_CMD              = new RelayCommand(ON_MOP_ROLLBACK_CMD);
            MOP_PIERCINGDELAY_CMD         = new RelayCommand(ON_MOP_PIERCINGDELAY_CMD);
            MOP_PIERCINGSHORTEN_CMD       = new RelayCommand(ON_MOP_PIERCINGSHORTEN_CMD);
            MOP_DUSTCLEAR_CMD             = new RelayCommand(ON_MOP_DUSTCLEAR_CMD);
            MOP_LAMPON_CMD                = new RelayCommand(ON_MOP_LAMPON_CMD);
            MOP_FOLLOWON_CMD              = new RelayCommand(ON_MOP_FOLLOWON_CMD);
            MOP_FOLLOWLOCK_CMD            = new RelayCommand(ON_MOP_FOLLOWLOCK_CMD);
            MOP_RAPIDOV0_CMD              = new RelayCommand(ON_MOP_RAPIDOV0_CMD);
            MOP_RAPIDOV25_CMD             = new RelayCommand(ON_MOP_RAPIDOV25_CMD);
            MOP_RAPIDOV50_CMD             = new RelayCommand(ON_MOP_RAPIDOV50_CMD);
            MOP_RAPIDOV100_CMD            = new RelayCommand(ON_MOP_RAPIDOV100_CMD);
            MOP_HANDLEOV1_CMD             = new RelayCommand(ON_MOP_HANDLEOV1_CMD);
            MOP_HANDLEOV10_CMD            = new RelayCommand(ON_MOP_HANDLEOV10_CMD);
            MOP_HANDLEOV100_CMD           = new RelayCommand(ON_MOP_HANDLEOV100_CMD);
            MOP_HANDLEOV1000_CMD          = new RelayCommand(ON_MOP_HANDLEOV1000_CMD);
            MOP_AXIS_X_CMD                = new RelayCommand(ON_MOP_AXIS_X_CMD);
            MOP_AXIS_Y_CMD                = new RelayCommand(ON_MOP_AXIS_Y_CMD);
            MOP_AXIS_Z_CMD                = new RelayCommand(ON_MOP_AXIS_Z_CMD);
            MOP_AXIS_4_CMD                = new RelayCommand(ON_MOP_AXIS_4_CMD);
            MOP_MANUAL_PLUS_CMD           = new RelayCommand(ON_MOP_MANUAL_PLUS_CMD);
            MOP_MANUAL_RAPID_CMD          = new RelayCommand(ON_MOP_MANUAL_RAPID_CMD);
            MOP_MANUAL_SUBTRACT_CMD       = new RelayCommand(ON_MOP_MANUAL_SUBTRACT_CMD);
            MOP_AUX_G_SUBTRACT_CMD        = new RelayCommand(ON_MOP_AUX_G_SUBTRACT_CMD);
            MOP_AUX_G_PLUS_CMD            = new RelayCommand(ON_MOP_AUX_G_PLUS_CMD);
            MOP_JOG_OVERRIDE_SUBTRACT_CMD = new RelayCommand(ON_MOP_JOG_OVERRIDE_SUBTRACT_CMD);
            MOP_JOG_OVERRIDE_PLUS_CMD     = new RelayCommand(ON_MOP_JOG_OVERRIDE_PLUS_CMD);
            MOP_LASER_POWER_SUBTRACT_CMD  = new RelayCommand(ON_MOP_LASER_POWER_SUBTRACT_CMD);
            MOP_LASER_POWER_PLUS_CMD      = new RelayCommand(ON_MOP_LASER_POWER_PLUS_CMD);
            MOP_LASER_FREQ_SUBTRACT_CMD   = new RelayCommand(ON_MOP_LASER_FREQ_SUBTRACT_CMD);
            MOP_LASER_FREQ_PLUS_CMD       = new RelayCommand(ON_MOP_LASER_FREQ_PLUS_CMD);
            MOP_LASER_DUTY_SUBTRACT_CMD   = new RelayCommand(ON_MOP_LASER_DUTY_SUBTRACT_CMD);
            MOP_LASER_DUTY_PLUS_CMD       = new RelayCommand(ON_MOP_LASER_DUTY_PLUS_CMD);

            Messenger.Default.Register <MopKeyStatus>(this, "MopKeyStatusMsg", OnRefreshKeyStatus);
        }
Exemple #8
0
        public MainViewModel(IMapper mapper, Fanuc fanuc, User user)
        {
            this._user             = user;
            this._fanuc            = fanuc;
            this._mapper           = mapper;
            LoginCommand           = new RelayCommand(OnLogin);
            LoginStatus            = "Visible";
            CloseCommand           = new RelayCommand(OnClose);
            MiniCommand            = new RelayCommand(OnMini);
            MaxCommand             = new RelayCommand(OnMax);
            ShowAlarmDialogCmd     = new RelayCommand(OnShowAlarmDialog);
            ShowOpMessageDialogCmd = new RelayCommand(OnShowOpMessageDialog);
            ReLoadingCommand       = new RelayCommand(OnReLoading);

            SafeNetLimitVisible = "Hidden";
            _LoadVisibility     = "Visible";

            _homeCmd       = new RelayCommand(OnHomeClick);
            _machiningCmd  = new RelayCommand(OnMachiningClick);
            _simulationCmd = new RelayCommand(OnSimulationClick);
            _machineCmd    = new RelayCommand(OnMachineClick);
            _diagnoseCmd   = new RelayCommand(OnDiagnoseClick);
            _ioCmd         = new RelayCommand(OnIOClick);
            _maintainCmd   = new RelayCommand(OnMaintainClick);
            _custom1Cmd    = new RelayCommand(OnCustom1Click);
            _custom2Cmd    = new RelayCommand(OnCustom2Click);

            System.Timers.Timer timerB = new System.Timers.Timer();//刷新时间
            timerB.Interval = System.Convert.ToDouble(500);
            timerB.Elapsed += new System.Timers.ElapsedEventHandler(RefreshTime);
            timerB.Enabled  = true;

            System.Timers.Timer timerP = new System.Timers.Timer();//获得诚信管理信息
            timerP.Interval = System.Convert.ToDouble(10000);
            timerP.Elapsed += new System.Timers.ElapsedEventHandler(SafeNet);
            timerP.Enabled  = true;

            Messenger.Default.Register <string>(this, "ReloadMsg", msg =>
            {
                _Content    = null;
                LoginStatus = "Visible";
            });

            //刷新操作信息
            timerN.Interval  = System.Convert.ToDouble(5000);
            timerN.Elapsed  += new System.Timers.ElapsedEventHandler(RefreshOperateNotice);
            timerN.Enabled   = true;
            timerN.AutoReset = false;

            Messenger.Default.Register <string>(this, "OperateNotice", msg =>
            {
                timerN.Stop();
                _DisNotice = msg;
                timerN.Start();
            });

            //注册消息
            Messenger.Default.Register <CncStateInfo>(this, "CncStateMsg", msg =>
            {
                CncStateInfo = _mapper.Map <CncStateInfo, CncStateInfoDto>(msg);

                if (CncStateInfo.ProgramNum == "O9015")
                {
                    CncStateInfo.ProgramNum = "自动对中";
                }
                if (CncStateInfo.ProgramNum == "O9016")
                {
                    CncStateInfo.ProgramNum = "自动清洁";
                }
                if (CncStateInfo.ProgramNum == "O9017")
                {
                    CncStateInfo.ProgramNum = "自动寻边";
                }
                if (CncStateInfo.ProgramNum == "O9018")
                {
                    CncStateInfo.ProgramNum = "手动寻边测试";
                }

                //报警信息转换
                var al_timespan = (DateTime.Now - _lastAlarmUpdataTime).TotalSeconds;
                if (al_timespan > 3)
                {
                    if (CncStateInfo.CncAlarmList.Count == 0)
                    {
                        _DisAlarm = "";
                    }
                    else
                    {
                        try
                        {
                            string[] alm_type = { "SW", "PW", "IO", "PS", "OT", "OH", "SV", "SR", "MC", "SP", "DS", "IE", "BG", "SN", "", "EX", "", "", "", "PC" };
                            string[] alm_axis = { "", "(X)", "(Y)", "(Z)" };
                            if (_curAlarmIndex >= CncStateInfo.CncAlarmList.Count)
                            {
                                _curAlarmIndex = 0;
                            }
                            _DisAlarm = alm_type[CncStateInfo.CncAlarmList[_curAlarmIndex].Type] +
                                        CncStateInfo.CncAlarmList[_curAlarmIndex].Alm_No.ToString("0000") +
                                        @" " + CncStateInfo.CncAlarmList[_curAlarmIndex].Alm_Msg;


                            _curAlarmIndex++;
                        }
                        catch { }
                    }
                    _lastAlarmUpdataTime = DateTime.Now;
                }


                //操作信息转换
                var op_timespan = (DateTime.Now - _lastMessageUpdataTime).TotalSeconds;
                if (op_timespan > 3)
                {
                    if (CncStateInfo.CncMessageList.Count == 0)
                    {
                        _DisMessage = "";
                    }
                    else
                    {
                        try
                        {
                            if (_curMessageIndex >= CncStateInfo.CncMessageList.Count)
                            {
                                _curMessageIndex = 0;
                            }
                            _DisMessage =
                                CncStateInfo.CncMessageList[_curMessageIndex].Msg_No.ToString("0000") +
                                @" " + CncStateInfo.CncMessageList[_curMessageIndex].Alm_Msg;
                            _curMessageIndex++;
                        }
                        catch { }
                    }

                    _lastMessageUpdataTime = DateTime.Now;
                }
            });

            Messenger.Default.Register <string>(this, "SoftwareLimitMsgBySafeNet", msg =>
            {
                SafeNetLimitVisible = "Visible";
                SafeNetLimitMessage = msg;
            });

            Messenger.Default.Register <string>(this, "SoftwareNoLimitMsgBySafeNet", msg =>
            {
                SafeNetLimitVisible = "Hidden";
            });

            Messenger.Default.Register <string>(this, "SoftwareLimitNearMsgBySafeNet", msg =>
            {
                Messenger.Default.Send <string>(msg, "OperateNotice");
            });


            _LoadingMessage       = "系统连接加载中,请稍候";
            _ReLoadConnVisibility = "Hidden";
            timerL.Interval       = System.Convert.ToDouble(1000);
            timerL.Elapsed       += new System.Timers.ElapsedEventHandler(OnLoad);
            timerL.Enabled        = true;
            timerL.AutoReset      = false;
        }
 public SystemMacroViewModel(Fanuc fanuc)
 {
     MacroNodes = new List <SystemMacroItemViewModel>();
     this.fanuc = fanuc;
     this.LoadData();
 }
 public SystemPmcViewModel(Fanuc fanuc)
 {
     this.fanuc = fanuc;
     PmcNodes   = new List <SystemPmcItemViewModel>();
     LoadData();
 }
Exemple #11
0
        public MachiningViewModel(Fanuc fanuc, MachiningLibService mchiningSrv, IMapper mapper)
        {
            _fanuc        = fanuc;
            _mapper       = mapper;
            m_mchiningSrv = mchiningSrv;

            _UploadEnable = true;
            _SearchEnable = true;

            LoadPageCommand   = new RelayCommand(ON_LoadPageCommand);
            UnLoadPageCommand = new RelayCommand(ON_UnLoadPageCommand);
            AddMatrialCommand = new RelayCommand(OnAddMatrialCommand);
            DelMatrialCommand = new RelayCommand(OnDelMatrialCommand);


            //初始化分页viewmodel
            SimpleIoc.Default.GetInstance <MachiningLibCutDataGridViewModel>();
            SimpleIoc.Default.GetInstance <MachiningLibEdgeCuttingDataGridViewModel>();
            SimpleIoc.Default.GetInstance <MachiningLibPiercingDataGridViewModel>();
            SimpleIoc.Default.GetInstance <MachiningLibSlopeControlDataGridViewModel>();

            _MachiningCutCmd          = new RelayCommand(OnMachiningCutClick);
            _MachiningHoleCmd         = new RelayCommand(OnMachiningHoleClick);
            _MachiningCornerCmd       = new RelayCommand(OnMachiningCornerClick);
            _MachiningStartCmd        = new RelayCommand(OnMachiningStartClick);
            _MachiningPowerCmd        = new RelayCommand(OnMachiningPowerClick);
            _MachiningLibLoadingCmd   = new RelayCommand(OnMachiningLibLoadingClick);
            _SendToCncCmd             = new RelayCommand(OnMachiningLibSendToCncClick);
            _Material_Changed_Command = new RelayCommand(OnMaterialChangedCmd);


            _MachiningLib_Content = new MachiningLibCutDataGrid();
            ChangeMachiningLibMenuButtonCheckedStatus(btn1: true);

            var config = new ConfigHelper();

            config.GetMachiningConfigurationInfo(out laserType, out cutterType, out opticalType);

            //TODO:加载材料、厚度的选项
            //TODO:根据系统宏变量查找当前选中的材料和厚度
            ReloadMaterialAndThickness();

            //TODO:读取NC的库至PC显示
            GetDataAndMessageToShow();

            Messenger.Default.Register <MachiningLib_CuttingDto>(this, "MachiningLibCutDataSave", msg =>
            {
                var cut = cuttingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (cut != null)
                {
                    cut = msg;
                }

                var cutting = _mapper.Map <MachiningLib_CuttingDto, MachiningLib_Cutting>(msg);
                var ret     = m_mchiningSrv.UpdateMachiningLibCuttingRecord(cutting);
                if (ret == false)
                {
                    Messenger.Default.Send <string>("保存至数据库失败", "OperateNotice");
                }
                else
                {
                    Messenger.Default.Send <string>("保存至数据库成功", "OperateNotice");
                }
            });

            Messenger.Default.Register <MachiningLib_CuttingDto>(this, "MachiningLibCutDataApplicate", msg =>
            {
                var cut = cuttingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (cut != null)
                {
                    cut = msg;
                }
            });

            Messenger.Default.Register <MachiningLib_EdgeCuttingDto>(this, "MachiningLibEdgeCuttingDataSave", msg =>
            {
                var ecut = edgeCuttingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (ecut != null)
                {
                    ecut = msg;
                }

                var edgeCutting = _mapper.Map <MachiningLib_EdgeCuttingDto, MachiningLib_EdgeCutting>(msg);
                var ret         = m_mchiningSrv.UpdateMachiningLibEdgeCuttingRecord(edgeCutting);
                if (ret == false)
                {
                    Messenger.Default.Send <string>("保存至数据库失败", "OperateNotice");
                }
                else
                {
                    Messenger.Default.Send <string>("保存至数据库成功", "OperateNotice");
                }
            });

            Messenger.Default.Register <MachiningLib_EdgeCuttingDto>(this, "MachiningLibEdgeCuttingDataApplicate", msg =>
            {
                var ecut = edgeCuttingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (ecut != null)
                {
                    ecut = msg;
                }
            });

            Messenger.Default.Register <MachiningLib_PiercingDto>(this, "MachiningLibPiercingDataSave", msg =>
            {
                var pcut = piercingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (pcut != null)
                {
                    pcut = msg;
                }

                var piercing = _mapper.Map <MachiningLib_PiercingDto, MachiningLib_Piercing>(msg);
                var ret      = m_mchiningSrv.UpdateMachiningLibPiercingRecord(piercing);
                if (ret == false)
                {
                    Messenger.Default.Send <string>("保存至数据库失败", "OperateNotice");
                }
                else
                {
                    Messenger.Default.Send <string>("保存至数据库成功", "OperateNotice");
                }
            });

            Messenger.Default.Register <MachiningLib_PiercingDto>(this, "MachiningLibPiercingDataApplicate", msg =>
            {
                var pcut = piercingDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (pcut != null)
                {
                    pcut = msg;
                }
            });

            Messenger.Default.Register <MachiningLib_SlopeControlDto>(this, "MachiningLibSlopeControlDataSave", msg =>
            {
                var sc = slopeControlDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (sc != null)
                {
                    sc = msg;
                }

                var slopeControl = _mapper.Map <MachiningLib_SlopeControlDto, MachiningLib_SlopeControl>(msg);
                var ret          = m_mchiningSrv.UpdateMachiningLibSlopeControlRecord(slopeControl);
                if (ret == false)
                {
                    Messenger.Default.Send <string>("保存至数据库失败", "OperateNotice");
                }
                else
                {
                    Messenger.Default.Send <string>("保存至数据库成功", "OperateNotice");
                }
            });

            Messenger.Default.Register <MachiningLib_SlopeControlDto>(this, "MachiningLibSlopeControlDataApplicate", msg =>
            {
                var sc = slopeControlDtos.Where(x => x.Id == msg.Id).FirstOrDefault();
                if (sc != null)
                {
                    sc = msg;
                }
            });
        }
 public MaintainSubLimitPageViewModel(Fanuc fanuc)
 {
     this.fanuc = fanuc;
     LoadData();
 }
        public MainWindowViewModel(IMapper mapper, Fanuc fanuc, Role role)
        {
            _fanuc  = fanuc;
            _mapper = mapper;
            _role   = role;

            InitialMainMenu();
            OnMainMenu1Click();

            System.Timers.Timer timerB = new System.Timers.Timer();//刷新时间
            timerB.Interval = System.Convert.ToDouble(500);
            timerB.Elapsed += new System.Timers.ElapsedEventHandler(RefreshTime);
            timerB.Enabled  = true;

            Messenger.Default.Register <CncStaticInfo>(this, "CncStaticInfoMsg", msg =>
            {
                CncStaticInfo = _mapper.Map <CncStaticInfo, CncStaticInfoDto>(msg);

                //报警信息转换
                var al_timespan = (DateTime.Now - _lastAlarmUpdataTime).TotalSeconds;
                if (al_timespan > 3)
                {
                    if (CncStaticInfo.CncAlarmList.Count == 0)
                    {
                        _DisAlarm = "";
                    }
                    else
                    {
                        try
                        {
                            string[] alm_type = { "SW", "PW", "IO", "PS", "OT", "OH", "SV", "SR", "MC", "SP", "DS", "IE", "BG", "SN", "", "EX", "", "", "", "PC" };
                            string[] alm_axis = { "", "(X)", "(Y)", "(Z)" };
                            if (_curAlarmIndex >= CncStaticInfo.CncAlarmList.Count)
                            {
                                _curAlarmIndex = 0;
                            }
                            _DisAlarm = alm_type[CncStaticInfo.CncAlarmList[_curAlarmIndex].Type] +
                                        CncStaticInfo.CncAlarmList[_curAlarmIndex].Alm_No.ToString("0000") +
                                        @" " + CncStaticInfo.CncAlarmList[_curAlarmIndex].Alm_Msg;


                            _curAlarmIndex++;
                        }
                        catch { }
                    }
                    _lastAlarmUpdataTime = DateTime.Now;
                }
            });

            Messenger.Default.Register <OperatorAuthTypeEnum>(this, "OperatorAuthMsg", msg =>
            {
                switch (msg)
                {
                case OperatorAuthTypeEnum.OPERATOR:
                    OperatorRole = "操作者";
                    break;

                case OperatorAuthTypeEnum.MANAGER:
                    OperatorRole = "管理员";
                    break;

                case OperatorAuthTypeEnum.MTB:
                    OperatorRole = "设备维护";
                    break;

                case OperatorAuthTypeEnum.BFM:
                    OperatorRole = "最高权限";
                    break;

                default:
                    OperatorRole = "操作者";
                    break;
                }
            });
        }