标签:计算 param ++ alt 赋值 src 实际应用 dex c#
一.基本思路整理如下:
二.封周期启动程序C#代码(部份代码)
/// <summary> /// 单个生产型号 更新周期 /// </summary> /// <param name="pdctno"></param> /// <param name="gpid"></param> /// <returns></returns> private MOD_ReturnDate BatUpdateWeek(string pdctno, int gpid) { string OutFilePath = Application.StartupPath + @"log\AutoUpdateWeek.txt"; if (File.Exists(OutFilePath)) File.Delete(OutFilePath); string Script_Path = Application.StartupPath + @"\GenesisScript.exe"; string strjob = pdctno.ToLower(); Script_Run(Script_Path, gpid, strjob, "", "Param=AutoUpdateWeek"); Stopwatch sw = new Stopwatch(); sw.Start(); MOD_ReturnDate ReturnDate; while (!File.Exists(OutFilePath)) { Thread.Sleep(1000); if (sw.ElapsedMilliseconds > 60000) //一分钟后脚本还未执行返回信息,关闭进程 { Process[] arrayProcess = Process.GetProcesses(); foreach (Process p in arrayProcess) { if (p.ProcessName.ToLower() == "genesisscript") { p.Kill(); } } break; } } sw.Stop(); string errinfo = ""; if (File.Exists(OutFilePath)) { string AutoUpdateWeekJSON = File.ReadAllText(OutFilePath); ReturnDate = JsonHelper.DeserializeJsonToObject<MOD_ReturnDate>(AutoUpdateWeekJSON); } else { errinfo = "超时"; ReturnDate = new MOD_ReturnDate() { JobName = strjob, tgzJOBname = "", State = 0, ReturnInfo = errinfo }; } return ReturnDate; } /// <summary> /// 启动循环遍历 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Click(object sender, EventArgs e) { string[] jobList = {"A0001A0", "A0001A1" }; //手动赋值,在实际应用:这里数据应该是从DB数据库,由MES过数触发写入, foreach (var item in jobList) { int pid = getPIDonly(); if (pid > -1) { MOD_ReturnDate ReturnDate = BatUpdateWeek(item, pid); } else { MessageBox.Show("未检测到G启动"); break; } } }
三.更新周期脚本C#代码(部份代码)
/// <summary> /// 自动调TGZ更新周期 /// </summary> /// <param name="JOBname"></param> /// <param name="ReturnInfo"></param> /// <param name="ParentTechName">外层干膜|阻焊|字符 填写其中一个或者不填检测全部</param> /// <returns>1成功 0失败(异常) -1不存在周期</returns> public static int AutoUpdateWeekScript(string JOBname, ref string tgzJOBname, ref string ReturnInfo, string ParentTechName = "") { string WeekFormat = ""; //WWYY YYWW等 string WeekFormatNum = "";//2618 1826 等 int isOK = 0; isOK = AutoUpdateWeek.getWeekFormat(JOBname, ref WeekFormat, ref ReturnInfo, ParentTechName); //抓取流程指示 周期格式 if (isOK == 1) { isOK = InputTGZ(JOBname, ref tgzJOBname, ref ReturnInfo);//导入TGZ if (isOK == 1) { int AddDay = 0;//延后封周期天数 DateTime CurrentDateWeekTime = getDateTimeNow(JOBname, ref AddDay);//获取封周期时间 WeekFormatNum = AutoUpdateWeek.getWeek(CurrentDateWeekTime, WeekFormat, AddDay); string job = tgzJOBname; isOK = AutoUpdateWeek.UpdateWeekScript(job, WeekFormatNum, ref ReturnInfo); //UI 更新genesis JOB 周期 (处理当前Job,处理后不关闭Job窗口) if (isOK == 1) { g.COM($"check_inout,mode=out,type=job,job={job}"); g.COM($"save_job,job={job},override=no"); string OutDir = "E:/work/" + job + "/"; if (!Directory.Exists(OutDir)) Directory.CreateDirectory(OutDir); g.COM($"export_job,job={job},path={OutDir},mode=tar_gzip,submode=full,overwrite=yes"); } g.COM($"check_inout,mode=in,type=job,job={job}"); g.COM($"close_job,job={job}"); g.COM($"close_form,job={job}"); g.COM($"close_flow,job={job}"); } } return isOK; //1成功 0失败(异常) -1不存在周期 } /// <summary> /// UI 更新genesis JOB 周期 (处理当前Job,处理后不关闭Job窗口) /// </summary> /// <param name="JOBname"></param> /// <param name="WeekFormatNum"></param> /// <param name="ReturnInfo"></param> /// <returns></returns> public static int UpdateWeekScript(string JOBname, string WeekFormatNum, ref string ReturnInfo) { if (string.IsNullOrEmpty(WeekFormatNum)) { ReturnInfo = "周期未计算,不允许执行"; return 0; } job job_ = new G_Helper.job(); step step_ = new G_Helper.step(JOBname); List<string> SETstepList = new List<string> { "cam", "set" }; List<string> stepList = job_.get_step_list(JOBname).Where(tt => SETstepList.IndexOf(tt) > -1).ToList(); List<string> layerList = new List<string>(); if (stepList.Count > 0) { layerList = step_.get_layer_list(stepList[0]).Where(tt => tt.StartsWith("datecode")).ToList(); } int WeekLength = WeekFormatNum.Length; int UpdateDateCodeLayerNum = 0; bool WeekLengthDiff = false; string UpdateDateCodeStr = "周期更新信息\r\n"; if (layerList.Count > 0) { foreach (var stepname_ in stepList) { bool isStepUpdate = false; step_.open_step(stepname_); foreach (var layername in layerList) { g.COM($"display_layer,name={layername},display=yes,number=1"); g.COM($"work_layer,name={layername}"); g.COM("filter_reset,filter_name=popup"); g.COM("adv_filter_set,filter_name=popup,update_popup=yes,fontname=datecode"); g.COM("adv_filter_set,filter_name=popup,update_popup=no,txt_types=string"); g.COM("filter_area_strt"); g.COM("filter_area_end,layer=,filter_name=popup,operation=select,area_type=none,inside_area=no,intersect_area=no"); int datecodeCount = int.Parse(g.COM(g._get_select_count)); //datecode字体个数 if (datecodeCount > 0) { g.COM("clear_highlight"); g.COM("sel_clear_feat"); g.COM($"adv_filter_set,filter_name=popup,update_popup=yes,str_len=yes,min_str_len={WeekLength},max_str_len={WeekLength}"); g.COM("filter_area_strt"); g.COM("filter_area_end,layer=,filter_name=popup,operation=select,area_type=none,inside_area=no,intersect_area=no"); int datecodeWeekLengthCount = int.Parse(g.COM(g._get_select_count));//datecode字体且长度相同个数 if (datecodeWeekLengthCount > 0 && datecodeWeekLengthCount == datecodeCount) { g.COM("sel_change_txt,text=" + WeekFormatNum); UpdateDateCodeStr = UpdateDateCodeStr + $"Step名:{stepname_} Layer名:{layername} 成功 \r\n"; UpdateDateCodeLayerNum++; isStepUpdate = true; } else if (datecodeWeekLengthCount > 0 && datecodeWeekLengthCount != datecodeCount) { UpdateDateCodeStr = UpdateDateCodeStr + $"Step名:{stepname_} Layer名:{layername} 失败(多种周期长度) \r\n"; WeekLengthDiff = true; } else { UpdateDateCodeStr = UpdateDateCodeStr + $"Step名:{stepname_} Layer名:{layername} 失败(周期长不致) \r\n"; WeekLengthDiff = true; } } g.COM("filter_reset,filter_name=popup"); } if (!isStepUpdate) { step_.close_step(); } } } else { ReturnInfo = "未检测datecode层,无法更新周期"; return 0; } if (UpdateDateCodeLayerNum > 0 && !WeekLengthDiff) { ReturnInfo = UpdateDateCodeStr; return 1; } else if (WeekLengthDiff) { ReturnInfo = "datecode字体长度与更新周期字体长度不一致\r\n" + UpdateDateCodeStr; return 0; } else { ReturnInfo = "未检测datecode字体,无法更新周期"; return 0; } }
标签:计算 param ++ alt 赋值 src 实际应用 dex c#
原文地址:https://www.cnblogs.com/pcbren/p/9235766.html