Ejemplo n.º 1
0
        public static RootObject DevStopStatUpload(int M_FLAG, string stationID, string stat, ref string strJson)
        {
            RootObject rObj = null;

            if (SysCfgModel.SimMode)
            {
                rObj     = new RootObject();
                rObj.RES = "OK";

                return(rObj);
            }
            List <ContentDetail> CList = new List <ContentDetail>();
            ContentDetail        tail  = new ContentDetail();

            tail.M_FLAG           = M_FLAG;
            tail.M_DEVICE_SN      = "";
            tail.M_WORKSTATION_SN = stationID;
            tail.CONTROL_TYPE     = stat;
            CList.Add(tail);
            strJson = WShelper.ReturnJsonData("OK", "RUN", CList);
            object objJson = strJson;

            object[] addParams = new object[] { objJson };
            object   result    = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
            string   strRES    = result.ToString();

            rObj = new RootObject();
            rObj = JsonConvert.DeserializeObject <RootObject>(strRES);
            return(rObj);
        }
Ejemplo n.º 2
0
        public static RootObject DevErrorUpload(string M_DEVICE_SN, string M_AREA, string errCode, int errStatus, ref string strJson)
        {
            RootObject rObj = null;

            if (SysCfgModel.SimMode)
            {
                rObj     = new RootObject();
                rObj.RES = "OK";

                return(rObj);
            }
            List <ContentDetail> CList = new List <ContentDetail>();
            ContentDetail        tail  = new ContentDetail();

            tail.M_FLAG         = 7;
            tail.M_AREA         = M_AREA;
            tail.M_DEVICE_SN    = M_DEVICE_SN;
            tail.M_ERROR_CODE   = errCode;
            tail.M_ERROR_STATUS = errStatus.ToString();
            CList.Add(tail);
            strJson = WShelper.ReturnJsonData("OK", "", CList);
            object objJson = strJson;

            object[] addParams = new object[] { objJson };
            object   result    = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
            string   strRES    = result.ToString();

            rObj = new RootObject();
            rObj = JsonConvert.DeserializeObject <RootObject>(strRES);
            return(rObj);
        }
Ejemplo n.º 3
0
        //public static RootObject DevStopstatQuery(string stationID,ref string strJson)
        //{
        //    RootObject rObj = null;
        //    if (SysCfgModel.SimMode)
        //    {
        //        rObj = new RootObject();
        //        rObj.RES = "OK";
        //        rObj.CONTROL_TYPE = "RUN";
        //        return rObj;
        //    }
        //    List<ContentDetail> CList = new List<ContentDetail>();
        //    ContentDetail tail = new ContentDetail();
        //    tail.M_DEVICE_SN = "";
        //    tail.M_WORKSTATION_SN = stationID;
        //    tail.M_FLAG = 1;
        //    CList.Add(tail);
        //    strJson = WShelper.ReturnJsonData("OK", "RUN", CList);
        //    object objJson = strJson;
        //    object[] addParams = new object[] { objJson };
        //    object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
        //    string strRES = result.ToString();
        //    rObj = new RootObject();
        //    rObj = JsonConvert.DeserializeObject<RootObject>(strRES);
        //    return rObj;
        //}
/// </summary>
        /// <param name="jsonStr">格式化的json串</param>
        /// <param name="restr"></param>
        /// <returns>0上传成功,1上传成功,单返回NG,2传输失败</returns>
        public static int UploadDataToMes(string jsonStr, ref string restr)
        {
            RootObject rObj = new RootObject();

            object objJson = jsonStr;

            object[] addParams = new object[] { objJson };

            object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
            string strRES = result.ToString();

            rObj  = new RootObject();
            rObj  = JsonConvert.DeserializeObject <RootObject>(strRES);
            restr = rObj.RES;
            if (rObj.RES.ToUpper().Contains("OK") == true)
            {
                return(0);
            }
            else if (rObj.RES.ToUpper().Contains("NG") == true)
            {
                return(1);
            }
            else
            {
                return(2);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 设备数据上传
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static RootObject DevDataUpload(int M_FLAG, string M_DEVICE_SN, string M_WORKSTATION_SN, string M_SN, string M_UNION_SN, string M_CONTAINER_SN, string M_LEVEL, string M_ITEMVALUE, ref string strJson, string CONTROL_TYPE)
        {
            RootObject rObj = null;

            if (SysCfgModel.SimMode)
            {
                rObj     = new RootObject();
                rObj.RES = "OK";

                return(rObj);
            }
            List <ContentDetail> CList = new List <ContentDetail>();
            ContentDetail        tail  = new ContentDetail();

            tail.M_FLAG           = M_FLAG;
            tail.M_DEVICE_SN      = M_DEVICE_SN;
            tail.M_WORKSTATION_SN = M_WORKSTATION_SN;
            tail.M_SN             = M_SN;
            tail.M_UNION_SN       = M_UNION_SN;
            tail.M_CONTAINER_SN   = M_CONTAINER_SN;
            tail.M_LEVEL          = M_LEVEL;
            tail.M_ITEMVALUE      = M_ITEMVALUE;
            tail.CONTROL_TYPE     = CONTROL_TYPE;
            CList.Add(tail);
            //上传参数
            strJson = WShelper.ReturnJsonData("OK", CONTROL_TYPE, CList);
            object objJson = strJson;

            object[] addParams = new object[] { objJson };
            if (SysCfgModel.MesOfflineMode == true)//离线模式将上报数据存储到数据库
            {
                FTDataAccess.Model.OfflineDataModel offlineModel = new FTDataAccess.Model.OfflineDataModel();
                offlineModel.OfflineDataID  = Guid.NewGuid().ToString();
                offlineModel.IsUpLoad       = EnumUploadStatus.待上传.ToString();
                offlineModel.DataType       = EnumUpLoadDataType.数据上报.ToString();
                offlineModel.WorkStationID  = M_WORKSTATION_SN;
                offlineModel.UploadJsonData = strJson;
                offlineModel.CreateTime     = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                bllOfflineData.Add(offlineModel);
                rObj     = new RootObject();
                rObj.RES = "OK";
                return(rObj);
            }
            else
            {
                object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
                string strRES = result.ToString();
                rObj = new RootObject();
                rObj = JsonConvert.DeserializeObject <RootObject>(strRES);
                FTDataAccess.Model.OfflineDataModel offlineModel = new FTDataAccess.Model.OfflineDataModel();
                offlineModel.OfflineDataID  = Guid.NewGuid().ToString();
                offlineModel.IsUpLoad       = EnumUploadStatus.已上传.ToString();
                offlineModel.DataType       = EnumUpLoadDataType.数据上报.ToString();
                offlineModel.WorkStationID  = M_WORKSTATION_SN;
                offlineModel.UploadJsonData = strJson;
                offlineModel.CreateTime     = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                bllOfflineData.Add(offlineModel);
                return(rObj);
            }
        }
Ejemplo n.º 5
0
        public static object InvokeWebService(string url, string classname, string methodname, object[] args)
        {
            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";

            if ((classname == null) || (classname == ""))
            {
                classname = WShelper.GetWsClassName(url);
            }

            try
            {
                //获取WSDL
                WebClient wc = new WebClient();

                Stream                     stream = wc.OpenRead(url + "?WSDL");
                ServiceDescription         sd     = ServiceDescription.Read(stream);
                ServiceDescriptionImporter sdi    = new ServiceDescriptionImporter();
                sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                sdi.Import(cn, ccu);
                CodeDomProvider    provider = new CSharpCodeProvider();//设定编译参数
                CompilerParameters cplist   = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory   = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                CompilerResults cr = provider.CompileAssemblyFromDom(cplist, ccu);
                if (true == cr.Errors.HasErrors)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(System.Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }

                //生成代理实例,并调用方法
                System.Reflection.Assembly assembly = cr.CompiledAssembly;
                Type   t   = assembly.GetType(@namespace + "." + classname, true, true);
                object obj = Activator.CreateInstance(t);
                System.Reflection.MethodInfo mi = t.GetMethod(methodname);

                return(mi.Invoke(obj, args));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 直接发json数据
        /// </summary>
        /// <param name="jsonData"></param>
        /// <returns></returns>
        public static RootObject UploadDataByJson(string jsonData)
        {
            object objJson = jsonData;

            object[] addParams = new object[] { objJson };

            object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
            string strRES = result.ToString();

            RootObject rObj = JsonConvert.DeserializeObject <RootObject>(strRES);

            return(rObj);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 设备请求条码
        /// </summary>
        public static RootObject BarCodeRequest(string M_WORKSTATION_SN, EnumQRCodeType qrcodeType, string CONTROL_TYPE, ref string jsonStr)
        {
            List <ContentDetail> CList = new List <ContentDetail>();
            ContentDetail        tail  = new ContentDetail();

            tail.M_FLAG = 11;
            // tail.M_WORKSTATION_SN = "Y00100101";
            tail.M_WORKSTATION_SN = M_WORKSTATION_SN;
            CList.Add(tail);
            //上传参数
            string strJson = WShelper.ReturnJsonData("OK", CONTROL_TYPE, CList);
            object objJson = strJson;

            object[] addParams = new object[] { objJson };
            if (SysCfgModel.MesOfflineMode == true)//离线模式将上报数据存储到数据库
            {
                RootObject rObj = new RootObject();
                DBAccess.Model.QRCodeModel qrCode = bllQrCode.RequireQrCode(qrcodeType.ToString());
                if (qrCode == null)
                {
                    ContentDetail offlienTail = new ContentDetail();
                    offlienTail.M_SN = "";
                    rObj.M_COMENT    = new List <ContentDetail>();
                    rObj.M_COMENT.Add(offlienTail);
                    rObj.CONTROL_TYPE = "";
                    rObj.RES          = "离线条码申请失败!";
                    return(rObj);
                }
                else
                {
                    ContentDetail offlienTail = new ContentDetail();
                    offlienTail.M_SN = qrCode.QRCode;
                    rObj.M_COMENT    = new List <ContentDetail>();
                    rObj.M_COMENT.Add(offlienTail);
                    rObj.CONTROL_TYPE = "";
                    rObj.RES          = "OK!离线条码申请成功:" + qrCode.QRCode;
                    qrCode.PintStatus = EnumQrCodeApplyStatus.已申请.ToString();
                    bllQrCode.Update(qrCode);
                    return(rObj);
                }
            }
            else
            {
                object     result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
                string     strRES = result.ToString();
                RootObject rObj   = new RootObject();
                rObj    = JsonConvert.DeserializeObject <RootObject>(strRES);
                jsonStr = strRES;
                return(rObj);
            }
        }
Ejemplo n.º 8
0
        public bool ReportToMesByProcessStationID(string stationID, string rfid)
        {
            List <DBAccess.Model.BatteryModuleModel> modList = modBll.GetModelList(string.Format("palletID='{0}'   and palletBinded=1", rfid));

            if (modList == null || modList.Count == 0)
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "返修流程不加工工位:" + stationID + ",RFID:" + rfid + ",绑定数据为空,不需要上传数据!");
                return(true);
            }
            RepairRecordModel repairRecModel = bllRepairRecord.GetModel(modList[0].batModuleID);

            if (repairRecModel == null)//如果没有这个记录则不为返修流程
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "返修记录不存在二维码:" + modList[0].batModuleID + ",不需要上传数据!");
                return(true);
            }

            DBAccess.Model.ModuleProcessModel startModuleProcess = bllModuleProcess.GetProcessByWorkStationID(repairRecModel.RepairStartStationNum);
            if (startModuleProcess == null)
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "起始加工中心编号:" + repairRecModel.RepairStartStationNum + "错误,没有此加工中心编号!");
            }

            DBAccess.Model.ModuleProcessModel currModuleProcess = bllModuleProcess.GetProcessByID(stationID);
            if (currModuleProcess == null)
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "工位编号错误:" + stationID + ",无此工位编号");
                return(false);
            }
            if (currModuleProcess.ModuleProcessOrder < startModuleProcess.ModuleProcessOrder)
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "开始工位工艺前面的工位不需要上传MES数据!");
                return(true);
            }
            FTDataAccess.Model.OfflineDataModel offlineData = bllOfflineData.GetLastDataByWorkStationID(currModuleProcess.WorkStationID);
            if (offlineData == null)
            {
                this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "获取上一次加工数据失败,工作中心号:" + currModuleProcess.WorkStationID + ",上报MES失败!");
                return(false);
            }
            RootObject rootObj = WShelper.UploadDataByJson(offlineData.UploadJsonData);

            this.nodeBase.LogRecorder.AddDebugLog(this.nodeBase.NodeName, "返修流程," + currModuleProcess.ModuleProcessName + ",不加工工作中心上传MES正常数据成功:" + currModuleProcess.WorkStationID + ",数据:" + offlineData.UploadJsonData);

            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 从MES获取测试标准数据
        /// </summary>
        /// <param name="M_FLAG"></param>
        /// <param name="M_AREA"></param>
        /// <param name="M_ITEM_TYPE"></param>
        /// <returns></returns>
        public static RootObject GetTestStandardDataFromMES(int M_FLAG, string M_AREA, int M_ITEM_TYPE)
        {
            RootObject rObj = null;

            if (SysCfgModel.SimMode)
            {
                rObj     = new RootObject();
                rObj.RES = "NG,仿真模式不支持获取标准!";

                return(rObj);
            }
            if (SysCfgModel.MesOfflineMode == true)//只有在线模式才能申请标准
            {
                rObj     = new RootObject();
                rObj.RES = "NG,离线模式不支持获取标准";

                return(rObj);
            }
            List <ContentDetail> CList = new List <ContentDetail>();
            ContentDetail        tail  = new ContentDetail();

            tail.M_FLAG      = M_FLAG;
            tail.M_AREA      = M_AREA;
            tail.M_ITEM_TYPE = M_ITEM_TYPE;
            CList.Add(tail);
            string CONTROL_TYPE = "";
            //上传参数
            string strJson = WShelper.ReturnJsonData("OK", CONTROL_TYPE, CList);
            object objJson = strJson;

            object[] addParams = new object[] { objJson };

            object result = WShelper.InvokeWebService(url, "DxDataUploadJson", addParams);
            string strRES = result.ToString();

            rObj = new RootObject();
            rObj = JsonConvert.DeserializeObject <RootObject>(strRES);

            return(rObj);
        }
Ejemplo n.º 10
0
 /// < summary>
 /// 动态调用web服务
 /// < /summary>
 /// < param name="url">WSDL服务地址< /param>
 /// < param name="methodname">方法名< /param>
 /// < param name="args">参数< /param>
 /// < returns>< /returns>
 public static object InvokeWebService(string url, string methodname, object[] args)
 {
     return(WShelper.InvokeWebService(url, null, methodname, args));
 }
Ejemplo n.º 11
0
        public bool GetRepairProcessParamByCode(string moduleCode, ref RepairProcessParam repairProcessParam, ref string restr)
        {
            try
            {
                repairProcessParam = new RepairProcessParam();
                if (SysCfgModel.IsRequireRequireFromMes == false)
                {
                    repairProcessParam.StartDevStation = SysCfgModel.StartWorkStationID;
                    repairProcessParam.ProcessNum      = SysCfgModel.ProcessID;
                    restr = "获取MES返修流程参数成功:开始工位编号:" + repairProcessParam.StartDevStation + ",流程参数:" + repairProcessParam.ProcessNum;
                    return(true);
                }
                string     M_WORKSTATION_SN = "";
                string     M_DEVICE_SN      = "";
                string     M_UNION_SN       = "";
                string     M_CONTAINER_SN   = "";
                string     M_LEVEL          = "";
                string     M_ITEMVALUE      = "";
                int        flag             = 16;
                RootObject rObj             = new RootObject();

                //List<DBAccess.Model.BatteryModuleModel> modelList = modBll.GetModelList(string.Format("palletID='{0}'  and palletBinded=1", rfid)); //modBll.GetModelByPalletID(this.rfidUID, this.nodeName);
                //if (modelList == null || modelList.Count == 0)
                //{
                //    restr = "获取返修加工参数失败,工装板上的模块数量为空:" + rfid;
                //    return false;
                //}
                //foreach (DBAccess.Model.BatteryModuleModel bat in modelList)
                //{
                string barcode = moduleCode;
                string strJson = "";

                rObj = WShelper.DevDataUpload(flag, M_DEVICE_SN, M_WORKSTATION_SN, barcode, M_UNION_SN, M_CONTAINER_SN, M_LEVEL, M_ITEMVALUE, ref strJson, "");

                restr = rObj.RES;

                List <ContentDetail> content = rObj.M_COMENT;;
                if (content != null && content.Count > 0)
                {
                    if (repairProcessParam.StartDevStation == "" || repairProcessParam.ProcessNum == "")
                    {
                        restr = "二维码:" + barcode + "请求起始工位及流程代号失败,返回起始工位号或者流程代码为空:" + restr;
                        return(false);
                    }
                    repairProcessParam.StartDevStation = content[0].M_WORKSTATION_SN;
                    repairProcessParam.ProcessNum      = content[0].M_ROUTE;

                    restr = "获取MES返修流程参数成功:开始工位编号:" + repairProcessParam.StartDevStation + ",流程参数:" + repairProcessParam.ProcessNum;
                }
                else
                {
                    restr = "二维码:" + barcode + "请求起始工位及流程代号失败,MES返回ContentDetail数据为空:" + restr;
                    return(false);
                }


                //}
                this.repairParam = repairProcessParam;

                return(true);
            }
            catch (Exception ex)
            {
                restr = ex.ToString();
                return(false);
            }
        }
Ejemplo n.º 12
0
        public virtual bool DevWarnMonitor(ref string reStr)
        {
            if (PlcRW == null)
            {
                reStr = "PLC通信对象不存在";
                return(false);
            }
            if (!SysCfgModel.SimMode)
            {
                if (!PlcRW.ReadMultiDB(this.dbStartAddr, this.dbBlockNum * 16, ref dbVals))
                {
                    reStr = devName + "PLC未通信上";
                    Console.WriteLine(this.devName + "读取报警地址失败!");//测试
                    return(false);
                }
            }
            //if (dbVals[0] > 0)//测试用
            //{
            //    dbVals[0] = 0;
            //    dbVals[1] = 0;
            //}
            //else
            //{
            //    dbVals[0] = 255;
            //    dbVals[1] = 255;
            //}

            //Console.WriteLine(this.devName + dbVals[0].ToString() + "," + dbVals[1].ToString());

            foreach (string key in devWarnList.Keys)
            {
                DevWarnItemModel warnItem     = devWarnList[key];
                string[]         plcAddrArray = warnItem.PlcAddr.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                int blockIndex = int.Parse(plcAddrArray[0].Substring(1)) - int.Parse(this.dbStartAddr.Substring(1));
                int bitIndex   = int.Parse(plcAddrArray[1]);
                int val        = dbVals[blockIndex * 16 + bitIndex];//(dbVals[blockIndex]>>bitIndex)&0x01;

                if (val != warnItem.WarnStat)
                {
                    DevWarnRecordModel warnRecord = new DevWarnRecordModel();
                    warnRecord.devID      = this.devID;
                    warnRecord.plcAddr    = warnItem.PlcAddr;
                    warnRecord.recordID   = System.Guid.NewGuid().ToString();
                    warnRecord.recordTime = System.DateTime.Now;
                    warnRecord.warnStat   = val;

                    string areaLine  = "L001";
                    string reJsonStr = "";
                    if (val == 0)
                    {
                        warnRecord.warnInfo += "已清除";
                        if (!string.IsNullOrWhiteSpace(this.mesID) && !string.IsNullOrWhiteSpace(warnItem.MesWarnID))
                        {
                            RootObject rObj = WShelper.DevErrorUpload(mesID, areaLine, warnItem.MesWarnID, 1, ref reJsonStr);
                            if (LogRecorder != null)
                            {
                                LogRecorder.AddDebugLog(devName, string.Format("报警{0}复位,上传MES,返回结果:{1}", warnItem.WarnInfo, rObj.RES));
                            }
                        }
                    }
                    else
                    {
                        warnRecord.warnInfo = warnItem.WarnInfo;
                        if (!string.IsNullOrWhiteSpace(this.mesID) && !string.IsNullOrWhiteSpace(warnItem.MesWarnID))
                        {
                            RootObject rObj = WShelper.DevErrorUpload(mesID, areaLine, warnItem.MesWarnID, 0, ref reJsonStr);
                            if (LogRecorder != null)
                            {
                                LogRecorder.AddDebugLog(devName, string.Format("报警{0}发生,上传MES,返回结果:{1}", warnItem.WarnInfo, rObj.RES));
                            }
                        }
                    }
                    devWarnrecordBll.Add(warnRecord);
                    Console.WriteLine(this.devName + ":" + warnRecord.warnInfo + "-》添加报警记录成功!");
                    warnItem.WarnStat = val;
                }
            }
            return(true);
        }