/// <summary> /// 添加状态点到ItemPoints /// </summary> /// <param name="point"></param> public IResult AddItem(ILE.IDataPoint point) { //此处把配置文件中的数据点名拆出来,放进模型 string[] pms = point.parameter.Split(','); point.Item_name = pms[2]; ILE.LEResult res = new LEResult(); try { HaiGrang.Package.OpcNetApiChs.DaNet.RefreshEventHandler reh = new HaiGrang.Package.OpcNetApiChs.DaNet.RefreshEventHandler(this.DataChangeHandler); myRefreshGroup = new RefreshGroup(server, 500, reh); mySyncIOGroup = new SyncIOGroup(this.server); int i = myRefreshGroup.Add(point.Item_name); if (!HRESULTS.Succeeded(i)) { res.Result = false; res.ExtMessage = "新增监测点[" + point.dataPoint_name + "]失败"; this.server.Disconnect(); this.server = null; return(res); } myRefreshGroup.Remove(point.Item_name); //如果成功添加了,说明数据点可用,此时要拿出来,不能直接启动数据点。 this.ItemPoints.Add(point); res.Result = true; } catch (Exception exc) { res.Result = false; res.ExtMessage = "新增监测点失败"; } return(res); }
public IResult DoWork(IJob job, string val) { IResult res = new LEResult(); try { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); decimal decval = Convert.ToDecimal(val); if (decval > job.MaxQTY) { res.Result = false; res.ExtMessage = "批次数量超出范围"; return(res); } decimal decqty = job.MaxQTYOrder - job.QTYOrder; if (decval > decqty) { res.Result = false; res.ExtMessage = "数量超出工单剩余计划数[" + decqty.ToString() + "]"; return(res); } res.Result = true; job.QTY = int.Parse(val); job.StepList[job.StepIdx].StepValue = decval.ToString(); job.StepList[job.StepIdx].Completed = true; return(res); } catch (Exception exc) { //MessageBox.Show(exc.Message); res.Result = false; return(res); } }
/// <summary> /// 启动函数 /// </summary> /// <returns></returns> public IResult init() { OPCItemState rslt; OPCDATASOURCE dsrc = OPCDATASOURCE.OPC_DS_DEVICE; ILE.LEResult res = new LEResult(); ///将所有数据点放进RefreshGroup容器 foreach (ILE.IDataPoint po in this.ItemPoints) { if (po.business_code == "01" | po.business_code == "02") //如果是采集完成数与异常数,要把初始值拿到用于扣减 { int j = mySyncIOGroup.Read(dsrc, po.Item_name, out rslt); po.InitVal = rslt.DataValue.ToString(); } int i = myRefreshGroup.Add(po.Item_name); if (!HRESULTS.Succeeded(i)) { res.Result = false; res.ExtMessage = "新增监测点失败"; this.server.Disconnect(); this.server = null; return(res); } } //Action action = new Action(Monitor); //action.BeginInvoke(null, null); thread.Start(); res.Result = true; return(res); }
public IResult DoWork(ILE.IJob job) { DispatchForm form = new DispatchForm(job.StationCode); form.ShowDialog(); string dispatching = form.Dispetching; string orderNO = form.OrderNO; IResult result = new LEResult(); if (dispatching == null) { result.Result = false; result.ExtMessage = "未选择"; } else { job.DispatchNO = dispatching; job.Product = form.Product; job.OrderNO = orderNO; result.Result = true; ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); ILE.LEResult res = new LEResult(); string ResProduct1 = client.RunServerAPI("BLL.Product", "GetProductFlow", job.OrderNO); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct1); V_ProductFlow produc1 = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes1 = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc1.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes1); job.Pid = Convert.ToInt32(res.obj); job.StepList[job.StepIdx].Completed = true; } return(result); }
public IResult DoWork(IJob job, string val) { DispatchForm form = new DispatchForm(job.StationCode); form.ShowDialog(); string dispatching = form.Dispetching; string orderNO = form.OrderNO; string product = form.Product; IResult result = new LEResult(); if (dispatching == null) { result.Result = false; result.ExtMessage = "未选择"; } else { job.DispatchNO = dispatching; job.OrderNO = orderNO; job.Product = product; result.Result = true; ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); string ResProduct = client.RunServerAPI("BLL.Product", "GetProductFlow", orderNO); IResult res = new LEResult(); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct); job.Pid = Convert.ToInt32(res.obj); } return(result); }
public IResult DoWork(IJob job) { ServiceReference.ServiceClient clien = new ServiceReference.ServiceClient(); IResult res = new LEResult(); try { int Lot_Qty = int.Parse(job.QTY.ToString()); string Mat_code = job.StepList[job.StepIdx].Matcode.ToString(); string Product_code = job.Product.ToString(); decimal qty = decimal.Parse(clien.RunServerAPI("BLL.Product", "GetMaterialQty", Mat_code + "," + Product_code)); decimal MulQty = Lot_Qty * qty; job.StepList[job.StepIdx].StepValue = MulQty.ToString(); job.StepList[job.StepIdx].StepDetail = new List <ILE.StepData>(); ILE.StepData stepdata = new ILE.StepData(); stepdata.InPutDate = DateTime.Now; stepdata.StepVal = MulQty.ToString(); job.StepList[job.StepIdx].StepDetail.Add(stepdata); job.StepList[job.StepIdx].Completed = true; res.Result = true; } catch (Exception ex) { res.ExtMessage = "驱动加载失败,请检查工步配置"; res.Result = false; return(res); } return(res); }
public DCO(string pamater) { this.ItemPoints = new List <IDataPoint>(); thread = new System.Threading.Thread(new System.Threading.ThreadStart(Monitor)); ILE.LEResult res = new LEResult(); //用这个数据点的配置,启动OPC连接,正因如此,此处注意,无法支持一台设备存在两个OPC_server地址 string[] pmts = pamater.Split(','); strMachine = pmts[0]; //服务PC的IP地址 string strServerName = pmts[1]; //服务名 string strPointName = pmts[2]; //数据点地址名 OpcServerBrowser myBrowser = new OpcServerBrowser(strMachine); try { myBrowser.CLSIDFromProgID(strServerName, out SrvGuid); //获取OPC服务组件的注册ID,获取不到会直接报错 } catch { res.ExtMessage = "服务不存在或无法访问!"; res.Result = false; //return res; throw new Exception("服务不存在或无法访问"); } Host host = new Host(strMachine); server = new OpcServer(); host.Domain = strMachine.ToUpper(); host.HostName = strMachine; host.UserName = ""; host.Password = ""; int rtc = server.Connect(strMachine, SrvGuid); try { HRESULTS.Succeeded(rtc); //this.label1.Text = "连接成功!"; //守护线程 } catch (Exception exc) { res.Result = false; res.ExtMessage = exc.Message; this.server.Disconnect(); this.server = null; throw new Exception("服务连接失败"); } }
/// <summary> /// 该物料是否最小批次 /// </summary> /// <returns></returns> public static bool Check_Mbm(string order_no) { ILE.IResult res = new LEResult(); try { string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Check_Mbm", order_no); res = JsonConvert.DeserializeObject <LEResult>(strRes); } catch (Exception ex) { res.Result = false; res.ExtMessage = ex.ToString(); } return(res.Result); }
/// <summary> /// 派工单与工单报工 /// </summary> /// <param name="job"></param> /// <param name="cplt"></param> /// <returns></returns> public IResult DoWork(IJob job, string cplt) { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); string jsdata = client.RunServerAPI("BLL.WorkDispatching", "OrderReport", job.DispatchNO + "," + job.OrderNO + "," + cplt); ILE.LEResult rec = new LEResult(); if (jsdata != "") { rec.Result = false; rec.ExtMessage = jsdata; return(rec); } rec.Result = true; return(rec); }
/// <summary> /// 上料提交 /// </summary> /// <param name="wip_id"></param> /// <param name="point">安装点</param> /// <param name="station">工位</param> /// <param name="orderno">工单</param> /// <param name="empCode">员工</param> /// <param name="inputqty">投入数</param> /// <returns></returns> public static ILE.IResult Sumit_FeedMatToStation(int wip_id, string point, string station, string orderno, string empCode, decimal?inputqty) { ILE.IResult res = new LEResult(); try { string Array = wip_id.ToString() + "," + point + "," + station + "," + orderno + "," + empCode + "," + inputqty.ToString(); string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Sumit_FeedMatToStation", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); } catch (Exception ex) { res.Result = false; res.ExtMessage = ex.ToString(); } return(res); }
/// <summary> /// 该物料是否可以拆物料 /// </summary> /// <param name="wip_id">wip表 id号</param> /// <param name="lot">批次</param> /// <returns></returns> public static bool Check_Mat_Split(int?wip_id, string lot) { ILE.IResult res = new LEResult(); try { string Array = wip_id.ToString() + "," + lot; string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Check_Mat_Split", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); } catch (Exception ex) { res.Result = false; res.ExtMessage = ex.ToString(); } return(res.Result); }
/// <summary> /// 获取wip数据 /// </summary> /// <param name="orderno">工单</param> /// <param name="lot">批次</param> /// <returns></returns> public static ILE.IResult Get_WIP_LotInfo(string orderno, string lot) { ILE.IResult res = new LEResult(); try { string Array = orderno + "," + lot; string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Get_WIP_LotInfo", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); } catch (Exception ex) { res.Result = false; res.ExtMessage = "Get_WIP_LotInfo程序报错"; } return(res); }
/// <summary> /// 自动投料 /// </summary> /// <param name="orderno">工单</param> /// <param name="process">工序</param> /// <returns></returns> public static ILE.IResult Get_WIP_AutoSend(string orderno, string process) { ILE.IResult res = new LEResult(); try { string Array = orderno + "," + process; string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Get_WIP_AutoSend", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); } catch (Exception ex) { res.Result = false; res.ExtMessage = ex.ToString(); } return(res); }
/// <summary> /// 工单验证 /// </summary> /// <param name="process">工序</param> /// <param name="workorder">工单</param> /// <returns></returns> public static ILE.IResult Check_WIP_Work(string process, string workorder) { ILE.IResult res = new LEResult(); try { string Array = process + "," + workorder; string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Check_WIP_Work", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); } catch (Exception ex) { res.Result = false; res.ExtMessage = ex.ToString(); } return(res); }
/// <summary> /// 获取安装点 /// </summary> /// <param name="station">工站</param> /// <param name="orderNO">工单</param> /// <param name="wip_id">wip表id号</param> /// <returns></returns> public static ILE.IResult Get_WIP_Point(string station, string orderNO, int?wip_id) { ILE.IResult res = new LEResult(); try { string Array = station + "," + orderNO + "," + wip_id.ToString(); string strRes = Tools.ServiceReferenceManager.GetClient().RunServerAPI("BLL.WIP", "Get_WIP_LotInfo", Array); res = JsonConvert.DeserializeObject <LEResult>(strRes); return(res); } catch (Exception ex) { res.Result = false; res.ExtMessage = "Get_WIP_Point程序报错"; } return(res); }
public static ILE.IResult HandleJob(ILE.IJob job, string val) { string driveName = job.StepList[job.StepIdx].FileName; string path = System.IO.Directory.GetCurrentDirectory() + "\\DriveList\\" + driveName; IResult rec = new LEResult(); try { Assembly ass = Assembly.LoadFrom(path); Type type = ass.GetType(job.StepList[job.StepIdx].DriveCode + ".SPO"); //drive_code作为默认的驱动内命名空间 Object obj = Activator.CreateInstance(type); ISPO SpoObj = (ISPO)obj; if (val == null) //自动耗料 { rec = SpoObj.DoWork(job); } else { rec = SpoObj.DoWork(job, val); } } catch (Exception exp) { rec.Result = false; rec.ExtMessage = "加载工步驱动" + "[" + driveName + "]失败:" + exp.Message; return(rec); } ///如果当前被完成的STEP是关键步骤 if (rec.Result && job.Pid != 0 && job.StepList[job.StepIdx].KeyStep && !job.StepLoad) { return(Component.JobConstructor.FillJobStep(job)); } string i = rec.ExtMessage; return(rec); }
public static IResult GetTPO(string drive_code, string param) { string path = System.IO.Directory.GetCurrentDirectory() + "\\TPDriveList\\" + drive_code + ".dll"; IResult rec = new LEResult(); try { Assembly ass = Assembly.LoadFrom(path); Type type = ass.GetType(drive_code + ".TPO"); Object obj = Activator.CreateInstance(type, new object[] { param }); ITPO SpoObj = (ITPO)obj; SpoObj.Driver_code = drive_code; rec.Result = true; rec.obj = SpoObj; return(rec); } catch (Exception exp) { rec.Result = false; rec.ExtMessage = "加载任务驱动" + "[" + drive_code + "]失败:" + exp.Message; return(rec); } }
public IResult DoWork(IJob job, string val) { IResult res = new LEResult(); try { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); string jsdata = client.RunServerAPI("BLL.Employee", "GetStaff", val); if (jsdata == "") { res.ExtMessage = "员工号不存在!"; res.Result = false; return(res); } string jsdata1 = client.RunServerAPI("BLL.Employee", "GetStaffEnable", val); if (jsdata1 == "") { res.ExtMessage = "员工号已停用,请联系管理员!"; res.Result = false; return(res); } S_Employee emp = JsonConvert.DeserializeObject <S_Employee>(jsdata); job.EmpCode = emp.emp_code; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; //当前步骤完成 res.Result = true; return(res); } catch (Exception exc) { //MessageBox.Show(exc.Message); res.ExtMessage = "员工信息获取失败!"; res.Result = false; return(res); } }
public IResult DoWork(IJob job, string val) { IResult res = new LEResult(); decimal qyt = 0; try { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); string product_code = job.Product; string rule_code = client.RunServerAPI("BLL.Product", "GetRuleByProductCode", product_code); //var pattern = @"^([0-9]{4}-).+$"; if (!string.IsNullOrEmpty(rule_code)) { var pattern = @rule_code; bool result = System.Text.RegularExpressions.Regex.IsMatch(val, pattern); if (!result) { res.Result = false; res.ExtMessage = "条码不符合规则,请重新扫描"; return(res); } } string jsdata = client.RunServerAPI("BLL.SFC", "GetSfcState", val); #region --返回空 if (string.IsNullOrEmpty(jsdata)) { if (job.RouteType == "首工站") { //根据sfc在P_SFC_State表中查询是否存在未维修记录 string strclFailLog = client.RunServerAPI("BLL.Faillog", "GetFileLogBySFC", val); if (!string.IsNullOrWhiteSpace(strclFailLog)) { List <P_FailLog> dt = new List <P_FailLog>(); dt = JsonConvert.DeserializeObject <List <P_FailLog> >(strclFailLog); if (dt.Count > 0) { res.ExtMessage = "当前批次[" + val.ToString() + "]已进入维修工序,请检查"; res.Result = false; return(res); } } string ResProduct1 = client.RunServerAPI("BLL.Product", "GetProductFlow", job.OrderNO); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct1); V_ProductFlow produc1 = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes1 = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc1.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes1); if (!res.Result) { return(res); } string strqty = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", job.OrderNO + "," + job.ProcessCode); decimal.TryParse(strqty, out qyt); job.FatherOrderNO = produc1.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc1.product_code; job.FlowCode = produc1.flow_code; job.MaxQTY = produc1.max_qty.Value; job.MaxQTYOrder = produc1.qty.Value; job.QTYOrder = qyt; if (job.QTYOrder >= job.MaxQTYOrder) { res.ExtMessage = "工单完成数已达上限"; res.Result = false; return(res); } //验证是否打印绑定 ILE.IResult res1 = DP003.CheckPrintBing.PrintBing(job, client, val, res); if (!res1.Result) { return(res1); } job.start_time = DateTime.Parse(client.RunServerAPI("BLL.Process", "GetServerTime", "")); job.SFC = val; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; res.Result = true; return(res); } res.Result = false; res.ExtMessage = "没有成品批次号"; return(res); } #endregion P_SFC_State sfc = JsonConvert.DeserializeObject <P_SFC_State>(jsdata); if (job.Pid == 0) { string ResProduct1 = client.RunServerAPI("BLL.Product", "GetProductFlow", sfc.order_no); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct1); V_ProductFlow produc1 = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes1 = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc1.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes1); if (!res.Result) { return(res); } string strqty = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", sfc.order_no + "," + job.ProcessCode); decimal.TryParse(strqty, out qyt); job.MaxQTY = produc1.max_qty.Value; job.MaxQTYOrder = produc1.qty.Value; job.QTYOrder = qyt; if (job.RouteType == "首工站" && job.QTYOrder >= job.MaxQTYOrder) { res.ExtMessage = "工单完成数已达上限"; res.Result = false; return(res); } job.FatherOrderNO = produc1.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc1.product_code; job.FlowCode = produc1.flow_code; } string Pid = job.Pid.ToString(); string Strict = client.RunServerAPI("BLL.Process", "GetStrict", Pid); if (Strict == "1") { switch (sfc.state) { case -1: res.Result = false; res.ExtMessage = "成品批次已报废"; return(res); case 0: res.Result = false; res.ExtMessage = "成品批次已停用"; return(res); case 1: break; case 2: res.Result = false; res.ExtMessage = "成品批次已完成"; return(res); } if (job.ProcessCode != sfc.now_process) { string processs_code = sfc.now_process; string processJson = client.RunServerAPI("BLL.Process", "GetProcess", processs_code); V_ProcessList_Workshop list = JsonConvert.DeserializeObject <V_ProcessList_Workshop>(processJson); string Process_name = list.process_name; res.Result = false; res.ExtMessage = "成品批次工序是[" + Process_name + "]"; return(res); } } job.OrderNO = sfc.order_no; ///////////////////////////////////// //判断是否严格控制该工序,严格控制则执行以下代码,不严格控制则随意工序,不做控制 ///////////////////////////////////// //验证是否打印绑定 ILE.IResult resResult = DP003.CheckPrintBing.PrintBing(job, client, val, res); if (!resResult.Result) { return(resResult); } ///// string ResProduct = client.RunServerAPI("BLL.Product", "GetProductFlow", job.OrderNO); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct); if (!res.Result && Strict == "1") { return(res); } V_ProductFlow produc = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes); if (res.obj == null) { return(res); } if (!res.Result && Strict == "1") { return(res); } string strqty1 = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", job.OrderNO + "," + job.ProcessCode); decimal.TryParse(strqty1, out qyt); job.FatherOrderNO = produc.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc.product_code; job.FlowCode = produc.flow_code; job.MaxQTY = produc.max_qty.Value; job.MaxQTYOrder = produc.qty.Value; job.QTYOrder = qyt; job.SFC = val; // job.start_time = DateTime.Parse(client.RunServerAPI("BLL.Process", "GetServerTime", "")); //job.start_time = DateTime.Now; job.QTY = sfc.qty.Value; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; res.Result = true; return(res); } catch (Exception exc) { res.Result = false; return(res); } }
public IResult DoWork(IJob job, string val) { IResult res = new LEResult(); decimal qyt = 0; try { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); //首先判断输入的是否是条码,如果是工单号带出,不是的话,则说明 //string dt = client.RunServerAPI("BLL.SSW", "GetWorkerOrderbyBar", val); //List<P_BarCodeBing> proc = JsonConvert.DeserializeObject<List<P_BarCodeBing>>(dt); //if (proc != null) //{ // val = proc[0].order.ToString(); //} //else //{ // val = val; // string dts = client.RunServerAPI("BLL.SSW", "GetOrderNo", job.ProcessCode + "," + val); // List<V_WorkOrder_Product> pro = JsonConvert.DeserializeObject<List<V_WorkOrder_Product>>(dts); // if (pro != null) // { // val = pro[0].order_no; // } //} string ResProduct = client.RunServerAPI("BLL.Product", "GetProductFlow", val); res = JsonConvert.DeserializeObject <ILE.LEResult>(ResProduct); if (!res.Result) { return(res); } V_ProductFlow produc = JsonConvert.DeserializeObject <V_ProductFlow>(res.obj.ToString()); string strRes = client.RunServerAPI("BLL.Process", "GetFlowDetailOK", produc.flow_code + "," + job.ProcessCode); res = JsonConvert.DeserializeObject <ILE.LEResult>(strRes); if (!res.Result) { return(res); } ////根据工单查询bom基数,然后赋给job //int baseqty = Convert.ToInt32(client.RunServerAPI("BLL.Bom", "GetBomDetailBaseQty", val)); string strqty = client.RunServerAPI("BLL.SFC", "GetSFCQty_2", val + "," + job.ProcessCode); decimal.TryParse(strqty, out qyt); job.FatherOrderNO = produc.parent_order; job.Pid = Convert.ToInt32(res.obj); job.Product = produc.product_code; job.FlowCode = produc.flow_code; //job.baseqty = baseqty; job.MaxQTY = produc.max_qty.Value; job.MaxQTYOrder = produc.qty.Value; //job.QTYOrder = qyt; //if (job.QTYOrder >= job.MaxQTYOrder) //{ // res.ExtMessage = "工单完成数已达上限"; // res.Result = false; // return res; //} job.OrderNO = val; job.StepList[job.StepIdx].StepValue = val; job.StepList[job.StepIdx].Completed = true; res.Result = true; return(res); } catch (Exception exc) { //MessageBox.Show(exc.Message); res.ExtMessage = "DP002 catch ... " + exc.Message; res.Result = false; return(res); } }