private void Init() { HomePageVisibility = "Visible"; InsertPageVisibility = "Collapsed"; MessageStr = ""; MNOContent = "Edit"; MNOIsReadOnly = true; MNO = Inifile.INIGetStringValue(iniParameterPath, "System", "MNO", "NA"); //PARTNUM = Inifile.INIGetStringValue(iniParameterPath, "System", "PARTNUM", "NA"); RESULT = true; DATA0 = ""; OPERATORID = ""; BARCODE = ""; try { using (StreamReader reader = new StreamReader(Path.Combine(System.Environment.CurrentDirectory, "Partnum.json"))) { string json = reader.ReadToEnd(); PARTNUMItems = JsonConvert.DeserializeObject <ObservableCollection <string> >(json); } } catch (Exception ex) { PARTNUMItems = new ObservableCollection <string>(); AddMessage(ex.Message); } AddMessage("软件加载完成"); }
private void AppLoadedEventCommandExecute() { AddMessage("软件加载完成"); try { Mysql mysql = new Mysql(); if (mysql.Connect()) { string stm = $"SELECT NOW()"; DataSet ds = mysql.Select(stm); AddMessage($"数据库连接成功{ ds.Tables["table0"].Rows[0][0]}"); StatusDataBase = true; } else { AddMessage("数据库未连接"); StatusDataBase = false; } mysql.DisConnect(); } catch (Exception ex) { AddMessage($"数据库连接失败{ex.Message}"); StatusDataBase = false; } tcpServer = new DXH.Net.DXHTCPServer(); tcpServer.LocalIPAddress = Inifile.INIGetStringValue(iniParameterPath, "Server", "IP", "127.0.0.1"); tcpServer.LocalIPPort = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Server", "PORT", "11001")); tcpServer.SocketListChanged += TcpServer_SocketListChanged; tcpServer.ConnectStateChanged += TcpServer_ConnectStateChanged; tcpServer.Received += TcpServer_Received; tcpServer.StartTCPListen(); Run(); }
public MainDataContext() { ActPos1 = new TwinCATCoil1(new TwinCATCoil("MAIN.ActPos1", typeof(double), TwinCATCoil.Mode.Notice), _TwinCATAds); PowerOn1 = new TwinCATCoil1(new TwinCATCoil("MAIN.PowerOn", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); Error1 = new TwinCATCoil1(new TwinCATCoil("MAIN.Error1", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); M2 = new TwinCATCoil1(new TwinCATCoil("MAIN.M2", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); M4 = new TwinCATCoil1(new TwinCATCoil("MAIN.M4", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); M0 = new TwinCATCoil1(new TwinCATCoil("MAIN.M0", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); Mode1 = new TwinCATCoil1(new TwinCATCoil("MAIN.Mode1", typeof(ushort), TwinCATCoil.Mode.Notice), _TwinCATAds); M16 = new TwinCATCoil1(new TwinCATCoil("MAIN.M16", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); M17 = new TwinCATCoil1(new TwinCATCoil("MAIN.M17", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); M20 = new TwinCATCoil1(new TwinCATCoil("MAIN.M20", typeof(bool), TwinCATCoil.Mode.Notice), _TwinCATAds); P1 = new TwinCATCoil1(new TwinCATCoil("MAIN.P1", typeof(double), TwinCATCoil.Mode.Notice), _TwinCATAds); V1 = new TwinCATCoil1(new TwinCATCoil("MAIN.V1", typeof(double), TwinCATCoil.Mode.Notice), _TwinCATAds); _TwinCATAds.StartNotice(); UIUpdate(); Position1 = double.Parse(Inifile.INIGetStringValue(iniPosition, "Axis1", "Position1", "0")); Position2 = double.Parse(Inifile.INIGetStringValue(iniPosition, "Axis1", "Position2", "0")); Position3 = double.Parse(Inifile.INIGetStringValue(iniPosition, "Axis1", "Position3", "0")); Position4 = double.Parse(Inifile.INIGetStringValue(iniPosition, "Axis1", "Position4", "0")); Position5 = double.Parse(Inifile.INIGetStringValue(iniPosition, "Axis1", "Position5", "0")); //WaitNet(); //CommandFromRemote(); }
public EpsonRC90() { for (int i = 0; i < 4; i++) { YanmadeTester[i] = new Tester(i + 1); uploadSoftwareStatus[i] = new UploadSoftwareStatus(i + 1); uploadSoftwareStatus[i].ModelPrint += uploadprint; uploadSoftwareStatus[i].RecordPrint += RecordPrintOperate; } Ip = Inifile.INIGetStringValue(iniParameterPath, "EpsonRC90", "Ip", "192.168.1.2"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 15; j++) { BarInfo[i][j] = new ProducInfo(); BarInfo[i][j].Barcode = "FAIL"; BarInfo[i][j].BordBarcode = "Null"; BarInfo[i][j].Status = 0; BarInfo[i][j].TDate = DateTime.Now.ToString("yyyyMMdd"); BarInfo[i][j].TTime = DateTime.Now.ToString("HHmmss"); } } SamStart = DateTime.Now; Run(); }
private void TesterStatusInit() { for (int i = 0; i < 2; i++) { TestSpan[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "TestSpan", "0")); TestIdle[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "TestIdle", "0")); TestCycle[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "TestCycle", "0")); PassCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "PassCount", "0")); PassCount_Nomal[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "PassCount_Nomal", "0")); FailCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "FailCount", "0")); FailCount_Nomal[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "FailCount_Nomal", "0")); TestCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "TestCount", "0")); TestCount_Nomal[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "TestCount_Nomal", "0")); Yield[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "Yield", "0")); Yield_Nomal[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 2 + i).ToString(), "Yield_Nomal", "0")); string str = ""; switch (Index) { case 0: switch (i) { case 0: str = "TesterBracodeAL"; break; case 1: str = "TesterBracodeAR"; break; default: str = ""; break; } break; case 1: switch (i) { case 0: str = "TesterBracodeBL"; break; case 1: str = "TesterBracodeBR"; break; default: str = ""; break; } break; default: break; } TesterBracode[i] = Inifile.INIGetStringValue(iniParameterPath, "Barcode", str, "Null"); } }
public MainWindow() { InitializeComponent(); LastBanci = Inifile.INIGetStringValue(iniParameterPath, "System", "Banci", "0"); dispatcherTimer.Tick += new EventHandler(DispatcherTimerTickUpdateUi); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); }
private void run() { bool WriteFileFlag = false; try { numStr = Inifile.INIGetStringValue(iniFilepath, sectionName, "upload", "0"); } catch (Exception ex) { Log.Default.Error("UploadSoftwareStatus.ReadIniFail1", ex.Message); } status = true; timed = 2000; while (true) { if (start) { try { numStrNew = Inifile.INIGetStringValue(iniFilepath, sectionName, "upload", "0"); } catch (Exception ex) { Log.Default.Error("UploadSoftwareStatus.ReadIniFail2", ex.Message); } if (numStr != numStrNew) { status = true; numStr = numStrNew; timed = 2000; start = false; WriteFileFlag = false; } else { //if (!WriteFileFlag) //{ // Inifile.INIWriteValue(iniFilepath, sectionName, "upload", "0"); // numStr = "0"; // WriteFileFlag = true; //} status = false; timed = 1000; } } else { timed = 2000; } System.Threading.Thread.Sleep(timed); } }
public MainDataContext() { ScanCom = Inifile.INIGetStringValue(iniParameterPath, "Com", "ScanCom", "COM1"); SerialPortCom = Inifile.INIGetStringValue(iniParameterPath, "Com", "SerialPortCom", "COM1"); MACString = Inifile.INIGetStringValue(iniParameterPath, "MES", "MAC", "14-B3-1F-02-2D-83"); LiaoHaoSelectedIndex = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "LiaoHao", "SelectIndex", "0")); Scan.ini(ScanCom); //ImportDatefromExcel(); //Console.WriteLine(Convert.ToString(16, 16)); }
private void ReadParameter() { JiTaiHao = Inifile.INIGetStringValue(ParameterIniPath, "Text", "JiTaiHao", "01"); BarcocdeA = Inifile.INIGetStringValue(ParameterIniPath, "Text", "BarcocdeA", "ABC"); BarcocdeB = Inifile.INIGetStringValue(ParameterIniPath, "Text", "BarcocdeB", "DEF"); PLCPortCom = Inifile.INIGetStringValue(ParameterIniPath, "Text", "PLCPortCom", "COM1"); ScanAPortCom = Inifile.INIGetStringValue(ParameterIniPath, "Text", "ScanAPortCom", "COM1"); ScanBPortCom = Inifile.INIGetStringValue(ParameterIniPath, "Text", "ScanBPortCom", "COM1"); LastCleanRecordFlag = Inifile.INIGetStringValue(ParameterIniPath, "Record", "LastCleanRecordFlag", "123"); TrigerTimes = int.Parse(Inifile.INIGetStringValue(ParameterIniPath, "Times", "TrigerTimes", "0")); ScanTimes = int.Parse(Inifile.INIGetStringValue(ParameterIniPath, "Times", "ScanTimes", "0")); UpdateTimes = int.Parse(Inifile.INIGetStringValue(ParameterIniPath, "Times", "UpdateTimes", "0")); }
private void TesterStatusInit() { for (int i = 0; i < 4; i++) { TesterBracode[i] = Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "TesterBracode", "Null"); TestSpan[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "TestSpan", "0")); PassCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "PassCount", "0")); FailCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "FailCount", "0")); TestCount[i] = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "TestCount", "0")); Yield[i] = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index * 4 + i).ToString(), "Yield", "0")); double timeout = double.Parse(Inifile.INIGetStringValue(iniParameterPath, "FlexTest", "FlexTestTimeout", "100")); TestTimeout = (int)(timeout * 1000); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { string iniSamplePath = System.Environment.CurrentDirectory + "\\Sample.ini"; try { IsSampleCheck.IsChecked = bool.Parse(Inifile.INIGetStringValue(iniSamplePath, "Sample", "IsSample", "True")); } catch { IsSampleCheck.IsChecked = true; } try { int count = int.Parse(Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemCount", "9")); NGItemCount.Text = count.ToString(); } catch { NGItemCount.Text = "9"; } NGItem1.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem1", "Null"); NGItem2.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem2", "Null"); NGItem3.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem3", "Null"); NGItem4.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem4", "Null"); NGItem5.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem5", "Null"); NGItem6.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem6", "Null"); NGItem7.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem7", "Null"); NGItem8.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem8", "Null"); NGItem9.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem9", "Null"); NGItem10.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItem10", "Null"); NGItemClassify1.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify1", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify2.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify2", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify3.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify3", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify4.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify4", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify5.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify5", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify6.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify6", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify7.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify7", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify8.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify8", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify9.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify9", "Null") == "ZP" ? "ZP" : "FCT"; NGItemClassify10.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "NGItemClassify10", "Null") == "ZP" ? "ZP" : "FCT"; SamMode.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "SamMode", "Null") == "2h" ? "2h" : "6h"; ZPMID.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "ZPMID", "ATKC4-012"); FCTMID.Text = Inifile.INIGetStringValue(iniSamplePath, "Sample", "FCTMID", "ATKC4-016"); }
public DeltaPLC() { COM = Inifile.INIGetStringValue(iniParameterPath, "System", "COM", "COM1"); STATE = Inifile.INIGetStringValue(iniParameterPath, "System", "STATE", "01"); plc = new Delta_ModbusASCII(COM, 9600, System.IO.Ports.Parity.Even, 7, System.IO.Ports.StopBits.One); ScanC = new Scan(); string ScanCom = Inifile.INIGetStringValue(iniParameterPath, "System", "扫码枪串口", "COM1"); ReUpdateHour = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "System", "ReUpdateHour", "0")); //ScanC.ini(ScanCom); //ScanC.Connect(); PlcRun(); vision = new Vision(); //plc.PLCWriteBit(STATE, "M3111", "0006", "3E"); // GlobalVar.AddMessage("蚀刻信息已写入PLC"); }
public Tester(int index) { Index = index; idleswflag = false; idlesw = new Stopwatch(); TestSpan = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestSpan", "0")); TestIdle = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestIdle", "0")); TestCycle = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCycle", "0")); PassCount = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "PassCount", "0")); PassCount_Nomal = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "PassCount_Nomal", "0")); FailCount = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "FailCount", "0")); FailCount_Nomal = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "FailCount_Nomal", "0")); TestCount = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCount", "0")); TestCount_Nomal = int.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "TestCount_Nomal", "0")); Yield = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "Yield", "0")); Yield_Nomal = double.Parse(Inifile.INIGetStringValue(iniTesterResutPath, "Tester" + (Index - 1).ToString(), "Yield_Nomal", "0")); Task.Run(() => { RunLoop(); }); }
private void ReadIni() { try { AS300IP = Inifile.INIGetStringValue(iniParameterPath, "AS300", "AS300IP", "192.168.1.5"); HScriptFileName = Inifile.INIGetStringValue(iniParameterPath, "Camera", "HScriptFileName", @"D:\test.hdev"); BLID = Inifile.INIGetStringValue(iniParameterPath, "SQLMSG", "BLID", "Null"); BLUID = Inifile.INIGetStringValue(iniParameterPath, "SQLMSG", "BLUID", "Null"); BLMID = Inifile.INIGetStringValue(iniParameterPath, "SQLMSG", "BLMID", "Null"); BLNAME = Inifile.INIGetStringValue(iniParameterPath, "SQLMSG", "BLNAME", "Null"); LastReUpdateStr = Inifile.INIGetStringValue(iniParameterPath, "ReUpLoad", "LastReUpdateStr", "2017-10-16 11:22:33"); MsgText = AddMessage("参数读取完成"); } catch (Exception ex) { MsgText = AddMessage("参数读取失败: " + ex.Message); } }
public BigDataPage() { InitializeComponent(); AlarmDataGrid.ItemsSource = GlobalVar.AlarmRecord; MESDataRecord.ItemsSource = GlobalVar.MESDataRecord; MachineID_Text.Text = GlobalVar.MachineID = Inifile.INIGetStringValue(iniParameterPath, "System", "MachineID", "KF901"); UserID_Text.Text = GlobalVar.UserID = Inifile.INIGetStringValue(iniParameterPath, "System", "UserID", "F0001"); ProductName_Text.Text = GlobalVar.ProductName = Inifile.INIGetStringValue(iniParameterPath, "System", "ProductName", "KF9"); MachineName_Text.Text = GlobalVar.MachineName = Inifile.INIGetStringValue(iniParameterPath, "System", "MachineName", "KF9-01"); FactoryArea_Text.Text = GlobalVar.FactoryArea = Inifile.INIGetStringValue(iniParameterPath, "System", "FactoryArea", "SZ"); FactorySeparation_Text.Text = GlobalVar.FactorySeparation = Inifile.INIGetStringValue(iniParameterPath, "System", "FactorySeparation", "A2-4F"); ZhijuClass_Text.Text = GlobalVar.ZhijuClass = Inifile.INIGetStringValue(iniParameterPath, "System", "ZhijuClass", "ZX"); MAC_Text.Text = GlobalVar.MAC = Inifile.INIGetStringValue(iniParameterPath, "System", "MAC", "C4-8E-8F-74-5D-89"); Barcodeproofing_Text.Text = GlobalVar.Barcodeproofing = Inifile.INIGetStringValue(iniParameterPath, "System", "Barcodeproofing", "A2-4F"); scancodetype_Text.Text = GlobalVar.scancodetype = Inifile.INIGetStringValue(iniParameterPath, "System", "scancodetype", "ZX,C46"); CCD_Text.Text = GlobalVar.CCD = Inifile.INIGetStringValue(iniParameterPath, "System", "CCD", "CCD"); NNNN_Text.Text = GlobalVar.NNNN = Inifile.INIGetStringValue(iniParameterPath, "System", "NNNN", "NNNN"); }
public MainWindowViewModel() { #region 初始化参数 try { MessageStr = ""; Version = "20201103"; HomePageVisibility = "Visible"; ParameterPageVisibility = "Collapsed"; RemotePath = Inifile.INIGetStringValue(iniParameterPath, "System", "RemotePath", "D:\\"); MachineID = Inifile.INIGetStringValue(iniParameterPath, "System", "MachineID", "Null"); StationNo = 0; StationNo = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "System", "StationNo", "1")); cameraName = Inifile.INIGetStringValue(iniParameterPath, "System", "CameraName", "[0] Integrated Camera"); cameraInterface = Inifile.INIGetStringValue(iniParameterPath, "System", "CameraInterface", "DirectShow"); Version += StationNo.ToString(); EStopIsChecked = false; CameraROIList = new ObservableCollection <ROI>(); string ip = Inifile.INIGetStringValue(iniParameterPath, "PLC", "IP", "192.168.0.100"); H3u = new InovanceH3UModbusTCP(ip); RemoteIP = Inifile.INIGetStringValue(iniParameterPath, "Remote", "IP", "192.168.0.11"); RemotePort = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Remote", "PORT", "3000")); LocalIP = Inifile.INIGetStringValue(iniParameterPath, "Local", "IP", "192.168.0.11"); LocalPort = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Local", "PORT", "5000")); tcpNet = new DXH.Net.DXHTCPClient(RemoteIP, RemotePort, LocalIP, LocalPort); tcpNet.ConnectStateChanged += TcpNet_ConnectStateChanged; } catch (Exception ex) { AddMessage(ex.Message); } #endregion AppLoadedEventCommand = new DelegateCommand(new Action(this.AppLoadedEventCommandExecute)); MenuActionCommand = new DelegateCommand <object>(new Action <object>(this.MenuActionCommandExecute)); FolderBrowserDialogCommand = new DelegateCommand(new Action(this.FolderBrowserDialogCommandExecute)); ParameterSaveCommand = new DelegateCommand(new Action(this.ParameterSaveCommandExecute)); OperateButtonCommand = new DelegateCommand <object>(new Action <object>(this.OperateButtonCommandExecute)); }
public MainWindowViewModel() { #region 初始化参数 Version = "20201103"; MessageStr = ""; HomePageVisibility = "Visible"; ParameterPageVisibility = "Collapsed"; WorkPath = Inifile.INIGetStringValue(iniParameterPath, "System", "WorkPath", "D:\\"); ImageSavePath = Inifile.INIGetStringValue(iniParameterPath, "System", "ImageSavePath", "D:\\"); CameraROIList = new ObservableCollection <ROI>(); ServerIP = Inifile.INIGetStringValue(iniParameterPath, "Server", "IP", "192.168.0.11"); ServerPort = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Server", "PORT", "3000")); #endregion AppLoadedEventCommand = new DelegateCommand(new Action(this.AppLoadedEventCommandExecute)); MenuActionCommand = new DelegateCommand <object>(new Action <object>(this.MenuActionCommandExecute)); FolderBrowserDialogCommand = new DelegateCommand <object>(new Action <object>(this.FolderBrowserDialogCommandExecute)); ParameterSaveCommand = new DelegateCommand(new Action(this.ParameterSaveCommandExecute)); }
public MainWindowViewModel() { tcpServer = new DXHTCPServer(); string plc_ip = Inifile.INIGetStringValue(iniParameterPath, "System", "PLCIP", "192.168.1.13"); h3u = new H3U(plc_ip); string robot_ip = Inifile.INIGetStringValue(iniParameterPath, "System", "RobotIP", "192.168.1.5"); int robot_port = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "System", "RobotPORT", "2000")); epsonRC90 = new EpsonRC90(robot_ip, robot_port); h3u.ModbusTCP_Client.ModbusStateChanged += ModbusTCP_Client_ModbusStateChanged; epsonRC90.ConnectStateChanged += EpsonRC90_ConnectStateChanged; tcpServer.LocalIPAddress = Inifile.INIGetStringValue(iniParameterPath, "System", "ServerIP", "127.0.0.1"); tcpServer.LocalIPPort = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "System", "ServerPORT", "11001")); tcpServer.SocketListChanged += TcpServer_SocketListChanged; tcpServer.ConnectStateChanged += TcpServer_ConnectStateChanged; tcpServer.Received += TcpServer_Received; AppLoadedEventCommand = new DelegateCommand(new Action(this.AppLoadedEventCommandExecute)); AppClosedEventCommand = new DelegateCommand(new Action(this.AppClosedEventCommandExecute)); MenuActionCommand = new DelegateCommand <object>(new Action <object>(this.MenuActionCommandExecute)); FuncCommand = new DelegateCommand(new Action(this.FuncCommandExecute)); AlarmReportFromExportCommand = new DelegateCommand(new Action(this.AlarmReportFromExportCommandExecute)); BigDataPeramEditCommand = new DelegateCommand(new Action(this.BigDataPeramEditCommandExecute)); if (System.Environment.CurrentDirectory != @"C:\Debug") { System.Windows.MessageBox.Show("软件安装目录必须为C:\\Debug", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); System.Windows.Application.Current.Shutdown(); } else { System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("SZRFUI"); //获取指定的进程名 if (myProcesses.Length > 1) //如果可以获取到知道的进程名则说明已经启动 { System.Windows.MessageBox.Show("不允许重复打开软件", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); System.Windows.Application.Current.Shutdown(); } } }
public void ResetBord(int index) { for (int i = 0; i < 15; i++) { BarInfo[index][i].Barcode = "FAIL"; BarInfo[index][i].BordBarcode = BordBarcode[index]; BarInfo[index][i].Status = 0; BarInfo[index][i].TDate = DateTime.Now.ToString("yyyyMMdd"); BarInfo[index][i].TTime = DateTime.Now.ToString("HHmmss"); string machinestr = Inifile.INIGetStringValue(iniParameterPath, "System", "MachineID", "X1621_1"); Mysql mysql = new Mysql(); if (mysql.Connect()) { string stm = "INSERT INTO BARBIND (MACHINE,SCBARCODE,SCBODBAR,SDATE,STIME,PCSSER,RESULT) VALUES ('" + machinestr + "','" + BarInfo[index][i].Barcode + "','" + BordBarcode[index] + "','" + BarInfo[index][i].TDate + "','" + BarInfo[index][i].TTime + "','" + (i + 1).ToString() + "','" + BarInfo[index][i].Status.ToString() + "')"; mysql.executeQuery(stm); } mysql.DisConnect(); } }
public async void ChoosePageAction(object p) { switch (p.ToString()) { case "0": HomePageVisibility = "Visible"; RecordPageVisibility = "Collapsed"; ParameterPageVisibility = "Collapsed"; break; case "1": HomePageVisibility = "Collapsed"; RecordPageVisibility = "Visible"; ParameterPageVisibility = "Collapsed"; break; case "2": List <string> r; r = await mydialog.showlogin(); if (r[1] == Inifile.INIGetStringValue(ParameterIniPath, "Password", "Psw", "QWER7788")) { HomePageVisibility = "Collapsed"; RecordPageVisibility = "Collapsed"; ParameterPageVisibility = "Visible"; } else { HomePageVisibility = "Visible"; RecordPageVisibility = "Collapsed"; ParameterPageVisibility = "Collapsed"; } break; default: break; } }
void Init() { try { string ExIoExcelPath = System.Environment.CurrentDirectory + "\\排版.xlsx"; if (File.Exists(ExIoExcelPath)) { FileInfo existingFile = new FileInfo(ExIoExcelPath); using (ExcelPackage package = new ExcelPackage(existingFile)) { // get the first worksheet in the workbook ExcelWorksheet worksheet = package.Workbook.Worksheets[2]; for (int i = 0; i < 96; i++) { BordIndex[i] = int.Parse(worksheet.Cells[i / 12 + 1, i % 12 + 1].Value.ToString()); } } 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); Scan5 = new Scan(); string COM = Inifile.INIGetStringValue(iniParameterPath, "Scan", "Scan5", "COM3"); Scan5.ini(COM); Run(); } else { throw new Exception("排版文件不存在"); } } catch (Exception ex) { AddMessage(ex.Message); } }
public Testerwith4item(string ip, int port, int index) { TestPcIP = ip; TestPcRemotePort = port; Index = index; switch (index) { case 0: sectionName1 = "A"; sectionName2 = "B"; break; case 1: sectionName1 = "C"; sectionName2 = "D"; break; default: break; } udp = new Udp(TestPcIP, TestPcRemotePort, 12000 + Index, 5000); TestCommandStringReadline(); TesterStatusInit(); timeout = double.Parse(Inifile.INIGetStringValue(iniParameterPath, "FlexTest", "FlexTestTimeout", "100")); timenomal = double.Parse(Inifile.INIGetStringValue(iniParameterPath, "FlexTest", "FlexTestNomalTime", "50")); TestTimeout = (int)(timeout * 1000); //RunLoop(); idleswflag1 = false; idleswflag2 = false; idlesw1 = new Stopwatch(); idlesw2 = new Stopwatch(); Async.RunFuncAsync(RunLoop, null); }
public void ini(string Com) { try { Scaner = bool.Parse(Inifile.INIGetStringValue(iniParameterPath, "System", "Scaner", "False")); } catch { } if (Scaner) { mSerialPort = new SerialPort(Com, 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); START_DECODE = new byte[] { 0x16, 0x54, 0x0D };//{0x03,0x53,0x80,0xFF,0x2A }; STOP_DECODE = new byte[] { 0x16, 0x55, 0x0D }; MODE_DECODE = new byte[] { 0x16, 0x4D, 0x0D, 0x30, 0x34, 0x30, 0x31, 0x44, 0x30, 0x35, 0x2E }; } else { mSerialPort = new SerialPort(Com, 115200, System.IO.Ports.Parity.Even, 8, System.IO.Ports.StopBits.One); } mSerialPort.ReadTimeout = 1000; mSerialPort.WriteTimeout = 1000; }
private async void Run() { string MODE = "1"; int CardStatus = 1, cardret = 1; while (true) { await Task.Delay(500); #region 刷卡 await Task.Run(() => { try { byte[] buf = new byte[256]; //用来存储卡信息的buff byte[] snr = 读写器530SDK.CPublic.CharToByte("FF FF FF FF FF FF"); //应该是一种读码格式,照抄即可。 if (IntPtr.Zero == reader.GetHComm()) { string COM = Inifile.INIGetStringValue(iniParameterPath, "读卡器", "COM", "COM19").Replace("COM", ""); reader.OpenComm(int.Parse(COM), 9600); MODE = Inifile.INIGetStringValue(iniParameterPath, "读卡器", "MODE", "3"); } //刷卡;若刷到卡返回0,没刷到回1。 CardStatus = reader.MF_Read(0, byte.Parse(MODE), 0, 1, ref snr[0], ref buf[0]); //采用上升沿信号,防止卡放在读卡机上,重复执行查询动作。寄卡放一次,才查询一次,要再查询,需要重新刷卡。 if (cardret != CardStatus) { cardret = CardStatus; if (CardStatus == 0)//刷到卡了 { string strTmp = ""; //测试发现,卡返回的是16个HEX(十六进制)数,放在byte[]数组内,需要用一下方法转成字符串格式。 for (int i = 0; i < 16; i++) { strTmp += string.Format("{0:X2} ", buf[i]); } //删除转换后,字符串内的空格。这些HEX字符并不是员工编号字符的编码,需要用读到的字符串在数据库里查找, //在记录里再匹配员工信息和权限 string barcode = strTmp.Replace(" ", ""); AddMessage("刷卡 " + barcode); BARCODE = barcode; SXJLibrary.Oracle oraDB = new SXJLibrary.Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168"); if (oraDB.isConnect()) { string stm = string.Format("SELECT * FROM CAP_TABLE WHERE BARCODE = '{0}'", barcode); DataSet ds = oraDB.executeQuery(stm); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0)//查询到数据条目大于0,即查到了 { //取查到的第一行记录,一般只有1行。如果有多行,也只取第一行。 DataRow dr = dt.Rows[0]; //筛选一下数据,如果我们需要的“工号”、“姓名”和“权限”对应的栏位为空,则数据不合格。 if (dr["OPERATORID"] != DBNull.Value && dr["DATA0"] != DBNull.Value && dr["RESULT"] != DBNull.Value && dr["DATA1"] != DBNull.Value) { //打印出匹配到的结果,并返回给下位机。 AddMessage("工号 " + (string)dr["OPERATORID"] + " 姓名 " + (string)dr["DATA0"] + " 权限 " + (string)dr["RESULT"] + " 料号 " + (string)dr["DATA1"]); stm = string.Format("UPDATE CFT_DATA SET BARCODE = '{0}',TRESULT = '{1}',OPERTOR = '{2}',TESTDATE = '{3}',TESTTIME = '{4}', CFT01 = '{6}' WHERE MNO = '{5}'", barcode, (string)dr["RESULT"], (string)dr["OPERATORID"], DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), MNO, (string)dr["DATA1"]); int updaterst = oraDB.executeNonQuery(stm); if (updaterst > 0) { AddMessage("更新刷卡机台" + (string)dr["PARTNUM"] + " " + updaterst.ToString()); oraDB.executeNonQuery("COMMIT"); } else { stm = string.Format("INSERT INTO CFT_DATA (BARCODE,TRESULT,OPERTOR,TESTDATE,TESTTIME,CFT01,MNO) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", barcode, (string)dr["RESULT"], (string)dr["OPERATORID"], DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), (string)dr["DATA1"], MNO); int insertrst = oraDB.executeNonQuery(stm); AddMessage("插入刷卡机台" + (string)dr["PARTNUM"] + " " + insertrst.ToString()); oraDB.executeNonQuery("COMMIT"); } } else { AddMessage("数据库记录信息不完整"); } } else { AddMessage("未查询到卡信息"); } } oraDB.disconnect(); } } } catch (Exception ex) { reader.CloseComm(); AddMessage(ex.Message); } }); #endregion } }
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 }
/// <扫描周期> /// 100ms /// </扫描周期> private void RunLoop() { //[1] //--填入条码开始测试,测试完成条码会被清空 //BARCODE= //--PASS;FAIL; //RESULT= //--0:需要复测;1:可以取出 //TAKE= while (true) { for (int i = 0; i < 4; i++) { if (TestActionSwitch[i]) { switch (StepFlag[i]) { case 0: //写条码 Inifile.INIWriteValue(iniTestCommandpath, (i + 1).ToString(), "BARCODE", TesterBracode[i]); Inifile.INIWriteValue(iniTestCommandpath, (i + 1).ToString(), "RESULT", ""); Inifile.INIWriteValue(iniTestCommandpath, (i + 1).ToString(), "TAKE", ""); StepFlag[i] = 1; break; case 1: //读是否测试完成 string rststr = Inifile.INIGetStringValue(iniTestCommandpath, (i + 1).ToString(), "RESULT", "Error"); if (rststr == "PASS" || rststr == "FAIL") { StepFlag[i] = 2; } break; case 2: //读Pass;读Ng string takestr = Inifile.INIGetStringValue(iniTestCommandpath, (i + 1).ToString(), "TAKE", "Error"); Inifile.INIWriteValue(iniTestCommandpath, (i + 1).ToString(), "TAKE", ""); if (takestr == "0") { System.Threading.Thread.Sleep(2000); StepFlag[i] = 0; } else { string resultstr = Inifile.INIGetStringValue(iniTestCommandpath, (i + 1).ToString(), "RESULT", "PASS"); Inifile.INIWriteValue(iniTestCommandpath, (i + 1).ToString(), "RESULT", ""); result_flag[i] = resultstr == "PASS"; StepFlag[i] = 3; } break; case 3: //完成 System.Threading.Thread.Sleep(100); break; default: break; } } else { StepFlag[i] = -1; } } System.Threading.Thread.Sleep(100); } }
async void CardRun() { string MODE = ""; int CardStatus; int cardret = 1; int timetick = 0; Fx5u_2.SetM("M2606", true); CardLockFlag = true; CardLockTime = DateTime.Now; AddMessage("机台锁定!"); while (true) { await Task.Delay(1000); #region 刷卡 try { byte[] buf = new byte[256]; //用来存储卡信息的buff byte[] snr = 读写器530SDK.CPublic.CharToByte("FF FF FF FF FF FF"); //应该是一种读码格式,照抄即可。 if (true) { if (IntPtr.Zero == reader.GetHComm()) { string COM = Inifile.INIGetStringValue(iniParameterPath, "读卡器", "COM", "COM19").Replace("COM", ""); reader.OpenComm(int.Parse(COM), 9600); MODE = Inifile.INIGetStringValue(iniParameterPath, "读卡器", "MODE", "3"); } //刷卡;若刷到卡返回0,没刷到回1。 CardStatus = reader.MF_Read(0, byte.Parse(MODE), 0, 1, ref snr[0], ref buf[0]); //采用上升沿信号,防止卡放在读卡机上,重复执行查询动作。寄卡放一次,才查询一次,要再查询,需要重新刷卡。 if (cardret != CardStatus) { cardret = CardStatus; if (CardStatus == 0)//刷到卡了 { string strTmp = ""; //测试发现,卡返回的是16个HEX(十六进制)数,放在byte[]数组内,需要用一下方法转成字符串格式。 for (int i = 0; i < 16; i++) { strTmp += string.Format("{0:X2} ", buf[i]); } //删除转换后,字符串内的空格。这些HEX字符并不是员工编号字符的编码,需要用读到的字符串在数据库里查找, //在记录里再匹配员工信息和权限 string barcode = strTmp.Replace(" ", ""); AddMessage("刷卡 " + barcode); Oracle oraDB = new Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168"); if (oraDB.isConnect()) { string stm = string.Format("SELECT * FROM CAP_TABLE WHERE BARCODE = '{0}'", barcode); DataSet s = oraDB.executeQuery(stm); DataTable dt = s.Tables[0]; if (dt.Rows.Count > 0)//查询到数据条目大于0,即查到了 { //取查到的第一行记录,一般只有1行。如果有多行,也只取第一行。 DataRow dr = dt.Rows[0]; //筛选一下数据,如果我们需要的“工号”、“姓名”和“权限”对应的栏位为空,则数据不合格。 if (dr["OPERATORID"] != DBNull.Value && dr["DATA0"] != DBNull.Value && dr["RESULT"] != DBNull.Value && dr["PARTNUM"] != DBNull.Value) { //打印出匹配到的结果,并返回给下位机。 AddMessage("工号 " + (string)dr["OPERATORID"] + " 姓名 " + (string)dr["DATA0"] + " 权限 " + (string)dr["RESULT"]); if ((string)dr["PARTNUM"] == PM.Text) { stm = string.Format("UPDATE CFT_DATA SET BARCODE = '{0}',TRESULT = '{1}',OPERTOR = '{2}',TESTDATE = '{3}',TESTTIME = '{4}',PARTNUM = '{6}' WHERE MNO = '{5}' OR CFT01 = '{5}'", barcode, (string)dr["RESULT"], (string)dr["OPERATORID"], DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), _MACID, (string)dr["PARTNUM"]); int updaterst = oraDB.executeNonQuery(stm); AddMessage("更新刷卡机台" + updaterst.ToString()); oraDB.executeNonQuery("COMMIT"); } else { AddMessage("人员信息与料号不符"); } } else { AddMessage("数据库记录信息不完整"); } } else { AddMessage("未查询到卡信息"); } } oraDB.disconnect(); } } } } catch (Exception ex) { reader.CloseComm(); AddMessage(ex.Message); } #endregion #region 刷卡恢复 if (CardLockFlag) { try { Oracle oraDB = new Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168"); if (oraDB.isConnect()) { string stm = string.Format("SELECT * FROM CFT_DATA WHERE MNO = '{0}' AND TRESULT = 'PASS' ORDER BY TESTDATE DESC,TESTTIME DESC", _MACID); DataSet ds = oraDB.executeQuery(stm); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; string datestr = (string)dr["TESTDATE"]; string timestr = (string)dr["TESTTIME"]; if (datestr.Length == 8 && (timestr.Length == 5 || timestr.Length == 6)) { if (timestr.Length == 5) { timestr = "0" + timestr; } string datetimestr = string.Empty; datetimestr = string.Format("{0}/{1}/{2} {3}:{4}:{5}", datestr.Substring(0, 4), datestr.Substring(4, 2), datestr.Substring(6, 2), timestr.Substring(0, 2), timestr.Substring(2, 2), timestr.Substring(4, 2)); DateTime updatetime = Convert.ToDateTime(datetimestr); if ((updatetime - CardLockTime).TotalMilliseconds > 0) { Fx5u_2.SetM("M2606", false); CardLockFlag = false; AddMessage("刷卡成功,解锁"); } } } } oraDB.disconnect(); } catch (Exception ex) { AddMessage(ex.Message); } } #endregion #region 锁机 if (!CardLockFlag) { if (LampColor != 1) { if (timetick++ > 15 * 60) { Fx5u_2.SetM("M2606", true); CardLockFlag = true; CardLockTime = DateTime.Now; AddMessage("机台锁定!"); timetick = 0; } } else { timetick = 0; } } else { timetick = 0; } #endregion } }
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 }
private void run() { status = true; timed = 1000; int ngnum = 0; while (true) { if (start) { string newbar = Inifile.INIGetStringValue(iniFilepath, "A", "bar" + index.ToString(), "0"); try { Oracle oraDB = new Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168"); if (oraDB.isConnect()) { string stm = String.Format("Select * from fluke_data WHERE BARCODE = '{0}'AND TRESULT = '{1}' ORDER BY ITSDATE DESC, ITSTIME DESC", newbar, result); DataSet s = oraDB.executeQuery(stm); DataTable dt = s.Tables[0]; if (dt.Rows.Count > 0) { string datestr = (string)dt.Rows[0]["ITSDATE"]; string timestr = (string)dt.Rows[0]["ITSTIME"]; if (datestr.Length == 8 && (timestr.Length == 5 || timestr.Length == 6)) { if (timestr.Length == 5) { timestr = "0" + timestr; } string datetimestr = string.Empty; datetimestr = string.Format("{0}/{1}/{2} {3}:{4}:{5}", datestr.Substring(0, 4), datestr.Substring(4, 2), datestr.Substring(6, 2), timestr.Substring(0, 2), timestr.Substring(2, 2), timestr.Substring(4, 2)); DateTime updatetime = Convert.ToDateTime(datetimestr); TimeSpan sp = System.DateTime.Now - updatetime; if (sp.TotalSeconds < 30) { ngnum = 0; status = true; timed = 2000; start = false; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 数据上传成功 " + updatetime.ToString()); stm = String.Format("Select * from fluke_data WHERE BARCODE = '{0}' ORDER BY ITSDATE DESC, ITSTIME DESC", newbar, result); s = oraDB.executeQuery(stm); dt = s.Tables[0]; if (dt.Rows.Count > 3) { RecordPrint(index, newbar, result, testerCycle, false); } else { RecordPrint(index, newbar, result, testerCycle, true); } } else { timed = 1000; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 数据上传逾时 " + updatetime.ToString()); } } else { timed = 1000; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 时间格式错误 " + datestr + " " + timestr); } } else { timed = 1000; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 未查询到数据"); } } else { timed = 1000; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 数据库未连接"); } oraDB.disconnect(); } catch (Exception ex) { ModelPrint("测试机" + index.ToString() + ": " + newbar + " 查询数据库出错" + ex.Message); timed = 1000; } if (sw.Elapsed.TotalSeconds > 10 && start) { if (++ngnum > 1) { ngnum = 0; status = false; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 检测超时,2次,退出"); } else { status = true; ModelPrint("测试机" + index.ToString() + ": " + newbar + " 检测超时,1次,退出"); } start = false; timed = 2000; RecordPrint(index, "****************************", result, testerCycle, true); } } else { timed = 2000; } System.Threading.Thread.Sleep(timed); } }
async void CheckSam() { try { int ngItemCount = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Sample", "NGItemCount", "3")); int nGItemLimit = int.Parse(Inifile.INIGetStringValue(iniParameterPath, "Sample", "NGItemLimit", "99")); string MNO = Inifile.INIGetStringValue(iniParameterPath, "System", "MachineID", "X1621_1"); Oracle oraDB = new Oracle("qddb04.eavarytech.com", "mesdb04", "ictdata", "ictdata*168"); if (oraDB.isConnect()) { for (int i = 0; i < ngItemCount; i++) { for (int j = 0; j < 4; j++) { string flexid = Inifile.INIGetStringValue(iniFilepath, "A", "id" + (j + 1).ToString(), "99999"); string ngitem = Inifile.INIGetStringValue(iniParameterPath, "Sample", "NGItem" + i.ToString(), "Null"); string stm = String.Format("Select * from fluke_data WHERE FL04 = '{0}' AND FL01 = '{1}' AND ITSDATE = '{2}' ORDER BY ITSDATE DESC, ITSTIME DESC", flexid, ngitem, DateTime.Now.ToString("yyyyMMdd")); DataSet s = oraDB.executeQuery(stm); DataTable dt = s.Tables[0]; if (dt.Rows.Count > 0) { string datestr = (string)dt.Rows[0]["ITSDATE"]; string timestr = (string)dt.Rows[0]["ITSTIME"]; if (datestr.Length == 8 && (timestr.Length == 5 || timestr.Length == 6)) { if (timestr.Length == 5) { timestr = "0" + timestr; } string datetimestr = string.Empty; datetimestr = string.Format("{0}/{1}/{2} {3}:{4}:{5}", datestr.Substring(0, 4), datestr.Substring(4, 2), datestr.Substring(6, 2), timestr.Substring(0, 2), timestr.Substring(2, 2), timestr.Substring(4, 2)); DateTime updatetime = Convert.ToDateTime(datetimestr); TimeSpan sp = updatetime - SamStart; if (sp.TotalSeconds > 0) { stm = String.Format("Select * from barsaminfo WHERE BARCODE = '{0}'", (string)dt.Rows[0]["BARCODE"]); DataSet s1 = oraDB.executeQuery(stm); DataTable dt1 = s1.Tables[0]; if (dt1.Rows.Count > 0) { try { //插入样本记录 string parnum = Inifile.INIGetStringValue(iniFilepath, "Other", "pn", "FHAPHS9"); string tres = ngitem.Length > 20 ? ngitem.Substring(0, 20) : ngitem; stm = String.Format("INSERT INTO BARSAMREC (PARTNUM,SITEM,BARCODE,NGITEM,TRES,MNO,CDATE,CTIME,SR01) VALUES ('{0}','FLUKE','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", parnum, (string)dt.Rows[0]["BARCODE"], (string)dt1.Rows[0]["NGITEM"], tres, MNO, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), flexid); oraDB.executeNonQuery(stm); string filepath = "D:\\样本记录\\样本记录" + GlobalVars.GetBanci() + ".csv"; if (!Directory.Exists("D:\\样本记录")) { Directory.CreateDirectory("D:\\样本记录"); } if (!File.Exists(filepath)) { string[] heads = { "DateTime", "PARTNUM", "SITEM", "BARCODE", "NGITEM", "TRES", "MNO", "CDATE", "CTIME", "SR01" }; Csvfile.savetocsv(filepath, heads); } string[] conte = { System.DateTime.Now.ToString(), parnum, "FLUKE", (string)dt.Rows[0]["BARCODE"], (string)dt1.Rows[0]["NGITEM"], tres, MNO, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), flexid }; Csvfile.savetocsv(filepath, conte); stm = String.Format("Select * from BARSAMREC WHERE BARCODE = '{0}'", (string)dt.Rows[0]["BARCODE"]); DataSet samtimesds = oraDB.executeQuery(stm); ModelPrint("插入样本记录 " + (string)dt.Rows[0]["BARCODE"] + " " + samtimesds.Tables[0].Rows.Count.ToString()); if (samtimesds.Tables[0].Rows.Count > nGItemLimit) { ModelPrint((string)dt.Rows[0]["BARCODE"] + "样本记录" + samtimesds.Tables[0].Rows.Count.ToString() + " > " + nGItemLimit.ToString()); sampleContent[i][j] = "Limit"; } } catch (Exception ex) { ModelPrint(ex.Message); } if (((string)dt1.Rows[0]["NGITEM"]).ToUpper() == ngitem.ToUpper()) { sampleContent[i][j] = "OK"; } else { sampleContent[i][j] = (string)dt1.Rows[0]["NGITEM"]; } } else { sampleContent[i][j] = "NoSam"; } } else { sampleContent[i][j] = "NotNew"; } } else { ModelPrint("时间格式错误"); sampleContent[i][j] = "Error"; } } else { sampleContent[i][j] = "NoRecord"; } } } //回复样本结果 ModelPrint("UpdateCheckSam"); bool resut = true; for (int i = 0; i < ngItemCount; i++) { for (int j = 0; j < 4; j++) { if (sampleContent[i][j] != "OK") { string resultString = "RestartSample;" + j.ToString() + ";" + i.ToString(); if (TestSendStatus) { await TestSentNet.SendAsync(resultString); } resut = false; } } } if (resut) { ModelPrint("EndSample"); await TestSentNet.SendAsync("EndSample"); } } else { ModelPrint("样本查询Error:数据库连接失败"); } oraDB.disconnect(); } catch (Exception ex) { ModelPrint("样本查询Error:" + ex.Message); } }