using System; using System.Xml; using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.IOCore; using Aitex.Core.RT.Log; using Aitex.Core.Util; namespace VirgoRT.Devices { public class IoTemperatureCtrl : BaseDevice, IDevice { // Fields // private readonly AOAccessor _aoSubstrate; private readonly AIAccessor _aiCtrlTemp; private readonly AIAccessor _aiMonitorTemp; // Properties // public double SP { get { return null != _aoSubstrate ? _aoSubstrate.Value : 0; } set { if (null != _aoSubstrate) _aoSubstrate.Value = (short)value; } } public double CtrlTemp { get { return null != _aiCtrlTemp ? _aiCtrlTemp.Value : 0; } } public double MonitorTemp { get { return null != _aiMonitorTemp ? _aiMonitorTemp.Value : 0; } } // Constructor // public IoTemperatureCtrl(string module, XmlElement node, string ioModule = "") { base.Module = module; base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _aoSubstrate = ParseAoNode("aoSetpoint", node, ioModule); _aiCtrlTemp = ParseAiNode("aiCtrlFB", node, ioModule); _aiMonitorTemp = ParseAiNode("aiMonitorFB", node, ioModule); //_scEnableLeftTcAsControlTc = ParseScNodeBool("scEnalbeLeftTcAsControlTc", node); //_scMaxDifferenceTcValue = ParseScNodeDouble("scElectrodeTcDifferenceMaxValue", node); //_scManualProcessElectrodeCriticalTemperature = ParseScNodeDouble("scManualProcessElectrodeCriticalTemperature", node); //_leftTc = ParseDeviceNode("deviceLeftElectrodeTc", node); //_rightTc = ParseDeviceNode("deviceRightElectrodeTc", node); //_valveElectrodeWater = ParseDeviceNode("deviceElectrodeWaterValve", node); //_diLogicIsRfPoweringHeatupMode = ParseDiNode("diLogicIsRfPoweringHeatupMode", node); //_diLogicManualProcessRfPowering = ParseDiNode("diLogicManualProcessRfPowering", node); } public bool Initialize() { //DATA.Subscribe(string.Format("{0}.IoTemperatureCtrl.{1}.SubstrateTemperature", Module, Name), // () => MonitorTemp); DATA.Subscribe(string.Format("Device.{0}.{1}", Module, Name), () => { AITHeaterData data = new AITHeaterData() { DeviceName = Name, DeviceSchematicId = DeviceID, DisplayName = Display, SetPoint = SP, FeedBack = CtrlTemp, MonitorTcFeedBack = MonitorTemp }; return data; }, SubscriptionAttribute.FLAG.IgnoreSaveDB); DEVICE.Register(string.Format("{0}.{1}", Name, AITHeaterOperation.SetTemperature), (out string reason, int time, object[] param) => { reason = ""; double target = Convert.ToDouble((string)param[0]); SP = target; return true; }); return true; } public void SetTemperature(double val) { this.SP = val; LOG.Write("Temperature of substrate is set to " + val); } public void Terminate() { } public void Monitor() { } public void Reset() { } } }