/// <summary> /// 获取Capture(获取拍摄数据)处理结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCaptureResult_Click(object sender, EventArgs e) { try { var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { PgSelectCode pg = iixServer.SvrType == SvrType.Left ? PgSelectCode.Primary : PgSelectCode.Secondary; IIXExecute.GetCaptureResult(iixServer, pg); })); } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 关闭设备 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnClose_Click(object sender, EventArgs e) { try { var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { IIXExecute.Close(iixServer); })); } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// Flash Memory全部删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFlashErase_Click(object sender, EventArgs e) { try { var res = MessageBox.Show("你确定要擦除IC里的内容吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (res != DialogResult.OK) { return; } var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { PgSelectCode pg = iixServer.SvrType == SvrType.Left ? PgSelectCode.Primary : PgSelectCode.Secondary; IIXExecute.EraseFlashMemory(iixServer, pg); })); } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 点亮屏幕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPanelOn_Click(object sender, EventArgs e) { try { var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } if (iixServer.SvrType == SvrType.Right) { tasks.Add(Task.Factory.StartNew(() => { IIXExecute.PanelOn(iixServer, PgSelectCode.Primary); })); } } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 调整 slave pc 时间 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdjustTime_Click(object sender, EventArgs e) { try { if (MessageBox.Show("确定调整Slave PC 时间吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var tasks = new List <Task>(); this.dtpAdjustTime.CustomFormat = "yyyy-MM-dd HH:mm:ss"; DateTimeInfo dtInfo = new DateTimeInfo(this.dtpAdjustTime.Value); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { IIXExecute.AdjustPCTime(iixServer, dtInfo); })); } Task.WaitAll(tasks.ToArray()); } } catch (Exception ex) { Log.GetInstance().ErrorWrite("系统错误,请查询日志文件检查。"); Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 修改License /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLicenseFile_Click(object sender, EventArgs e) { try { using (OpenFileDialog dialog = new OpenFileDialog()) { if (!string.IsNullOrWhiteSpace(this.txtLicenseFile.Text)) { string fileDir = Path.GetDirectoryName(this.txtLicenseFile.Text); if (Directory.Exists(fileDir)) { dialog.InitialDirectory = fileDir; } dialog.FileName = Path.GetFileName(this.txtLicenseFile.Text); } dialog.Title = "Select License file."; dialog.Filter = string.Format("key pack file(*.{0})|*.{0}", "keys"); dialog.Filter += string.Format("|{0} file(*.{0})|*.{0}", "key"); dialog.Filter += "|All file(*.*)|*.*"; dialog.FileName = Path.GetFileName(this.txtLicenseFile.Text); if (dialog.ShowDialog() != DialogResult.OK) { return; } this.txtLicenseFile.Text = dialog.FileName; if (MessageBox.Show("确定更新License吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { IIXExecute.UpdateLicense(iixServer, dialog.FileName); })); } Task.WaitAll(tasks.ToArray()); } } } catch (Exception ex) { Log.GetInstance().ErrorWrite("系统错误,请查询日志文件检查。"); Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 向Flash Memory写入文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFlashWrite_Click(object sender, EventArgs e) { try { FormWriteFlashMemory formWriteFlashMemory = new FormWriteFlashMemory(); if (formWriteFlashMemory.ShowDialog() == DialogResult.OK) { string fileName = ""; this.txtFlashWrite.Text = formWriteFlashMemory.FilePath; if (formWriteFlashMemory.FilePath == null || formWriteFlashMemory.FilePath == "") { Log.GetInstance().WarningWrite("File name is empty"); return; } if (!File.Exists(formWriteFlashMemory.FilePath)) { Log.GetInstance().WarningWrite("File does not exist.path:" + formWriteFlashMemory.FilePath); return; } fileName = Path.GetFileName(formWriteFlashMemory.FilePath); var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { tasks.Add(Task.Factory.StartNew(() => { if (formWriteFlashMemory.IsUploadFile) { fileName = UploadFileByFtp(formWriteFlashMemory.FilePath, iixServer.Ip); } if (fileName == "") { return; } PgSelectCode pg = iixServer.SvrType == SvrType.Left ? PgSelectCode.Primary : PgSelectCode.Secondary; IIXExecute.WriteFlashMemory(iixServer, pg, fileName); })); } Task.WaitAll(tasks.ToArray()); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 获取Recipe /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGetRecipeFile_Click(object sender, EventArgs e) { try { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Save folder of recipe file."; if (!string.IsNullOrWhiteSpace(this.txtGetRecipeFile.Text) && (Directory.Exists(this.txtGetRecipeFile.Text))) { dialog.SelectedPath = this.txtGetRecipeFile.Text; } if (dialog.ShowDialog() == DialogResult.OK) { this.txtGetRecipeFile.Text = dialog.SelectedPath; var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { IIXExecute.GetRecipe(iixServer, dialog.SelectedPath); })); } Task.WaitAll(tasks.ToArray()); } } } catch (Exception ex) { Log.GetInstance().ErrorWrite("系统错误,请查询日志文件检查。"); Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 熄灭屏幕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPanelOff_Click(object sender, EventArgs e) { try { var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } if (iixServer.SvrType == SvrType.Right) { tasks.Add(Task.Factory.StartNew(() => { if (IIXExecute.PanelOff(iixServer, PgSelectCode.Primary) == CmdResultCode.Success) { Log.GetInstance().NormalWrite(string.Format("屏幕[{0}]Demura作业成功", iixServer.AssociatedPanelPos)); } else { Log.GetInstance().ErrorWrite(string.Format("屏幕[{0}]Demura作业失败", iixServer.AssociatedPanelPos)); } })); } } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 设置Panel显示Raster图像 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSetRaster_Click(object sender, EventArgs e) { try { FormImageColor formImageColor = new FormImageColor(); if (formImageColor.ShowDialog() == DialogResult.OK) { Color color = formImageColor.Color; this.txtSetRaster.Text = string.Format("R:{0:D3}, G:{1:D3}, B:{2:D3}", color.R, color.G, color.B); this.pnlColor.BackColor = color; var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { PgSelectCode pg = iixServer.SvrType == SvrType.Left ? PgSelectCode.Primary : PgSelectCode.Secondary; IIXExecute.SetRasterImage(iixServer, pg, color, formImageColor.IsFactory); })); } Task.WaitAll(tasks.ToArray()); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
/// <summary> /// 加载当前项目信息 /// </summary> private bool LoadProduct() { try { if (MoveExecute.LoadSettings(Global.ProductName)) { Log.GetInstance().NormalWrite("加载项目配置文件配置成功。"); } else { Log.GetInstance().ErrorWrite("加载项目配置文件配置失败。"); return(false); } var currentProductPath = Path.Combine(Application.StartupPath + "\\Product", Global.ProductName); var fileName = Global.IsExistFileBySuffixName(currentProductPath, ".bin"); if (fileName == "") { Log.GetInstance().ErrorWrite(string.Format("目录 '{0}' 下没有找到该项目的bin文件,切换项目失败。", currentProductPath)); return(false); } /// ///设置Recipe /// var tasks = new List <Task>(); CmdResultCode cmdRes; bool f = false; foreach (var iixServer in Global.ListIIXSerevr) { if (iixServer.IsEnable == false) { continue; } tasks.Add(Task.Factory.StartNew(() => { cmdRes = IIXExecute.SetRecipe(iixServer, Path.Combine(currentProductPath, fileName)); if (cmdRes != CmdResultCode.Success) { f = false; } })); } Task.WaitAll(tasks.ToArray()); if (!f) { Log.GetInstance().ErrorWrite(string.Format("设置Recipe失败,请重启软件。")); return(false); } //修改配置文件中当前项目名 IniFile.IniWriteValue("Product", "ProductName", Global.ProductName, Global.ConfigPath); //修改主界面项目名 return(true); } catch (Exception ex) { Log.GetInstance().ErrorWrite("系统错误,请查询日志文件检查。"); Log.WriterExceptionLog(ex.ToString()); return(false); } }
/// <summary> /// 初始化IIX服务端 /// </summary> /// <returns></returns> private bool InitIIXServer() { bool f = false; try { IIXServer iixServer = null; CmdResultCode cmdRes = CmdResultCode.Other; #region Ted modified 20180522 foreach (SlaveGroup slaveGroup in stationConfig.SlaveGroups) { foreach (Slave slave in slaveGroup.Slaves) { int index = this.dgvServer.Rows.Add(); iixServer = new IIXServer(); iixServer.DmrSvrApi = new IixDmrSvrApi(); iixServer.Ip = slave.ip; iixServer.IsEnable = slave.enable; iixServer.AssociatedPanelPos = slave.description; //iixServer.SvrType = SvrType.Left; this.SetEventHandlers(iixServer); DataGridViewRow row = this.dgvServer.Rows[index]; row.Cells["Enable"].Value = slave.enable; row.Cells["ServerIP"].Value = slave.ip; row.Cells["ServerPort"].Value = iixServer.Port; row.Cells["Open"].Value = iixServer.ConnState.ToString(); row.Cells["PgPrimary"].Value = iixServer.OutlineState[0].ToString(); row.Cells["PgSecondary"].Value = iixServer.OutlineState[1].ToString();; row.Cells["Status"].Value = iixServer.ResultState.ToString(); row.Cells["LatestResult"].Value = iixServer.LatestResult; Global.ListIIXSerevr.Add(iixServer); } } //for (int i = 1; i <= 3; i++) //{ // int index = this.dgvServer.Rows.Add(); // iixServer = new IIXServer(); // string ip = IniFile.IniReadValue(string.Format("ServerLeft#" + i), "IP", Global.ConfigPath); // bool isEnable = IniFile.IniReadValue(string.Format("ServerLeft#" + i), "IsEnable", Global.ConfigPath) == "1" ? true : false; // iixServer.DmrSvrApi = new IixDmrSvrApi(); // iixServer.Ip = ip; // iixServer.IsEnable = isEnable; // iixServer.AssociatedPanelPos = "#" + i; // iixServer.SvrType = SvrType.Left; // this.SetEventHandlers(iixServer); // this.dgvServer.Rows[index].Cells["Enable"].Value = isEnable; // this.dgvServer.Rows[index].Cells["ServerIP"].Value = ip; // this.dgvServer.Rows[index].Cells["ServerPort"].Value = iixServer.Port; // this.dgvServer.Rows[index].Cells["Open"].Value = iixServer.ConnState.ToString(); // this.dgvServer.Rows[index].Cells["PgPrimary"].Value = iixServer.OutlineState[0].ToString(); // this.dgvServer.Rows[index].Cells["PgSecondary"].Value = iixServer.OutlineState[1].ToString(); ; // this.dgvServer.Rows[index].Cells["Status"].Value = iixServer.ResultState.ToString(); // this.dgvServer.Rows[index].Cells["LatestResult"].Value = iixServer.LatestResult; // Global.ListIIXSerevr.Add(iixServer); //} //for (int i = 1; i <= 3; i++) //{ // int index = this.dgvServer.Rows.Add(); // iixServer = new IIXServer(); // string ip = IniFile.IniReadValue(string.Format("ServerRight#" + i), "IP", Global.ConfigPath); // bool isEnable = IniFile.IniReadValue(string.Format("ServerRight#" + i), "IsEnable", Global.ConfigPath) == "1" ? true : false; // iixServer.DmrSvrApi = new IixDmrSvrApi(); // iixServer.Ip = ip; // iixServer.IsEnable = isEnable; // iixServer.AssociatedPanelPos = "#" + i; // iixServer.SvrType = SvrType.Right; // this.SetEventHandlers(iixServer); // this.dgvServer.Rows[index].Cells["Enable"].Value = isEnable; // this.dgvServer.Rows[index].Cells["ServerIP"].Value = ip; // this.dgvServer.Rows[index].Cells["ServerPort"].Value = iixServer.Port; // this.dgvServer.Rows[index].Cells["Open"].Value = iixServer.ConnState.ToString(); // this.dgvServer.Rows[index].Cells["PgPrimary"].Value = iixServer.OutlineState[0].ToString(); // this.dgvServer.Rows[index].Cells["PgSecondary"].Value = iixServer.OutlineState[1].ToString(); ; // this.dgvServer.Rows[index].Cells["Status"].Value = iixServer.ResultState.ToString(); // this.dgvServer.Rows[index].Cells["LatestResult"].Value = iixServer.LatestResult; // Global.ListIIXSerevr.Add(iixServer); //} #endregion var tasks = new List <Task>(); foreach (var _iixServer in Global.ListIIXSerevr) { tasks.Add(Task.Factory.StartNew(() => { //连接 cmdRes = IIXExecute.ConnectToSlave(_iixServer); //连接成功后就打开 if (cmdRes == CmdResultCode.Success) { Log.WriterActionLog(string.Format("Slave {0}:{1} connected SUCCESS!", _iixServer.Ip, _iixServer.Port)); cmdRes = IIXExecute.Open(_iixServer); if (cmdRes == CmdResultCode.Success) { Log.WriterActionLog(string.Format("Slave {0}:{1} open SUCCESS!", _iixServer.Ip, _iixServer.Port)); } else { Log.WriterExceptionLog(string.Format("Slave {0}:{1} open FAIL!", _iixServer.Ip, _iixServer.Port)); } } else { Log.WriterExceptionLog(string.Format("Slave {0}:{1} connected FAIL!", _iixServer.Ip, _iixServer.Port)); } })); } Task.WaitAll(tasks.ToArray()); f = true; } catch (Exception ex) { f = false; Log.WriterExceptionLog(ex.ToString()); } return(f); }