schangxiang@126.com
2024-08-31 5c34ca4f23c702291188f122b05165310b579cbc
DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandler/PLCDataCapture/PLCManger.cs
@@ -44,7 +44,7 @@
                    return typeof(Char);
                case "real":
                    return typeof(double);
                    //return typeof(Single);
                //return typeof(Single);
                case "bool":
                    return typeof(bool);
                case "string":
@@ -58,7 +58,7 @@
            }
        }
        public static object GetVauleForObjectType(object vaule,TypeCode type)
        public static object GetVauleForObjectType(object vaule, TypeCode type)
        {
            switch (type)
@@ -77,7 +77,7 @@
                    return Convert.ToString(vaule);
                case TypeCode.Byte:
                    return Convert.ToByte(vaule);
                default:
                    return Convert.ToString(vaule);
            }
@@ -85,7 +85,7 @@
        public static LogType GetLogTypeForWorkingProcedure(string wp)
        {
            switch(wp)
            switch (wp)
            {
                case "OP05":
@@ -115,14 +115,34 @@
            }
        }
        public static string GetWorkPieceIDForPLC(DataCaptureConfig _dataCaptureConfig,PLCService plcService)
        /// <summary>
        /// 上线
        /// </summary>
        /// <param name="wp"></param>
        /// <returns></returns>
        public static LogType GetLogTypeForOnLine(string wp)
        {
            //强制转换
            try
            {
                LogType _logType = (LogType)Enum.Parse(typeof(LogType), wp);
                return _logType;
            }
            catch (Exception ex)
            {
                return LogType.OtherOnLine;
            }
        }
        public static string GetWorkPieceIDForPLC(DataCaptureConfig _dataCaptureConfig, PLCService plcService)
        {
            try
            {
                var valueid = plcService.ReadValuePoint(_dataCaptureConfig.DbNumber, _dataCaptureConfig.Offset, _dataCaptureConfig.DataCaptureColumnLength.Value, PLCManger.GetTypeForString(_dataCaptureConfig.DataCaptureColumnType));
                return valueid.ToString().Trim();
            }
            catch(Exception ex)
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(_dataCaptureConfig.WorkingProcedure), $" {_dataCaptureConfig.WorkingProcedure}工序监控读码标记 读取工件码数据时异常:", ex);
                throw;