GlobalPara.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using BaseLibRWFile;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. namespace BaseLibRWFile
  7. {
  8. public class GlobalPara
  9. {
  10. public static Ini newIni;
  11. //UI Size
  12. public static Size PLCSize { get; set; } = new Size(0, 0);
  13. public static Size TabSize { get; set; } = new Size(0, 0);
  14. public static Size VisionSize { get; set; } = new Size(0, 0);
  15. public static Size MainPanelSize { get; set; } = new Size(0, 0);
  16. //SystemParameter
  17. public static Language CurrentLanguage { get; set; } = Language.Chinese;
  18. public static event Action ChangeLanguageEvent;
  19. public static event Action ExitEvent;
  20. public static event Action<int> ChangeFormEvent;
  21. public static event Action OperationLevelEvent;
  22. public static string BaseFilePath { get; set; }
  23. public static string ProDataFilePath { get; set; }
  24. public static string MachineName { get; set; }
  25. public static ushort StationCount { get; set; }//
  26. public static string StrVisionVMSolutionPath { get; set; }
  27. public static bool IsVisionEnable { get; set; }
  28. public static bool IsSysInitOK { get; set; } = false;
  29. public static string StrCurrentMaterialItem { get; set; }
  30. public static bool IsMannulUISeleted { get; set; }
  31. public static bool IsMannulIOSeleted { get; set; }
  32. public static bool isPLCMotionSeleted { get; set; }
  33. public static string StrOperatorPassword { get; set; }
  34. public static string StrEngineerPassword { get; set; }
  35. public static bool isOperatorSelect { get; set; } = false;
  36. public static bool isEngineerSelect { get; set; } = false;
  37. #region MachineState / OperationLevel / MachineMode
  38. private static MachineState _currentMachineState = MachineState.WaitReset;
  39. public static MachineState LastMachineState { get; private set; } = MachineState.WaitReset;
  40. public static MachineState CurrentMachineState
  41. {
  42. get { return _currentMachineState; }
  43. set
  44. {
  45. if (_currentMachineState != value)
  46. {
  47. LastMachineState = _currentMachineState;
  48. _currentMachineState = value;
  49. }
  50. }
  51. }
  52. private static OperationLevel _currentOperationLevel = OperationLevel.SWEngineer;
  53. public static OperationLevel LastOperationLevel { get; private set; } = OperationLevel.SWEngineer;
  54. public static OperationLevel CurrentOperationLevel
  55. {
  56. get { return _currentOperationLevel; }
  57. set
  58. {
  59. if (_currentOperationLevel != value)
  60. {
  61. LastOperationLevel = _currentOperationLevel;
  62. _currentOperationLevel = value;
  63. }
  64. }
  65. }
  66. private static MachineMode _currentMachineMode = MachineMode.Run;
  67. public static MachineMode LastMachineMode { get; private set; } = MachineMode.Run;
  68. public static MachineMode CurrentMachineMode
  69. {
  70. get { return _currentMachineMode; }
  71. set
  72. {
  73. if (_currentMachineMode != value)
  74. {
  75. LastMachineMode = _currentMachineMode;
  76. _currentMachineMode = value;
  77. }
  78. }
  79. }
  80. #endregion
  81. //MachineOutput
  82. public static ushort YieldStatisticsDays { get; set; }
  83. //public static YieldStatistics YieldStatistics = new YieldStatistics();
  84. //public static TimeStatistics TimeStatistics = new TimeStatistics();
  85. //public static CTStatistics CTStatistics = new CTStatistics();
  86. public static Dictionary<DateTime, YieldStatistics> DictDataStatistics = new Dictionary<DateTime, YieldStatistics>();
  87. #region IOAttributes
  88. public static Dictionary<int, IOAttributes> DictAxisCardDI { get; set; } = new Dictionary<int, IOAttributes>();
  89. public static Dictionary<int, IOAttributes> DictAxisCardDO { get; set; } = new Dictionary<int, IOAttributes>();
  90. public static Dictionary<int, IOAttributes> DictIOCardDI { get; set; } = new Dictionary<int, IOAttributes>();
  91. public static Dictionary<int, IOAttributes> DictIOCardDO { get; set; } = new Dictionary<int, IOAttributes>();
  92. public static Dictionary<int, IOAttributes> DictPLCDI { get; set; } = new Dictionary<int, IOAttributes>();
  93. public static Dictionary<int, IOAttributes> DictPLCDO { get; set; } = new Dictionary<int, IOAttributes>();
  94. public static Dictionary<int, IOAttributes> DictRobotDI { get; set; } = new Dictionary<int, IOAttributes>();
  95. public static Dictionary<int, IOAttributes> DictRobotDO { get; set; } = new Dictionary<int, IOAttributes>();
  96. #endregion
  97. public static void ReadCurrentMaterial(string strPath)
  98. {
  99. newIni = new Ini(strPath + "\\料号选择.ini");
  100. StrCurrentMaterialItem = newIni.ReadIni("System", "当前料号", "料号1");
  101. }
  102. public static void ReadConfigFile(string strPath)
  103. {
  104. BaseFilePath = strPath;
  105. newIni = new Ini(BaseFilePath + "\\Config" + "\\System.ini");
  106. newIni.DirectoryCreate(BaseFilePath);
  107. newIni.DirectoryCreate(BaseFilePath + "\\Config");
  108. newIni.DirectoryCreate(BaseFilePath + "\\Excel");
  109. newIni.DirectoryCreate(BaseFilePath + "\\VmVision");
  110. //newIni.DirectoryCreate(BaseFilePath + "\\EditPath");
  111. newIni.DirectoryCreate(BaseFilePath + "\\Excel\\ErrorPicture");
  112. newIni.CreateFile(BaseFilePath + "\\Config\\System.ini");
  113. newIni.WriteIni("System", "ParaFilePath", BaseFilePath);
  114. ProDataFilePath = Application.StartupPath + "\\ProData";
  115. newIni.DirectoryCreate(ProDataFilePath + "\\ElseLogs");
  116. newIni.DirectoryCreate(ProDataFilePath + "\\Help");
  117. newIni.DirectoryCreate(ProDataFilePath + "\\AlarmLog");
  118. newIni.DirectoryCreate(ProDataFilePath + "\\DataLog");
  119. string SysLanguage = newIni.ReadIni("System", "SysLanguage", "Chinese");
  120. switch(SysLanguage)
  121. {
  122. case "Chinese":
  123. CurrentLanguage = Language.Chinese;
  124. break;
  125. case "English":
  126. CurrentLanguage = Language.English;
  127. break;
  128. case "Other":
  129. CurrentLanguage = Language.Other;
  130. break;
  131. default:
  132. CurrentLanguage = Language.Chinese;
  133. break;
  134. }
  135. MachineName = newIni.ReadIni("System", "MachineName", "T03");
  136. StationCount = (ushort)Convert.ToInt32( newIni.ReadIni("System", "StationCount", "1"));
  137. //YieldStatisticsDays = (ushort)Convert.ToInt32(newIni.ReadIni("System", "OutputStatisticsDays", "30"));
  138. StrVisionVMSolutionPath = newIni.ReadIni("VisionSolution", "VisionVMSolutionPath", "");
  139. IsVisionEnable = newIni.ReadIni("VisionSolution", "VisionEnable", "false") == "false" ? false : true;
  140. StrOperatorPassword = newIni.ReadIni("Passward", "Operator", "1");
  141. StrEngineerPassword = newIni.ReadIni("Passward", "Engineer", "2");
  142. //DataStatistics.ReadDataStatistics(true);
  143. //DataStatistics.SaveDataStatistics();
  144. }
  145. public static void ChangeOperationLevel()
  146. {
  147. OperationLevelEvent?.Invoke();
  148. }
  149. public static void ChangeLanuge()
  150. {
  151. ChangeLanguageEvent?.Invoke();
  152. }
  153. public static void ExitSys()
  154. {
  155. ExitEvent?.Invoke();
  156. }
  157. public static void ChangeForm(int iFormNo)
  158. {
  159. ChangeFormEvent?.Invoke(iFormNo);
  160. if(iFormNo ==2 )
  161. {
  162. IsMannulUISeleted = true;
  163. }
  164. else
  165. {
  166. IsMannulUISeleted = false;
  167. }
  168. }
  169. }
  170. }