PageRenderTime 101ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/output/program testing data/FA1B75/FA1B75_UICfg_script.cs

https://bitbucket.org/kumarvvr/data-acquisition-systems
C# | 279 lines | 242 code | 30 blank | 7 comment | 15 complexity | ec870bd2d6972552cdbd4e89c8bcfd78 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml;
  6. using System.IO;
  7. using System.Windows.Forms;
  8. using BHEL.PUMPSDAS.Datatypes;
  9. namespace userscript
  10. {
  11. namespace FA1B75
  12. {
  13. // Note This will be an external script file.
  14. public struct paramUILocation
  15. {
  16. public DataGridViewRow dgvRow;
  17. }
  18. public class FA1B75_UIConfig : UIConfigurator
  19. {
  20. List<Label> UILabelList;
  21. List<DataGridView> UIGridList;
  22. List<AlarmStatus> chAlarmListPrevious;
  23. List<AlarmStatus> chAlarmListCurrent;
  24. ResultParamsBase rp, rpAvg;
  25. MeasurementProfileBase mp, mpAvg;
  26. SpecifiedParamsBase sp;
  27. TestSetupParamsBase tsp;
  28. MachineDetailsBase md;
  29. MachineDescriptor mcd;
  30. List<MeasurementProfileDetails> mpDetails;
  31. List<ResultParamsDetails> rpDetails;
  32. AlarmColors alarmColors;
  33. Dictionary<string, DataGridViewCell> mp_uiDescMap,mp_uiUnitsMap,rp_uiDescMap,rp_uiUnitsMap;
  34. Dictionary<string, DataGridViewCell> mp_uiRealMap,mp_uiAvgMap,rp_uiRealMap,rp_uiAvgMap;
  35. public FA1B75_UIConfig() : base()
  36. {
  37. }
  38. public override void InitializeUIConfig(ref List<Label> UILabelList,
  39. ref List<DataGridView> UIGridList,
  40. ref ResultParamsBase rp,
  41. ref ResultParamsBase rpAvg,
  42. ref MeasurementProfileBase mp,
  43. ref MeasurementProfileBase mpAvg,
  44. ref SpecifiedParamsBase sp,
  45. ref TestSetupParamsBase tsp,
  46. ref MachineDetailsBase md,
  47. ref MachineDescriptor mcd,
  48. List<MeasurementProfileDetails> mpDetails,
  49. List<ResultParamsDetails> rpDetails,
  50. AlarmColors alarmColors)
  51. {
  52. this.UILabelList = UILabelList;
  53. this.UIGridList = UIGridList;
  54. this.rp = rp;
  55. this.rpAvg = rpAvg;
  56. this.mp = mp;
  57. this.mpAvg = mpAvg;
  58. this.sp = sp;
  59. this.tsp = tsp;
  60. this.md = md;
  61. this.mpDetails = mpDetails;
  62. this.alarmColors = alarmColors;
  63. this.mcd = mcd;
  64. this.rpDetails = rpDetails;
  65. mp_uiDescMap = new Dictionary<string,DataGridViewCell>();
  66. mp_uiUnitsMap = new Dictionary<string,DataGridViewCell>();
  67. rp_uiDescMap = new Dictionary<string,DataGridViewCell>();
  68. rp_uiUnitsMap = new Dictionary<string,DataGridViewCell>();
  69. mp_uiRealMap = new Dictionary<string,DataGridViewCell>();
  70. mp_uiAvgMap = new Dictionary<string,DataGridViewCell>();
  71. rp_uiRealMap = new Dictionary<string,DataGridViewCell>();
  72. rp_uiAvgMap = new Dictionary<string,DataGridViewCell>();
  73. for(int i = 0;i<17;i++)
  74. {
  75. UIGridList[0].Rows.Add(new Object[]{"","","",""});
  76. UIGridList[2].Rows.Add(new Object[]{"","","",""});
  77. }
  78. for(int i = 0;i<5;i++)
  79. {
  80. UIGridList[1].Rows.Add(new Object[]{"","","",""});
  81. UIGridList[3].Rows.Add(new Object[]{"","","",""});
  82. }
  83. chAlarmListCurrent = new List<AlarmStatus>();
  84. chAlarmListPrevious = new List<AlarmStatus>();
  85. }
  86. public override void UpdateStaticUIControls()
  87. {
  88. // Add all the mapping code here....
  89. rp_uiDescMap.Add("_percentageflow",UIGridList[0].Rows[0].Cells[0]);
  90. mp_uiDescMap.Add("_pumpspeed",UIGridList[0].Rows[1].Cells[0]);
  91. mp_uiDescMap.Add("_suctionwatertemp",UIGridList[0].Rows[2].Cells[0]);
  92. mp_uiDescMap.Add("_suctionflow",UIGridList[0].Rows[3].Cells[0]);
  93. mp_uiDescMap.Add("_suctionpressure",UIGridList[0].Rows[4].Cells[0]);
  94. mp_uiDescMap.Add("_dischargepressure",UIGridList[0].Rows[5].Cells[0]);
  95. mp_uiDescMap.Add("_motorvoltage",UIGridList[1].Rows[0].Cells[0]);
  96. mp_uiDescMap.Add("_motorcurrent",UIGridList[1].Rows[1].Cells[0]);
  97. mp_uiDescMap.Add("_motorinputpower",UIGridList[1].Rows[2].Cells[0]);
  98. mp_uiDescMap.Add("_inletoiltemp",UIGridList[2].Rows[0].Cells[0]);
  99. mp_uiDescMap.Add("_journal_de",UIGridList[2].Rows[1].Cells[0]);
  100. mp_uiDescMap.Add("_journal_nde",UIGridList[2].Rows[2].Cells[0]);
  101. mp_uiDescMap.Add("_vib_de_h",UIGridList[3].Rows[0].Cells[0]);
  102. mp_uiDescMap.Add("_vib_de_v",UIGridList[3].Rows[1].Cells[0]);
  103. mp_uiDescMap.Add("_vib_nde_h",UIGridList[3].Rows[2].Cells[0]);
  104. mp_uiDescMap.Add("_vib_nde_v",UIGridList[3].Rows[3].Cells[0]);
  105. mp_uiDescMap.Add("_vib_nde_a",UIGridList[3].Rows[4].Cells[0]);
  106. rp_uiUnitsMap.Add("_percentageflow",UIGridList[0].Rows[0].Cells[1]);
  107. mp_uiUnitsMap.Add("_pumpspeed",UIGridList[0].Rows[1].Cells[1]);
  108. mp_uiUnitsMap.Add("_suctionwatertemp",UIGridList[0].Rows[2].Cells[1]);
  109. mp_uiUnitsMap.Add("_suctionflow",UIGridList[0].Rows[3].Cells[1]);
  110. mp_uiUnitsMap.Add("_suctionpressure",UIGridList[0].Rows[4].Cells[1]);
  111. mp_uiUnitsMap.Add("_dischargepressure",UIGridList[0].Rows[5].Cells[1]);
  112. mp_uiUnitsMap.Add("_motorvoltage",UIGridList[1].Rows[0].Cells[1]);
  113. mp_uiUnitsMap.Add("_motorcurrent",UIGridList[1].Rows[1].Cells[1]);
  114. mp_uiUnitsMap.Add("_motorinputpower",UIGridList[1].Rows[2].Cells[1]);
  115. mp_uiUnitsMap.Add("_inletoiltemp",UIGridList[2].Rows[0].Cells[1]);
  116. mp_uiUnitsMap.Add("_journal_de",UIGridList[2].Rows[1].Cells[1]);
  117. mp_uiUnitsMap.Add("_journal_nde",UIGridList[2].Rows[2].Cells[1]);
  118. mp_uiUnitsMap.Add("_vib_de_h",UIGridList[3].Rows[0].Cells[1]);
  119. mp_uiUnitsMap.Add("_vib_de_v",UIGridList[3].Rows[1].Cells[1]);
  120. mp_uiUnitsMap.Add("_vib_nde_h",UIGridList[3].Rows[2].Cells[1]);
  121. mp_uiUnitsMap.Add("_vib_nde_v",UIGridList[3].Rows[3].Cells[1]);
  122. mp_uiUnitsMap.Add("_vib_nde_a",UIGridList[3].Rows[4].Cells[1]);
  123. for (int i = 0; i < mpDetails.Count; i++)
  124. {
  125. MeasurementProfileDetails mpd = mpDetails[i];
  126. string pname = mpd.paramname;
  127. try
  128. {
  129. mp_uiDescMap[pname].Value = mpd.paramdescription;
  130. mp_uiUnitsMap[pname].Value = mpd.paramunits;
  131. }
  132. catch(Exception ex)
  133. {
  134. // Do Nothing...
  135. }
  136. }
  137. for (int i = 0; i < rpDetails.Count; i++)
  138. {
  139. ResultParamsDetails rpd = rpDetails[i];
  140. string pname = rpd.paramname;
  141. try
  142. {
  143. rp_uiDescMap[pname].Value = rpd.paramdescription;
  144. rp_uiUnitsMap[pname].Value = rpd.paramunits;
  145. }
  146. catch(Exception ex)
  147. {
  148. // Ignore the error...
  149. }
  150. }
  151. ResetAlarmColors(true);
  152. UILabelList[0].Text += sp.GetProjectName();
  153. UILabelList[1].Text += mcd.MachineUniqueCode;
  154. ToolTip tooltipmucode = new ToolTip();
  155. tooltipmucode.SetToolTip(UILabelList[1], mcd.MachineDesc);
  156. UILabelList[2].Text += md.GetTestReference();
  157. UILabelList[3].Text = "";
  158. UILabelList[4].Text = "";
  159. UILabelList[5].Text = "";
  160. }
  161. private void ResetAlarmColors(bool isResetAll)
  162. {
  163. string pname;
  164. if(isResetAll)
  165. {
  166. for (int i = 0; i < UIGridList.Count; i++)
  167. {
  168. for(int j=0;j<UIGridList[i].Rows.Count;j++)
  169. {
  170. UIGridList[i].Rows[j].Cells[3].Style.ForeColor = alarmColors.defaultColor;
  171. UIGridList[i].Rows[j].Cells[3].Style.BackColor = alarmColors.defaultBackColor;
  172. }
  173. }
  174. return;
  175. }
  176. else
  177. {
  178. if(chAlarmListPrevious != null)
  179. {
  180. for(int i = 0;i<chAlarmListPrevious.Count;i++)
  181. {
  182. pname = chAlarmListPrevious[i].pname;
  183. mp_uiRealMap[pname].Style.ForeColor = alarmColors.defaultColor;
  184. }
  185. }
  186. }
  187. return;
  188. }
  189. public override void UpdateDynamicUIControls(List<AlarmStatus> chAlarmListCurrent, bool isAverageUpdateRequired)
  190. {
  191. string pname;
  192. // Add the value update codes here...
  193. // Real Values
  194. UIGridList[0].Rows[0].Cells[3].Value=rp.GetValue("_percentageflow");
  195. UIGridList[0].Rows[1].Cells[3].Value=mp.GetValue("_pumpspeed");
  196. UIGridList[0].Rows[2].Cells[3].Value=mp.GetValue("_suctionwatertemp");
  197. UIGridList[0].Rows[3].Cells[3].Value=mp.GetValue("_suctionflow");
  198. UIGridList[0].Rows[4].Cells[3].Value=mp.GetValue("_suctionpressure");
  199. UIGridList[0].Rows[5].Cells[3].Value=mp.GetValue("_dischargepressure");
  200. UIGridList[1].Rows[0].Cells[3].Value=mp.GetValue("_motorvoltage");
  201. UIGridList[1].Rows[1].Cells[3].Value=mp.GetValue("_motorcurrent");
  202. UIGridList[1].Rows[2].Cells[3].Value=mp.GetValue("_motorinputpower");
  203. UIGridList[2].Rows[0].Cells[3].Value=mp.GetValue("_inletoiltemp");
  204. UIGridList[2].Rows[1].Cells[3].Value=mp.GetValue("_journal_de");
  205. UIGridList[2].Rows[2].Cells[3].Value=mp.GetValue("_journal_nde");
  206. UIGridList[3].Rows[0].Cells[3].Value=mp.GetValue("_vib_de_h");
  207. UIGridList[3].Rows[1].Cells[3].Value=mp.GetValue("_vib_de_v");
  208. UIGridList[3].Rows[2].Cells[3].Value=mp.GetValue("_vib_nde_h");
  209. UIGridList[3].Rows[3].Cells[3].Value=mp.GetValue("_vib_nde_v");
  210. UIGridList[3].Rows[4].Cells[3].Value=mp.GetValue("_vib_nde_a");
  211. if(isAverageUpdateRequired)
  212. {
  213. UIGridList[0].Rows[0].Cells[2].Value=rpAvg.GetValue("_percentageflow");
  214. UIGridList[0].Rows[1].Cells[2].Value=mpAvg.GetValue("_pumpspeed");
  215. UIGridList[0].Rows[2].Cells[2].Value=mpAvg.GetValue("_suctionwatertemp");
  216. UIGridList[0].Rows[3].Cells[2].Value=mpAvg.GetValue("_suctionflow");
  217. UIGridList[0].Rows[4].Cells[2].Value=mpAvg.GetValue("_suctionpressure");
  218. UIGridList[0].Rows[5].Cells[2].Value=mpAvg.GetValue("_dischargepressure");
  219. UIGridList[1].Rows[0].Cells[2].Value=mpAvg.GetValue("_motorvoltage");
  220. UIGridList[1].Rows[1].Cells[2].Value=mpAvg.GetValue("_motorcurrent");
  221. UIGridList[1].Rows[2].Cells[2].Value=mpAvg.GetValue("_motorinputpower");
  222. UIGridList[2].Rows[0].Cells[2].Value=mpAvg.GetValue("_inletoiltemp");
  223. UIGridList[2].Rows[1].Cells[2].Value=mpAvg.GetValue("_journal_de");
  224. UIGridList[2].Rows[2].Cells[2].Value=mpAvg.GetValue("_journal_nde");
  225. UIGridList[3].Rows[0].Cells[2].Value=mpAvg.GetValue("_vib_de_h");
  226. UIGridList[3].Rows[1].Cells[2].Value=mpAvg.GetValue("_vib_de_v");
  227. UIGridList[3].Rows[2].Cells[2].Value=mpAvg.GetValue("_vib_nde_h");
  228. UIGridList[3].Rows[3].Cells[2].Value=mpAvg.GetValue("_vib_nde_v");
  229. UIGridList[3].Rows[4].Cells[2].Value=mpAvg.GetValue("_vib_nde_a");
  230. }
  231. this.chAlarmListCurrent = chAlarmListCurrent;
  232. ResetAlarmColors(false);
  233. //this.chAlarmListPrevious = null;
  234. this.chAlarmListPrevious = this.chAlarmListCurrent;
  235. if(chAlarmListCurrent !=null)
  236. {
  237. for(int i = 0;i<this.chAlarmListCurrent.Count;i++)
  238. {
  239. pname = this.chAlarmListCurrent[i].pname;
  240. if(this.chAlarmListCurrent[i].alarmType == AlarmType.HIGH_ALARM)
  241. mp_uiRealMap[pname].Style.ForeColor = alarmColors.highAlarmColor;
  242. else
  243. mp_uiRealMap[pname].Style.ForeColor = alarmColors.lowAlarmColor;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }