private void OnClickConfrim(object sender, RoutedEventArgs e) { //参数检查 if (!CheckArgs()) { return; } //格式化数据 RobotInfo info = new RobotInfo(); info.Id = Convert.ToInt32(TBAddID.Text.ToString()); info.EndPoint = TBIP.Text.ToString() + ":" + TBPort.Text.ToString(); info.NetId = 0; info.NetState = false; info.Fts = TBIP.Text.ToString() + ":" + "4411"; List <RobotInfo> list = new List <RobotInfo>(); list.Add(info); //接口调用写入XML if (!RobotInfoCollect.GetInstance().AppendRobotInfo(list)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "添加信息失败", "提示"); return; } //刷新界面 Tool.RobotsHome.RobotsHome.This.Refresh(); Tool.CarHouse.CartHousePage.This.Refresh(); TipsMessageEx.ShowTips(Tool.MainWindow.This, "添加信息成功", 18, 5, Colors.Green); CloseWid(); }
private void OnClickConfrim(object sender, RoutedEventArgs e) { //检查输入参数 if (!CheckArgs()) { CloseWid(); return; } RobotInfo info = new RobotInfo(); string str = TBIPv4.Text.ToString() + ":" + TBPort.Text.ToString(); info.EndPoint = str; info.Id = Convert.ToInt32(TBName.Text.ToString()); //更新XML文件 if (!Tool.RobotsHome.RobotInfoCollect.GetInstance().UpdateRobotInfo(infoCur, info)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "修改失败请重试!", "错误"); CloseWid(); return; } TipsMessageEx.ShowTips(Tool.MainWindow.This, "修改成功", 18, 5, Colors.Green); CloseWid(); }
private void OnClickPreview(object sender, RoutedEventArgs e) { if (!CheckBatchArgs()) { return; } string strIp = TBBatchIP.Text.ToString(); var array_ip = strIp.Split('.'); uint ipv4_1 = 0; uint ipv4_2 = 0; uint ipv4_3 = 0; uint ipv4_4 = 0; try { ipv4_1 = UInt32.Parse(array_ip[0]); ipv4_2 = UInt32.Parse(array_ip[1]); ipv4_3 = UInt32.Parse(array_ip[2]); ipv4_4 = UInt32.Parse(array_ip[3]); } catch (Exception) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "输入正确的ip格式", "错误"); return; } BatchProduce(Convert.ToInt32(TBBatchNum.Text), Convert.ToInt32(TBBatchAddID.Text), TBBatchPort.Text.ToString(), ipv4_1, ipv4_2, ipv4_3, --ipv4_4); PreviewRobotList.Items.Refresh(); }
private void OnUpdate(object sender, MouseButtonEventArgs e) { Tool.XControl.ImageButton Btn = sender as Tool.XControl.ImageButton; string fts_ep = Btn.Tag.ToString(); if (null == fts_ep) { return; } var fw = sender as FrameworkElement; if (null == fw) { return; } var info = fw.DataContext as Tool.RobotsHome.RobotInfo; //固件升级中状态进行中或者重启中,直接返回。 if (1 == info.BinStatus || 2 == info.BinStatus) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "正在操作中,请稍后再试", "错误"); return; } if (UpdateCore(fts_ep, false) < 0) { return; } TipsMessageEx.ShowTips(Tool.MainWindow.This, "正在更新固件。。。", 18, 5, Colors.Green); }
private void OnDeleteProcess(object sender, RoutedEventArgs e) { Tool.XControl.XButton Btn = sender as Tool.XControl.XButton; string id = Btn.Tag.ToString(); MessageBoxResult Result = NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "确定要删除此进程?", "提示", MessageBoxButton.YesNo); if (Result == MessageBoxResult.No) { return; } if (!ProcessInfoCollect.GetInstance().RemoveProcess(Convert.ToInt32(id))) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "删除失败!", "错误"); return; } if (UpdateProcessInfo() < 0) { return; } Refresh(); }
public void SendFile() { if (SelectList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要发送的IP!", "错误"); return; } if (FileList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要发送的为文件!", "错误"); return; } int retval = Tool.FileHandle.FTS.PushFiles(SelectList, FileList, ToDir); if (retval < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "发送文件失败!", "错误"); return; } TipsMessageEx.ShowTips(Tool.MainWindow.This, "已经加入传输列表", 20, 5, Colors.Green); dcContent.Collection.ToList().ForEach(p => p.IsSelected = false); SelectList.Clear(); Task.Run(() => { this.Dispatcher.Invoke(() => { Close(); }); }); }
private void OnDownLoad(object sender, MouseButtonEventArgs e) { Tool.XControl.ImageButton Btn = sender as Tool.XControl.ImageButton; string net_id = Btn.Tag.ToString(); if (null == net_id) { return; } System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog(); folder.ShowDialog(); if ("" == folder.SelectedPath) { return; } if (DownLoadCore(net_id, folder.SelectedPath) < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请先选择目标文件", "错误"); return; } TipsMessageEx.ShowTips(Tool.MainWindow.This, "正在下载固件。。。", 18, 5, Colors.Green); }
//文件重传 private void OnRepeatTransfrom(object sender, RoutedEventArgs e) { if (SelectFileList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要重传的文件!", "提示"); return; } string dirList = null; foreach (string dir in SelectFileList) { if (dir == null) { continue; } dirList += dir + "|"; } int retval = NetInterface.NetRepeatFilesToRemote(Taskid, dirList, dirList.Length); if (retval < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "重传失败", "错误"); return; } TipsMessageEx.ShowTips(Tool.MainWindow.This, "任务继续,请稍后。。。", 18, 5, Colors.Green); dcContent.Collection.ToList().ForEach(p => p.IsFileSelected = false); SelectFileList.Clear(); FilesCheckBox.IsChecked = false; }
/////////////////////重新获取软件版本信息////////////////////////// private int RefreshInfomtion(string net_id) { if ("" == FirmPath || "" == FirmEndPoint) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请先选择目标文件", "错误"); return(-1); } string id = TB_NodeId.Text.ToString(); string can_bus = ComboxNodeMode.Text; int node_id; int can_bus_type; if (id == string.Empty) { node_id = 0; } else { node_id = Convert.ToInt32(id); } if (can_bus == string.Empty) { can_bus_type = 0; } else { can_bus_type = Convert.ToInt32(can_bus); } return(NetInterface.NetGetBinDetailInfo(net_id, FirmwareType, FirmEndPoint, node_id, can_bus_type)); }
private void OnStopProcess(object sender, RoutedEventArgs e) { if (0 == ProcessCheckObj.Count) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要操作的进程", "错误"); return; } string id_list = ""; foreach (var id in ProcessCheckObj) { id_list += id; id_list += "|"; } string netid_list = ""; foreach (var id in RobotList) { netid_list += id; netid_list += "|"; } if (NetInterface.NetPostCodeAgvProcess(netid_list, id_list, Tool.RobotsHome.CmdAgvShell.cmd_stop_process) < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "停止失败", "错误"); } TipsMessageEx.ShowTips(Tool.MainWindow.This, "停止请求发送成功", 18, 3, Colors.Green); RobotList.Clear(); dcRobotInfo.Collection.ToList().ForEach(p => p.IsSelectedProcess = false); AllObj.IsChecked = false; }
private void OnClickAdd(object sender, RoutedEventArgs e) { string path = TBPath.Text.ToString(); if (path.Length > 250) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "路径太长", "提示"); return; } if (path.Trim() == string.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入软件路径", "提示"); return; } string arg = TBArg.Text.ToString(); if (arg.Length > 250) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "启动参数太长", "提示"); return; } string time = TBDeplyTime.Text.ToString().Trim(); if (time.Length > 4) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "延迟时间太长,小于1000", "提示"); return; } if (time.Trim() == string.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入延迟时间", "提示"); return; } ProcessObjInfo info = new ProcessObjInfo(); info.Name = ""; info.Path = path; info.Arg = arg; info.DelayTime = Convert.ToInt32(time); if (!ProcessInfoCollect.GetInstance().AddProcess(info)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "添加失败!", "错误"); return; } Tool.ProcessConfig.WinProcessDetail.This.Refresh(); Tool.ProcessConfig.WinProcessDetail.This.UpdateProcessInfo(); this.Dispatcher.Invoke(() => { Close(); }); }
private void OnPreviewTextInput(object sender, TextCompositionEventArgs e) { Regex re = new Regex("[^0-9.-]+"); e.Handled = re.IsMatch(e.Text); if (e.Handled) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "输入的必须是数字", "错误"); return; } }
//传输详情 private void OnMouseCheckFileDetail(object sender, MouseButtonEventArgs e) { TextBlock tb = sender as TextBlock; List <TaskFileDetailInfo> list = new List <TaskFileDetailInfo>(); string str = tb.Tag.ToString(); int retval = NetInterface.NetGetPushFilesDetailInfo(Convert.ToUInt64(str), ref list); if (retval < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "获取文件详情失败!", "错误"); return; } TransFromDetailInfoWid.Show(this, Convert.ToUInt64(str), list); }
private void OnClickCloseWid(object sender, RoutedEventArgs e) { e.Handled = true; MessageBoxResult Result = NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "确认是否退出?", "提示", MessageBoxButton.YesNo); if (Result == MessageBoxResult.No) { return; } Task.Run(() => { this.Dispatcher.Invoke(() => { Close(); }); }); }
//检查文件大小 private bool CheckFileSize(string path) { if ("" == path) { return(false); } FileInfo fi = new FileInfo(path); if (fi.Length > (1024 * 1024)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件大于1M,无法显示", "提示"); return(false); } return(true); }
//应用多车 public void AppToHost(List <RobotOnlineInfo> Robotlist) { if (SelectLocalList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请先选择需要发送的文件!", "错误"); return; } if (Robotlist.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "当前无在线车辆!", "错误"); return; } SelectAGVWindow.Show(This, Robotlist, SelectLocalList, WorkMode.SendFile, DirRelative); }
private void OnUpProcess(object sender, RoutedEventArgs e) { Tool.XControl.XButton Btn = sender as Tool.XControl.XButton; string id = Btn.Tag.ToString(); if (!ProcessInfoCollect.GetInstance().SortUPProcess(Convert.ToInt32(id))) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "调准顺序失败!", "错误"); return; } if (UpdateProcessInfo() < 0) { return; } Refresh(); }
/////////////////////更新自主驱动////////////////////////// private int UpdateDriver(string fts_ep, string driver_id, bool isBatch = false) { if (!isBatch) { if (!File.Exists(FirmPath)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件不存在!", "错误"); return(-1); } } if ("" == FirmPath || "" == FirmEndPoint) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请先选择目标文件", "错误"); return(-1); } return(NetInterface.NetPushCanBinFile(fts_ep, Convert.ToInt32(driver_id), Convert.ToInt32(DriverMode), FirmPath, FirmEndPoint)); }
private void OnClickCloseWid(object sender, RoutedEventArgs e) { e.Handled = true; MessageBoxResult isSave = MessageBoxResult.No; if (IsChanged) { string str = string.Format("文件已修改,请确认是否保存?"); isSave = NotifyMessageEx.ShowNotify(Tool.MainWindow.This, str, "提示", System.Windows.MessageBoxButton.YesNo); if (isSave == MessageBoxResult.Yes) { SaveFile(); } } this.Dispatcher.Invoke(() => { Close(); }); Tool.P2PConfig.List2List.This.RefreshFileList(); }
private void OnUpdateBatch(object sender, RoutedEventArgs e) { if (!File.Exists(FirmPath)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件不存在!", "错误"); return; } foreach (string fts_ep in SelectFTSList) { int retval = Tool.RobotsHome.RobotInfoCollect.GetInstance().FindBinStatusByFTS(fts_ep); if (1 == retval || 2 == retval) { continue; } UpdateCore(fts_ep, true); } }
private bool CheckArgs() { //IP或者域名校验 if (TBIPv4.Text.ToString().Length <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "IP不能为空!", "错误"); return(false); } if (!CheckIP(TBIPv4.Text.ToString())) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请正确的IP格式,例如192.168.255.255", "错误"); return(false); } //端口校验 if (TBPort.Text.ToString().Length <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "端口不能为空!", "错误"); return(false); } int id; if (!isNumberic(TBPort.Text.ToString(), out id)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "端口必须为纯数字!", "错误"); return(false); } //编号校验 if (TBName.Text.ToString().Length <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "编号不能为空!", "错误"); return(false); } if (!isNumberic(TBName.Text.ToString(), out id)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "编号必须为纯数字!", "错误"); return(false); } return(true); }
private bool CheckArgs() { string strId = TBAddID.Text.ToString(); int id; if (!isNumberic(strId, out id)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "编号必须为纯数字!", "错误"); return(false); } string strIp = TBIP.Text.ToString(); var array_ip = strIp.Split('.'); if (array_ip.Length != 4) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请正确的IP格式,例如192.168.1.1", "错误"); return(false); } if (!CheckIP(strIp)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请正确的IP格式,例如192.168.1.1", "错误"); return(false); } string strPort = TBPort.Text.ToString(); int port; if (!isNumberic(strPort, out port)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "编号必须为纯数字!", "错误"); return(false); } if (port > 65536 || port < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "端口范围:0-65536!", "错误"); return(false); } return(true); }
private void InitLocalFile(string path) { string text = ""; if (File.Exists(path)) { this.WaitEvent(() => { text = InitFile(path); }); if (null == text) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "读取标准文件错误", "提示"); return; } TBLocal.Text = text; } }
//AGV车载文件下载到本地 private void OnClickDownLoadFile(object sender, RoutedEventArgs e) { List <TransFilesInfo> tmpList = new List <TransFilesInfo>(); CheckSelFileList(ref tmpList); if (0 == tmpList.Count) { return; } System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog(); folder.ShowDialog(); if (folder.SelectedPath == string.Empty) { return; } int retval = -1; this.Dispatcher.Invoke(() => { this.WaitEvent(() => { unsafe { retval = Tool.FileHandle.FTS.DownLoadFile(EP, tmpList, folder.SelectedPath); } }, true, true); }); if (retval < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "下载文件失败!", "错误"); return; } NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "下载文件完成", "提示"); SelectRemoteList.Clear(); dcRemote.Collection.ToList().ForEach(p => p.IsSelectedRemote = false); AllRemoteFilesCheckBox.IsChecked = false; }
private void OnMenuEditFile(object sender, RoutedEventArgs e) { if (!BtnAdd.IsEnabled) { return; } if (null == PointItem) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要编辑的车辆", "提示"); return; } if (((Tool.RobotsHome.RobotInfo)(PointItem)).NetState) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "该车已经连接无法编辑", "提示"); return; } CarEditWin.Show(Tool.MainWindow.This, ((Tool.RobotsHome.RobotInfo)PointItem)); }
private void OnUpdateDriverBatch(object sender, RoutedEventArgs e) { if (!File.Exists(FirmPath)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件不存在!", "错误"); return; } string id = TB_NodeId.Text.ToString(); if (id == string.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入节点ID", "错误"); return; } foreach (string fts_ep in SelectFTSList) { UpdateDriver(fts_ep, id, true); } }
public void InitAGV() { if (SelectList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要发送的IP!", "错误"); return; } string epList = null; foreach (string ep in SelectList) { if (ep == null) { continue; } epList += ep + "|"; } int retval = -1; this.Dispatcher.Invoke(() => { this.WaitEvent(() => { retval = NetInterface.NetInitFactorySetting(epList, fn_init_agv_t_); }); }); if (retval < 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "初始化失败", "错误"); return; } dcContent.Collection.ToList().ForEach(p => p.IsSelected = false); SelectList.Clear(); TipsMessageEx.ShowTips(Tool.MainWindow.This, "初始化结束", 20, 5, Colors.Green); this.Dispatcher.Invoke(() => { Close(); }); }
private void OnClickSend(object sender, RoutedEventArgs e) { string msg = TBMSG.Text.ToString(); if (msg == String.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入脚本", "提示"); return; } Tool.Proto.ProtoMSG protomsg = new Proto.ProtoMSG(); protomsg.MSG.value_ = msg; byte[] b_msg = new byte[protomsg.length()]; Int32 offset = 0; protomsg.serialize(b_msg, ref offset); var array_ip = RobotList.Split('|'); foreach (string robot_id in array_ip) { if (robot_id == String.Empty) { continue; } unsafe { fixed(byte *l_msg = b_msg) { NetInterface.NetPostAsyncPackage(Convert.ToInt32(robot_id), (int)NetInterface.PKTTYPE.kAgvShellProto_RunScript, l_msg, protomsg.length()); } } } TipsMessageEx.ShowTips(Tool.MainWindow.This, "执行脚本完成", 18, 5, Colors.Green); Task.Run(() => { this.Dispatcher.Invoke(() => { Close(); }); }); }
private void OnRepeatTransfrom(object sender, RoutedEventArgs e) { if (SelectFileList.Count <= 0) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请选择需要重传的文件!", "提示"); return; } string dirList = null; foreach (string dir in SelectFileList) { if (dir == null) { continue; } dirList += dir + "|"; } NetInterface.RepeatFilesToRemote(Taskid, dirList); }
/////////////////////更新M核相机程序////////////////////////// private int UpdateCore(string fts_ep, bool isBatch = false) { if (!isBatch) { if (!File.Exists(FirmPath)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件不存在!", "错误"); return(-1); } } if ("" == FirmPath || "" == FirmEndPoint) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请先选择目标文件", "错误"); return(-1); } return(NetInterface.NetUpdateBinFiles(fts_ep, FirmwareType, FirmPath, FirmEndPoint)); }