123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- 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<int> 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<DateTime, YieldStatistics> DictDataStatistics = new Dictionary<DateTime, YieldStatistics>();
-
- #region IOAttributes
- public static Dictionary<int, IOAttributes> DictAxisCardDI { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictAxisCardDO { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictIOCardDI { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictIOCardDO { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictPLCDI { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictPLCDO { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictRobotDI { get; set; } = new Dictionary<int, IOAttributes>();
- public static Dictionary<int, IOAttributes> DictRobotDO { get; set; } = new Dictionary<int, IOAttributes>();
- #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;
- }
- }
- }
- }
|