using BaseLibRWFile; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace BaseLibRWFile { public class GlobalPara { public static Ini newIni; //UI Size public static Size PLCSize { get; set; } = new Size(0, 0); public static Size TabSize { get; set; } = new Size(0, 0); public static Size VisionSize { get; set; } = new Size(0, 0); public static Size MainPanelSize { get; set; } = new Size(0, 0); //SystemParameter public static Language CurrentLanguage { get; set; } = Language.Chinese; public static event Action ChangeLanguageEvent; public static event Action ExitEvent; public static event Action ChangeFormEvent; public static event Action OperationLevelEvent; public static string BaseFilePath { get; set; } public static string ProDataFilePath { get; set; } public static string MachineName { get; set; } public static ushort StationCount { get; set; }// public static string StrVisionVMSolutionPath { get; set; } public static bool IsVisionEnable { get; set; } public static bool IsSysInitOK { get; set; } = false; public static string StrCurrentMaterialItem { get; set; } public static bool IsMannulUISeleted { get; set; } public static bool IsMannulIOSeleted { get; set; } public static bool isPLCMotionSeleted { get; set; } public static string StrOperatorPassword { get; set; } public static string StrEngineerPassword { get; set; } public static bool isOperatorSelect { get; set; } = false; public static bool isEngineerSelect { get; set; } = false; #region MachineState / OperationLevel / MachineMode private static MachineState _currentMachineState = MachineState.WaitReset; public static MachineState LastMachineState { get; private set; } = MachineState.WaitReset; public static MachineState CurrentMachineState { get { return _currentMachineState; } set { if (_currentMachineState != value) { LastMachineState = _currentMachineState; _currentMachineState = value; } } } private static OperationLevel _currentOperationLevel = OperationLevel.SWEngineer; public static OperationLevel LastOperationLevel { get; private set; } = OperationLevel.SWEngineer; public static OperationLevel CurrentOperationLevel { get { return _currentOperationLevel; } set { if (_currentOperationLevel != value) { LastOperationLevel = _currentOperationLevel; _currentOperationLevel = value; } } } private static MachineMode _currentMachineMode = MachineMode.Run; public static MachineMode LastMachineMode { get; private set; } = MachineMode.Run; public static MachineMode CurrentMachineMode { get { return _currentMachineMode; } set { if (_currentMachineMode != value) { LastMachineMode = _currentMachineMode; _currentMachineMode = value; } } } #endregion //MachineOutput public static ushort YieldStatisticsDays { get; set; } //public static YieldStatistics YieldStatistics = new YieldStatistics(); //public static TimeStatistics TimeStatistics = new TimeStatistics(); //public static CTStatistics CTStatistics = new CTStatistics(); public static Dictionary DictDataStatistics = new Dictionary(); #region IOAttributes public static Dictionary DictAxisCardDI { get; set; } = new Dictionary(); public static Dictionary DictAxisCardDO { get; set; } = new Dictionary(); public static Dictionary DictIOCardDI { get; set; } = new Dictionary(); public static Dictionary DictIOCardDO { get; set; } = new Dictionary(); public static Dictionary DictPLCDI { get; set; } = new Dictionary(); public static Dictionary DictPLCDO { get; set; } = new Dictionary(); public static Dictionary DictRobotDI { get; set; } = new Dictionary(); public static Dictionary DictRobotDO { get; set; } = new Dictionary(); #endregion public static void ReadCurrentMaterial(string strPath) { newIni = new Ini(strPath + "\\料号选择.ini"); StrCurrentMaterialItem = newIni.ReadIni("System", "当前料号", "料号1"); } public static void ReadConfigFile(string strPath) { BaseFilePath = strPath; newIni = new Ini(BaseFilePath + "\\Config" + "\\System.ini"); newIni.DirectoryCreate(BaseFilePath); newIni.DirectoryCreate(BaseFilePath + "\\Config"); newIni.DirectoryCreate(BaseFilePath + "\\Excel"); newIni.DirectoryCreate(BaseFilePath + "\\VmVision"); //newIni.DirectoryCreate(BaseFilePath + "\\EditPath"); newIni.DirectoryCreate(BaseFilePath + "\\Excel\\ErrorPicture"); newIni.CreateFile(BaseFilePath + "\\Config\\System.ini"); newIni.WriteIni("System", "ParaFilePath", BaseFilePath); ProDataFilePath = Application.StartupPath + "\\ProData"; newIni.DirectoryCreate(ProDataFilePath + "\\ElseLogs"); newIni.DirectoryCreate(ProDataFilePath + "\\Help"); newIni.DirectoryCreate(ProDataFilePath + "\\AlarmLog"); newIni.DirectoryCreate(ProDataFilePath + "\\DataLog"); string SysLanguage = newIni.ReadIni("System", "SysLanguage", "Chinese"); switch(SysLanguage) { case "Chinese": CurrentLanguage = Language.Chinese; break; case "English": CurrentLanguage = Language.English; break; case "Other": CurrentLanguage = Language.Other; break; default: CurrentLanguage = Language.Chinese; break; } MachineName = newIni.ReadIni("System", "MachineName", "T03"); StationCount = (ushort)Convert.ToInt32( newIni.ReadIni("System", "StationCount", "1")); //YieldStatisticsDays = (ushort)Convert.ToInt32(newIni.ReadIni("System", "OutputStatisticsDays", "30")); StrVisionVMSolutionPath = newIni.ReadIni("VisionSolution", "VisionVMSolutionPath", ""); IsVisionEnable = newIni.ReadIni("VisionSolution", "VisionEnable", "false") == "false" ? false : true; StrOperatorPassword = newIni.ReadIni("Passward", "Operator", "1"); StrEngineerPassword = newIni.ReadIni("Passward", "Engineer", "2"); //DataStatistics.ReadDataStatistics(true); //DataStatistics.SaveDataStatistics(); } public static void ChangeOperationLevel() { OperationLevelEvent?.Invoke(); } public static void ChangeLanuge() { ChangeLanguageEvent?.Invoke(); } public static void ExitSys() { ExitEvent?.Invoke(); } public static void ChangeForm(int iFormNo) { ChangeFormEvent?.Invoke(iFormNo); if(iFormNo ==2 ) { IsMannulUISeleted = true; } else { IsMannulUISeleted = false; } } } }