void Init()
        {
            PM.Text          = _PM = Inifile.INIGetStringValue(iniParameterPath, "BigData", "PM", "X1621");
            GROUP1.Text      = _GROUP1 = Inifile.INIGetStringValue(iniParameterPath, "BigData", "GROUP1", "NA");
            TRACK.Text       = _TRACK = Inifile.INIGetStringValue(iniParameterPath, "BigData", "TRACK", "0102");
            MACID.Text       = _MACID = Inifile.INIGetStringValue(iniParameterPath, "BigData", "MACID", "007");
            WORKSTATION.Text = _WORKSTATION = Inifile.INIGetStringValue(iniParameterPath, "BigData", "WORKSTATION", "X1621");
            LIGHT_ID.Text    = _LIGHT_ID = Inifile.INIGetStringValue(iniParameterPath, "BigData", "LIGHT_ID", "007");

            LampGreenElapse         = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "BigData", "LampGreenElapse", "0"));
            LampGreenFlickerElapse  = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "BigData", "LampGreenFlickerElapse", "0"));
            LampYellowElapse        = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "BigData", "LampYellowElapse", "0"));
            LampYellowFlickerElapse = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "BigData", "LampYellowFlickerElapse", "0"));
            LampRedElapse           = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "BigData", "LampRedElapse", "0"));

            LastBanci = Inifile.INIGetStringValue(iniParameterPath, "Summary", "LastBanci", "null");

            #region 报警文档
            try
            {
                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
                if (File.Exists(alarmExcelPath))
                {
                    FileInfo existingFile = new FileInfo(alarmExcelPath);
                    using (ExcelPackage package = new ExcelPackage(existingFile))
                    {
                        // get the first worksheet in the workbook
                        ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
                        for (int i = 1; i <= worksheet.Dimension.End.Row; i++)
                        {
                            AlarmData ad = new AlarmData();
                            ad.Code    = worksheet.Cells["A" + i.ToString()].Value == null ? "Null" : worksheet.Cells["A" + i.ToString()].Value.ToString();
                            ad.Content = worksheet.Cells["B" + i.ToString()].Value == null ? "Null" : worksheet.Cells["B" + i.ToString()].Value.ToString();
                            ad.Type    = worksheet.Cells["C" + i.ToString()].Value == null ? "Null" : worksheet.Cells["C" + i.ToString()].Value.ToString();
                            ad.Start   = DateTime.Now;
                            ad.End     = DateTime.Now;
                            ad.State   = false;
                            AlarmList.Add(ad);
                        }
                        AddMessage("读取到" + worksheet.Dimension.End.Row.ToString() + "条报警");
                    }
                }
                else
                {
                    AddMessage("X1621串线下料机报警.xlsx 文件不存在");
                }
            }
            catch (Exception ex)
            {
                AddMessage(ex.Message);
            }
            #endregion


            string ip   = Inifile.INIGetStringValue(iniParameterPath, "FX5U", "Ip", "192.168.0.20");
            int    port = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "FX5U", "Port", "504"));
            Fx5u   = new Fx5u(ip, port);
            ip     = Inifile.INIGetStringValue(iniParameterPath, "FX5U", "Ip2", "192.168.0.20");
            port   = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "FX5U", "Port2", "504"));
            Fx5u_2 = new Fx5u(ip, port);
            ScanA  = new Scan();
            string COM = Inifile.INIGetStringValue(iniParameterPath, "Scan", "ScanA", "COM3");
            ScanA.ini(COM);
            ScanB = new Scan();
            COM   = Inifile.INIGetStringValue(iniParameterPath, "Scan", "ScanB", "COM3");
            ScanB.ini(COM);
            UpdateUI();
            CardRun();
            Task.Run(() => { Run(); });
            BigDataRun();
            #region 更新本地时间
            try
            {
                SXJLibrary.Oracle oraDB = new SXJLibrary.Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168");
                if (oraDB.isConnect())
                {
                    string oracleTime = oraDB.OraclDateTime();
                    AddMessage("更新数据库时间到本地" + oracleTime);
                }
                oraDB.disconnect();
            }
            catch (Exception ex)
            {
                AddMessage(ex.Message);
            }
            #endregion
        }
Esempio n. 2
0
        public MainWindowViewModel()
        {
            #region 方法绑定
            this.FuncTestCommand   = new DelegateCommand(new Action(this.FuncTestCommandExecute));
            this.EditSaveCommand   = new DelegateCommand(new Action(this.EditSaveCommandExecute));
            this.ChoosePageCommand = new DelegateCommand <object>(new Action <object>(this.ChoosePageCommandExecute));
            this.CheckCommand      = new DelegateCommand(new Action(this.CheckCommandExecute));
            #endregion
            #region 界面元素初始化
            this.MessageStr        = "";
            this.WindowTitle       = "淮安鹏鼎轨道扫码软体";
            this.SaveButtonContent = "Edit";
            this.TextParmReadOnly  = true;
            LOCATIONID             = Inifile.INIGetStringValue(iniParameterPath, "System", "LOCATIONID", "HA");
            FACTORYID           = Inifile.INIGetStringValue(iniParameterPath, "System", "FACTORYID", "A1-2F");
            BPEMPID             = Inifile.INIGetStringValue(iniParameterPath, "System", "BPEMPID", "F7052804");
            BPWORKNO            = Inifile.INIGetStringValue(iniParameterPath, "System", "BPWORKNO", "1000080146");
            BPLINE              = Inifile.INIGetStringValue(iniParameterPath, "System", "BPLINE", "S14-302");
            BPIP                = Inifile.INIGetStringValue(iniParameterPath, "System", "BPIP", "01");
            BP01                = Inifile.INIGetStringValue(iniParameterPath, "System", "BP01", "F0AP0194A0Q");
            BP04                = Inifile.INIGetStringValue(iniParameterPath, "System", "BP04", "FHAPGD6A7X1SBD180324121");
            BP11                = Inifile.INIGetStringValue(iniParameterPath, "System", "BP11", "FHAPGD6A7X1SBDC180324314");
            BPPNL               = Inifile.INIGetStringValue(iniParameterPath, "System", "BPPNL", "A00110662A12210172");
            CheckBarcode        = Inifile.INIGetStringValue(iniParameterPath, "System", "CheckBarcode", "A00110662A12210172");
            HomePageVisibility  = "Visible";
            CheckPageVisibility = "Collapsed";
            #endregion
            #region 部件
            string COM = Inifile.INIGetStringValue(iniParameterPath, "Scan", "COM", "COM0");
            Scan1.ini(COM);
            #endregion
            #region 初始化IO卡
            IoInput = new ObservableCollection <bool>();
            for (int i = 0; i < 24; i++)
            {
                IoInput.Add(false);
            }
            IoOutput = new ObservableCollection <bool>();
            for (int i = 0; i < 16; i++)
            {
                IoOutput.Add(false);
            }
            IOCardRun();
            #endregion
            #region 更新本地时间
            try
            {
                SXJLibrary.Oracle oraDB = new SXJLibrary.Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168");
                if (oraDB.isConnect())
                {
                    string oracleTime = oraDB.OraclDateTime();
                    AddMessage("更新数据库时间到本地" + oracleTime);
                }
                oraDB.disconnect();
            }
            catch (Exception ex)
            {
                AddMessage(ex.Message);
            }

            #endregion
        }