312 lines
14 KiB
C#
312 lines
14 KiB
C#
/**************************************************************************
|
||
*
|
||
* =================================
|
||
* CLR版本 :4.0.30319.42000
|
||
* 命名空间 :NSAnalysis
|
||
* 文件名称 :Define.cs
|
||
* =================================
|
||
* 创 建 者 :shupeng.wang
|
||
* 创建日期 :2021/6/9 14:58:52
|
||
* 功能描述 :
|
||
* 使用说明 :
|
||
* =================================
|
||
* 修改者 :
|
||
* 修改日期 :
|
||
* 修改内容 :
|
||
* =================================
|
||
*
|
||
***************************************************************************/
|
||
|
||
using BaseFunction;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Web;
|
||
using System.Windows.Forms;
|
||
|
||
namespace NSAnalysis
|
||
{
|
||
public class LogDebugDfn
|
||
{
|
||
public static string strDebugFile = Application.StartupPath + "\\Debug.txt"; //保存操作log的文件
|
||
public static string strStartTime = "";//程序启动时间
|
||
public static string strEndTime = ""; //程序关闭时间
|
||
}
|
||
|
||
public class ConfigDfn
|
||
{
|
||
#region 全局变量
|
||
|
||
public static string strKeyFolder = Application.StartupPath + "\\Key";
|
||
public static string strFileFolder = Application.StartupPath + "\\File";
|
||
public static string strDFQFolder = Application.StartupPath + "\\DFQFiles";
|
||
public static string strDebugFileFolder = Application.StartupPath + "\\File\\DebugFiles\\";
|
||
public static string strThemePath = Application.StartupPath + "\\ThemeSkin\\";
|
||
public static string strTheme = Application.StartupPath + "\\ThemeSkin\\";
|
||
|
||
/// <summary>CheryAnalysisConfig.ini绝对路径地址</summary>
|
||
public static string strConfigFile = Application.StartupPath + "\\File\\AnalysisConfig.ini";
|
||
|
||
public static string strImageFile = Application.StartupPath + "\\Images\\";
|
||
public static string strExpiredTime = "";
|
||
|
||
public static string strSkinName = "";
|
||
public static string strHelpDocumentName = "";
|
||
public static int iDeleteFlieTime;
|
||
public static string strImagePath = "";
|
||
|
||
/// <summary> true =中文 false =英语 </summary>
|
||
public static bool bLanguage = true;
|
||
|
||
public static bool bRememberMe = false;
|
||
public static string UserName = "";
|
||
public static string Password = "";
|
||
|
||
public static int gtm1_60 = 5000;
|
||
public static int gtmRMIDMode = 5000;
|
||
public static int gtmRCMMStatus = 6000;
|
||
|
||
public static string strNextSenseCSVEH3Path = "";
|
||
public static string strNextSenseCSVEHYPath = "";
|
||
public static string strNextSenseSelfMeasurePath = "";
|
||
public static string strPLCIP = "";
|
||
|
||
/// <summary>NextSense 测量结果</summary>
|
||
public static bool bMeasureResult = false;
|
||
|
||
public static string strMeasureTime = "";
|
||
|
||
public static double dFPY = 0.8;
|
||
public static double dFPY2 = 0.6;
|
||
|
||
public static string strCarModel = "";
|
||
public static string strEquipNo = "";
|
||
public static string strEquipName = "";
|
||
public static string strIOTAddress = "";
|
||
public static string strIOTCarTypeAddress = "";
|
||
public static int iStartIOTFlag = 1;
|
||
public static int iShowCarDataFlag = 0;
|
||
public static string strShowCarLR="";
|
||
public static string strCOMPort = "";
|
||
|
||
public static int iCreateReportFlag = 0;
|
||
public static string strStationName = "";
|
||
public static string strUploadPath = "";
|
||
public static string strUploadPath2 = "";
|
||
public static double dLevel2 = 1.5;
|
||
|
||
public static double dLevel3 = 2.0;
|
||
public static string strReportPath = "";
|
||
public static string strReportPath2 = "";
|
||
/// <summary>
|
||
/// 公差带百分比
|
||
/// </summary>
|
||
public static double dTolerancePer = 0.0;
|
||
public static double dExceptionTolerancePer = 0.0;
|
||
public static string strPwd = "";
|
||
public static int iAnalysisCSVFlag=1;
|
||
public static int iRecordEncoderFlag = 0;
|
||
public static int iIncludeRangeFlag = 0;
|
||
public static int iMeasureItemsCount = 0;
|
||
public static int iFailedCarCount = 0;
|
||
#endregion 全局变量
|
||
|
||
public static void LoadConfig()
|
||
{
|
||
string strSection = "";
|
||
|
||
#region 读取系统配置参数
|
||
|
||
strSection = "Chery";
|
||
iDeleteFlieTime = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "DeleteDebugFileIntervalTime");
|
||
strSkinName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ConfigSkinName");
|
||
strTheme += strSkinName;
|
||
strHelpDocumentName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SoftwareHelpDocument");
|
||
strImagePath = strImageFile + FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "CNCPictureName");
|
||
bLanguage = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "Language", 0);
|
||
bRememberMe = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "RememberMe", 0);
|
||
strNextSenseCSVEH3Path = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextsenseCSVEH3Path");
|
||
strNextSenseCSVEHYPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextsenseCSVEHYPath");
|
||
strNextSenseSelfMeasurePath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextseneSelfMeasurePath");
|
||
dFPY = double.Parse(FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "FPY"));
|
||
dFPY2 = double.Parse(FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "FPY2"));
|
||
strCarModel = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "CarModel");
|
||
strEquipNo = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "EquipmentNo");
|
||
strEquipName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "EquipmentName");
|
||
iStartIOTFlag = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "StartIOTFlag");
|
||
strIOTAddress = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "IOTAddress");
|
||
strIOTCarTypeAddress = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "IOTCarTypeAddr");
|
||
iShowCarDataFlag = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "ShowDataFlag");
|
||
strShowCarLR = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ShowData");
|
||
dTolerancePer = FileIni.ReadDouble(ConfigDfn.strConfigFile, strSection, "TolerancePercentage");
|
||
dExceptionTolerancePer = FileIni.ReadDouble(strConfigFile, strSection, "ExceptionPercentage");
|
||
strPwd = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "Password");
|
||
strCOMPort = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "COMPort");
|
||
|
||
iCreateReportFlag = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "CreateReportFlag");
|
||
strStationName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "StationName");
|
||
strUploadPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "tavascanUploadPath");
|
||
strUploadPath2 = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "blacklabelUploadPath");
|
||
dLevel2 = double.Parse(FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "Level2Times"));
|
||
dLevel3 = double.Parse(FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "Level3Times"));
|
||
strReportPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ReportCSVPath");
|
||
strReportPath2 = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ReportCSVPath2");
|
||
iAnalysisCSVFlag= FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "AnalysisCSVFlag");
|
||
iRecordEncoderFlag = FileIni.ReadInt(strConfigFile, strSection, "RecordEncoderFlag");
|
||
iIncludeRangeFlag = FileIni.ReadInt(strConfigFile, strSection, "IncludeRangeFlag");
|
||
iMeasureItemsCount = FileIni.ReadInt(strConfigFile, strSection, "MeasureCarItemsCount");
|
||
iFailedCarCount = FileIni.ReadInt(strConfigFile, strSection, "ContinuousCarCount");
|
||
#endregion 读取系统配置参数
|
||
|
||
#region 读[PLC] 参数
|
||
|
||
strSection = "PLC";
|
||
strPLCIP = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ModbusTcp_IP");
|
||
|
||
#endregion 读[PLC] 参数
|
||
|
||
#region 读[Timer] 参数
|
||
|
||
strSection = "Timer";
|
||
gtm1_60 = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "TimerFixedStorage") * 1000;
|
||
gtmRMIDMode = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "TimerRefreshMIDMode") * 1000;
|
||
gtmRCMMStatus = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "TimerRefreshCMMStatus") * 1000;
|
||
|
||
#endregion 读[Timer] 参数
|
||
}
|
||
|
||
public static void LoadConfigFile()
|
||
{
|
||
try
|
||
{
|
||
#region 检查DLL是否存在
|
||
|
||
//if (!File.Exists(Application.StartupPath + "\\Fwlib32.dll"))
|
||
// MyBase.TraceWriteLine("错误:Fwlib32.dll 文件丢失,程序将不能正确运行!");
|
||
//else
|
||
// MyBase.TraceWriteLine("Fwlib32.dll 文件存在!");
|
||
|
||
#endregion 检查DLL是否存在
|
||
|
||
MyBase.TraceWriteLine("加载配置文件——>开始");
|
||
if (File.Exists(strConfigFile))
|
||
{
|
||
LoadConfig();
|
||
ConfigPlc.LoadConfig();
|
||
DatabaseDfn.LoadConfig();
|
||
MyBase.TraceWriteLine("加载配置文件——>完成");
|
||
}
|
||
else
|
||
{
|
||
MyBase.TraceWriteLine("配置文件不存在!");
|
||
}
|
||
|
||
#region 检测文件夹,没有则创建
|
||
|
||
if (!Directory.Exists(ConfigDfn.strFileFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strFileFolder);
|
||
if (!Directory.Exists(ConfigDfn.strDebugFileFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strDebugFileFolder);
|
||
if (!Directory.Exists(ConfigDfn.strKeyFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strKeyFolder);
|
||
if (!Directory.Exists(ConfigDfn.strThemePath))
|
||
Directory.CreateDirectory(ConfigDfn.strThemePath);
|
||
if (!Directory.Exists(ConfigDfn.strImageFile))
|
||
Directory.CreateDirectory(ConfigDfn.strImageFile);
|
||
if (!Directory.Exists(ConfigDfn.strDFQFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strDFQFolder);
|
||
|
||
#endregion 检测文件夹,没有则创建
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MyBase.TraceWriteLine("加载配置文件错误:" + ex.ToString());
|
||
}
|
||
}
|
||
}
|
||
|
||
public class PLCDfn
|
||
{
|
||
/// <summary> 上料完成状态 10=OK,其他=false </summary>
|
||
public static int CmmPartOk = -1;
|
||
|
||
/// <summary>清除测量结果标志位 </summary>
|
||
public static int CMMResultClear = -1;
|
||
|
||
/// <summary>PLC心跳状态: 0 1 定时闪烁</summary>
|
||
public static bool bPlcLiveHeart = false;
|
||
|
||
/// <summary> CMM外部急停(PLC给出)</summary>
|
||
public static bool bCMMEmengency = false;
|
||
|
||
/// <summary>PLC当前模式10:手动;20:自动;30:联机自动;40:脱机运行</summary>
|
||
public static int bPLCMode;
|
||
|
||
/// <summary>PLC自动运行</summary>
|
||
public static bool bAllowHome = false;
|
||
|
||
/// <summary>托盘到位状态:10:托盘到位;0 :默认</summary>
|
||
public static int TrayStatus;
|
||
|
||
/// <summary> 允许启动指令:0=禁止启动, 1611或10 = 允许启动, -1= 未知(PLC未连接) </summary>
|
||
public static int StartCmd = -1;
|
||
|
||
/// <summary>启动测量:10:开始测量;0 :默认</summary>
|
||
public static int NSStartMeasure;
|
||
|
||
public static int CarPassFlag;
|
||
/// <summary>读码完成:10:默认为;0 :默认</summary>
|
||
public static int ReadVINFinishFlag;
|
||
|
||
/// <summary>从工位1流向工位2:10:station1->2;0 :默认</summary>
|
||
public static int Station1To2;
|
||
|
||
/// <summary>从工位2流向工位3:10:station1->2;0 :默认</summary>
|
||
public static int Station2To3;
|
||
|
||
/// <summary>工件ID</summary>
|
||
public static string PartID = "";
|
||
|
||
/// <summary>1:EH3;2:EHY</summary>
|
||
public static int CarType;
|
||
|
||
/// <summary>PLC心跳状态: 0 1 定时闪烁</summary>
|
||
public static bool bPlcLiveTick = false;
|
||
}
|
||
|
||
public class HYPLCDfn
|
||
{
|
||
public static int testValue = 1;
|
||
}
|
||
|
||
public class DatabaseDfn
|
||
{
|
||
public static string SqlServerName = "";
|
||
public static string SqlDbName = "";
|
||
public static string SqlUserName = "";
|
||
public static string SqlPassword = "";
|
||
|
||
public static string SqlConnectStr()
|
||
{
|
||
string strConnectString = "";
|
||
strConnectString = @"Data Source=" + SqlServerName
|
||
+ ";initial Catalog=" + SqlDbName
|
||
+ ";User ID=" + SqlUserName
|
||
+ ";password=" + SqlPassword + ";";
|
||
|
||
return strConnectString;
|
||
}
|
||
|
||
public static void LoadConfig()
|
||
{
|
||
string strSection = "MSDB";
|
||
SqlServerName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlServerName");
|
||
SqlUserName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlUserName");
|
||
SqlPassword = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlPassword");
|
||
SqlDbName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlDbName");
|
||
}
|
||
}
|
||
} |