IoTemperatureControl.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.RT.DataCenter;
  5. using Aitex.Core.RT.Device;
  6. using Aitex.Core.RT.IOCore;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.Util;
  9. namespace VirgoRT.Devices
  10. {
  11. public class IoTemperatureCtrl : BaseDevice, IDevice
  12. {
  13. // Fields
  14. //
  15. private readonly AOAccessor _aoSubstrate;
  16. private readonly AIAccessor _aiCtrlTemp;
  17. private readonly AIAccessor _aiMonitorTemp;
  18. // Properties
  19. //
  20. public double SP
  21. {
  22. get { return null != _aoSubstrate ? _aoSubstrate.Value : 0; }
  23. set { if (null != _aoSubstrate) _aoSubstrate.Value = (short)value; }
  24. }
  25. public double CtrlTemp
  26. {
  27. get { return null != _aiCtrlTemp ? _aiCtrlTemp.Value : 0; }
  28. }
  29. public double MonitorTemp
  30. {
  31. get { return null != _aiMonitorTemp ? _aiMonitorTemp.Value : 0; }
  32. }
  33. // Constructor
  34. //
  35. public IoTemperatureCtrl(string module, XmlElement node, string ioModule = "")
  36. {
  37. base.Module = module;
  38. base.Name = node.GetAttribute("id");
  39. base.Display = node.GetAttribute("display");
  40. base.DeviceID = node.GetAttribute("schematicId");
  41. _aoSubstrate = ParseAoNode("aoSetpoint", node, ioModule);
  42. _aiCtrlTemp = ParseAiNode("aiCtrlFB", node, ioModule);
  43. _aiMonitorTemp = ParseAiNode("aiMonitorFB", node, ioModule);
  44. //_scEnableLeftTcAsControlTc = ParseScNodeBool("scEnalbeLeftTcAsControlTc", node);
  45. //_scMaxDifferenceTcValue = ParseScNodeDouble("scElectrodeTcDifferenceMaxValue", node);
  46. //_scManualProcessElectrodeCriticalTemperature = ParseScNodeDouble("scManualProcessElectrodeCriticalTemperature", node);
  47. //_leftTc = ParseDeviceNode<IoThermalCouple>("deviceLeftElectrodeTc", node);
  48. //_rightTc = ParseDeviceNode<IoThermalCouple>("deviceRightElectrodeTc", node);
  49. //_valveElectrodeWater = ParseDeviceNode<IoValve>("deviceElectrodeWaterValve", node);
  50. //_diLogicIsRfPoweringHeatupMode = ParseDiNode("diLogicIsRfPoweringHeatupMode", node);
  51. //_diLogicManualProcessRfPowering = ParseDiNode("diLogicManualProcessRfPowering", node);
  52. }
  53. public bool Initialize()
  54. {
  55. //DATA.Subscribe(string.Format("{0}.IoTemperatureCtrl.{1}.SubstrateTemperature", Module, Name),
  56. // () => MonitorTemp);
  57. DATA.Subscribe(string.Format("Device.{0}.{1}", Module, Name), () =>
  58. {
  59. AITHeaterData data = new AITHeaterData()
  60. {
  61. DeviceName = Name,
  62. DeviceSchematicId = DeviceID,
  63. DisplayName = Display,
  64. SetPoint = SP,
  65. FeedBack = CtrlTemp,
  66. MonitorTcFeedBack = MonitorTemp
  67. };
  68. return data;
  69. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  70. DEVICE.Register(string.Format("{0}.{1}", Name, AITHeaterOperation.SetTemperature),
  71. (out string reason, int time, object[] param) =>
  72. {
  73. reason = "";
  74. double target = Convert.ToDouble((string)param[0]);
  75. SP = target;
  76. return true;
  77. });
  78. return true;
  79. }
  80. public void SetTemperature(double val)
  81. {
  82. this.SP = val;
  83. LOG.Write("Temperature of substrate is set to " + val);
  84. }
  85. public void Terminate()
  86. {
  87. }
  88. public void Monitor()
  89. {
  90. }
  91. public void Reset()
  92. {
  93. }
  94. }
  95. }