123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.CommonData.DeviceData;
- using System;
- using System.Xml;
- using Venus_Core;
- namespace Venus_RT.Devices.IODevices
- {
- public class IoHighTemperatureHeater : BaseDevice, IDevice
- {
- private readonly DIAccessor _diPowerOnFeedback;
- private readonly DOAccessor _doPowerOn;
- private readonly AIAccessor _aiTemperatureFeedback;
- private readonly AOAccessor _aoTemperatureSetPoint;
- private readonly DIAccessor _diGoPosition1Feedback;
- private readonly DOAccessor _doGoPosition1On;
- private readonly DIAccessor _diGoPosition2Feedback;
- private readonly DOAccessor _doGoPosition2On;
- private readonly DIAccessor _diGoPosition3Feedback;
- private readonly DOAccessor _doGoPosition3On;
- private readonly DIAccessor _diGoPosition4Feedback;
- private readonly DOAccessor _doGoPosition4On;
- private readonly DIAccessor _diGoPosition5Feedback;
- private readonly DOAccessor _doGoPosition5On;
- private readonly DIAccessor _diGoOriginFeedback;
- private readonly DOAccessor _doGoOriginOn;
- private readonly AOAccessor _aoLiftServoPosition1;
- private readonly AOAccessor _aoLiftServoPosition2;
- private readonly AOAccessor _aoLiftServoPosition3;
- private readonly AOAccessor _aoLiftServoPosition4;
- private readonly AOAccessor _aoLiftServoPosition5;
- private readonly AOAccessor _aoOriginSearchHighSpeed;
- private readonly AOAccessor _aoOriginSearchLowSpeed;
- private readonly AOAccessor _aoAbsMoveSpeed;
- private readonly AOAccessor _aoMaximusMoveSpeed;
- private readonly AOAccessor _aoSoftDownLimit;
- private readonly AOAccessor _aoSoftUpLimit;
- private readonly AOAccessor _aoRatio;
- private readonly DeviceTimer _originTimer = new DeviceTimer();
- private readonly DeviceTimer _position1Timer = new DeviceTimer();
- private readonly DeviceTimer _position2Timer = new DeviceTimer();
- private readonly DeviceTimer _position3Timer = new DeviceTimer();
- private readonly DeviceTimer _position4Timer = new DeviceTimer();
- private readonly DeviceTimer _position5Timer = new DeviceTimer();
- private int _goPositionTime = 60 * 1000;
- private float HighTemperatureHeaterTemperatureSetPoint;
- private string HighTemperatureHeaterPositipnSetPoint;
- private float HighTemperatureHeaterRatioSetPoint;
- private float _maxTemperatureSetPoint;
- private float _minTemperatureSetPoint;
- private AITHighTemperatureHeaterData DeviceData
- {
- get
- {
- return new AITHighTemperatureHeaterData
- {
- Module = Module,
- DeviceName = Name,
- DisplayName = Display,
- HighTemperatureHeaterPositionFeedBack = CurrentPosition.ToString(),
- HighTemperatureHeaterIsonFeedBack = HighTemperatureHeaterIsOn,
- HighTemperatureHeaterTemperatureFeedBack = HighTemperatureHighHeaterTemperature,
- HighTemperatureHeaterRatioFeedBack = HighTemperatureHeaterRatio,
- HighTemperatureHeaterPositionSetPoint = HighTemperatureHeaterPositipnSetPoint,
- HighTemperatureHeaterTemperatureSetPoint = HighTemperatureHeaterTemperatureSetPoint,
- HighTemperatureHeaterRatioSetPoint = HighTemperatureHeaterRatioSetPoint,
- };
- }
- }
- public HighTemperatureHeaterPosition CurrentPosition
- {
- get
- {
- if (_diGoOriginFeedback.Value == true && _diGoPosition1Feedback.Value == false && _diGoPosition2Feedback.Value == false && _diGoPosition3Feedback.Value == false && _diGoPosition4Feedback.Value == false && _diGoPosition5Feedback.Value == false)
- {
- return HighTemperatureHeaterPosition.Origin;
- }
- if (_diGoOriginFeedback.Value == false && _diGoPosition1Feedback.Value == true && _diGoPosition2Feedback.Value == false && _diGoPosition3Feedback.Value == false && _diGoPosition4Feedback.Value == false && _diGoPosition5Feedback.Value == false)
- {
- return HighTemperatureHeaterPosition.Position1;
- }
- else if (_diGoOriginFeedback.Value == false && _diGoPosition1Feedback.Value == false && _diGoPosition2Feedback.Value == true && _diGoPosition3Feedback.Value == false && _diGoPosition4Feedback.Value == false && _diGoPosition5Feedback.Value == false)
- {
- return HighTemperatureHeaterPosition.Position2;
- }
- else if (_diGoOriginFeedback.Value == false && _diGoPosition1Feedback.Value == false && _diGoPosition2Feedback.Value == false && _diGoPosition3Feedback.Value == true && _diGoPosition4Feedback.Value == false && _diGoPosition5Feedback.Value == false)
- {
- return HighTemperatureHeaterPosition.Position3;
- }
- else if (_diGoOriginFeedback.Value == false && _diGoPosition1Feedback.Value == false && _diGoPosition2Feedback.Value == false && _diGoPosition3Feedback.Value == false && _diGoPosition4Feedback.Value == true && _diGoPosition5Feedback.Value == false)
- {
- return HighTemperatureHeaterPosition.Position4;
- }
- else if (_diGoOriginFeedback.Value == false && _diGoPosition1Feedback.Value == false && _diGoPosition2Feedback.Value == false && _diGoPosition3Feedback.Value == false && _diGoPosition4Feedback.Value == false && _diGoPosition5Feedback.Value == true)
- {
- return HighTemperatureHeaterPosition.Position5;
- }
- else
- {
- return HighTemperatureHeaterPosition.UnKnow;
- }
- }
- }
- public bool HighTemperatureHeaterIsOn
- {
- get
- {
- if (_diPowerOnFeedback.Value == true && _doPowerOn.Value == true)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- set
- {
- SC.SetItemValue($"{Module}.HighTemperatureHeater.IsOn", value);
- }
- }
- public float HighTemperatureHighHeaterTemperature
- {
- get
- {
- if (_aiTemperatureFeedback == null) return -1;
- return _GetRealFloat(_aiTemperatureFeedback);
- }
- set
- {
- if (value <= _maxTemperatureSetPoint && value >= _minTemperatureSetPoint)
- {
- HighTemperatureHeaterTemperatureSetPoint = value;
- SC.SetItemValue($"{Module}.HighTemperatureHeater.Temperature", value);
- }
- else
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"高温Heater设定温度失败,由于设定温度{value}不在区间[{_minTemperatureSetPoint},{_maxTemperatureSetPoint}]");
- }
-
- }
- }
- public float HighTemperatureHeaterRatio
- {
- get
- {
- if (_aoRatio == null) return -1;
- return _GetRealFloat(_aoRatio);
- }
- set
- {
- HighTemperatureHeaterRatioSetPoint = value;
- SC.SetItemValue($"{Module}.HighTemperatureHeater.Ratio", value);
- }
- }
- public IoHighTemperatureHeater(string module, XmlElement node, string ioModule = "")
- {
- base.Module = module;
- base.Name = node.GetAttribute("id");
- base.Display = node.GetAttribute("display");
- base.DeviceID = node.GetAttribute("schematicId");
- _diPowerOnFeedback = ParseDiNode("diPowerOnFeedback", node, ioModule);
- _doPowerOn = ParseDoNode("doPowerOn", node, ioModule);
- _aiTemperatureFeedback = ParseAiNode("aiTemperatureFeedback", node, ioModule);
- _aoTemperatureSetPoint = ParseAoNode("aoTemperatureSetPoint", node, ioModule);
- _diGoPosition1Feedback = ParseDiNode("diGoPosition1Feedback", node, ioModule);
- _doGoPosition1On = ParseDoNode("doGoPosition1On", node, ioModule);
- _diGoPosition2Feedback = ParseDiNode("diGoPosition2Feedback", node, ioModule);
- _doGoPosition2On = ParseDoNode("doGoPosition2On", node, ioModule);
- _diGoPosition3Feedback = ParseDiNode("diGoPosition3Feedback", node, ioModule);
- _doGoPosition3On = ParseDoNode("doGoPosition3On", node, ioModule);
- _diGoPosition4Feedback = ParseDiNode("diGoPosition4Feedback", node, ioModule);
- _doGoPosition4On = ParseDoNode("doGoPosition4On", node, ioModule);
- _diGoPosition5Feedback = ParseDiNode("diGoPosition5Feedback", node, ioModule);
- _doGoPosition5On = ParseDoNode("doGoPosition5On", node, ioModule);
- _diGoOriginFeedback = ParseDiNode("diGoOriginFeedback", node, ioModule);
- _doGoOriginOn = ParseDoNode("doGoOriginOn", node, ioModule);
- _aoLiftServoPosition1 = ParseAoNode("aoLiftServoPosition1", node, ioModule);
- _aoLiftServoPosition2 = ParseAoNode("aoLiftServoPosition2", node, ioModule);
- _aoLiftServoPosition3 = ParseAoNode("aoLiftServoPosition3", node, ioModule);
- _aoLiftServoPosition4 = ParseAoNode("aoLiftServoPosition4", node, ioModule);
- _aoLiftServoPosition5 = ParseAoNode("aoLiftServoPosition5", node, ioModule);
- _aoOriginSearchHighSpeed = ParseAoNode("aoOriginSearchHighSpeed", node, ioModule);
- _aoOriginSearchLowSpeed = ParseAoNode("aoOriginSearchLowSpeed", node, ioModule);
- _aoAbsMoveSpeed = ParseAoNode("aoAbsMoveSpeed", node, ioModule);
- _aoMaximusMoveSpeed = ParseAoNode("aoMaximusMoveSpeed", node, ioModule);
- _aoSoftDownLimit = ParseAoNode("aoSoftDownLimit", node, ioModule);
- _aoSoftUpLimit = ParseAoNode("aoSoftUpLimit", node, ioModule);
- _aoRatio= ParseAoNode("aoRatio", node, ioModule);
- _maxTemperatureSetPoint = Convert.ToSingle(SC.GetConfigItem($"{module}.HighTemperatureHeater.Temperature").Max);
- _minTemperatureSetPoint = Convert.ToSingle(SC.GetConfigItem($"{module}.HighTemperatureHeater.Temperature").Min);
- }
- public bool GotoPosition(HighTemperatureHeaterPosition highTemperatureHeaterPosition)
- {
- if (CurrentPosition == highTemperatureHeaterPosition)
- {
- return true;
- }
- HighTemperatureHeaterPositipnSetPoint = highTemperatureHeaterPosition.ToString();
- switch (highTemperatureHeaterPosition)
- {
- case HighTemperatureHeaterPosition.Origin:
- _doGoOriginOn.Value = true;
- _originTimer.Start(_goPositionTime);
- break;
- case HighTemperatureHeaterPosition.Position1:
- _doGoPosition1On.Value = true;
- _position1Timer.Start(_goPositionTime);
- break;
- case HighTemperatureHeaterPosition.Position2:
- _doGoPosition2On.Value = true;
- _position2Timer.Start(_goPositionTime);
- break;
- case HighTemperatureHeaterPosition.Position3:
- _doGoPosition3On.Value = true;
- _position3Timer.Start(_goPositionTime);
- break;
- case HighTemperatureHeaterPosition.Position4:
- _doGoPosition4On.Value = true;
- _position4Timer.Start(_goPositionTime);
- break;
- case HighTemperatureHeaterPosition.Position5:
- _doGoPosition5On.Value = true;
- _position5Timer.Start(_goPositionTime);
- break;
- }
- return true;
- }
- public bool Initialize()
- {
- OP.Subscribe($"{Module}.{Name}.GotoPosition", (cmd, args) =>
- {
- var currentPosition = (HighTemperatureHeaterPosition)Enum.Parse(typeof(HighTemperatureHeaterPosition), args[0].ToString());
- GotoPosition(currentPosition);
- return true;
- });
- OP.Subscribe($"{Module}.{Name}.SwitchHighTemperatureHeater", (cmd, args) =>
- {
- HighTemperatureHeaterIsOn = Convert.ToBoolean(args[0].ToString());
- return true;
- });
- OP.Subscribe($"{Module}.{Name}.SetHighTemperatureHeaterTemperature", (cmd, args) =>
- {
- HighTemperatureHighHeaterTemperature = Convert.ToSingle(args[0]);
- return true;
- });
- OP.Subscribe($"{Module}.{Name}.SetHighTemperatureHeaterRatio", (cmd, args) =>
- {
- HighTemperatureHeaterRatio = Convert.ToSingle(args[0]);
- return true;
- });
- DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData,SubscriptionAttribute.FLAG.IgnoreSaveDB);
- DATA.Subscribe($"{Module}.{Name}.Temperature", () => DeviceData.HighTemperatureHeaterTemperatureFeedBack);
- DATA.Subscribe($"{Module}.{Name}.Position", () => (int)CurrentPosition-1);
- _SetRealFloat(_aoLiftServoPosition1, 20);
- _SetRealFloat(_aoLiftServoPosition2, -30);
- _SetRealFloat(_aoLiftServoPosition3, -40);
- _SetRealFloat(_aoLiftServoPosition4, 20);
- _SetRealFloat(_aoLiftServoPosition5, 50);
- _SetRealFloat(_aoOriginSearchHighSpeed, 10);
- _SetRealFloat(_aoOriginSearchLowSpeed, 5);
- _SetRealFloat(_aoAbsMoveSpeed, 10);
- _SetRealFloat(_aoMaximusMoveSpeed, 20);
- _SetRealFloat(_aoSoftDownLimit, 100);
- _SetRealFloat(_aoSoftUpLimit, 300);
- return true;
- }
- public void Stop()
- {
- }
- public void Terminate()
- {
- }
- public void Monitor()
- {
- if (_originTimer.IsTimeout())
- {
- _originTimer.Stop();
- if (_diGoOriginFeedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到原点");
- }
- }
- else if (_originTimer.IsIdle() == false)
- {
- if (_diGoOriginFeedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Origin");
- _doGoOriginOn.Value = false;
- _originTimer.Stop();
- }
- }
- if (_position1Timer.IsTimeout())
- {
- _position1Timer.Stop();
- if (_diGoPosition1Feedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到Position1");
- }
- }
- else if (_position1Timer.IsIdle() == false)
- {
- if (_diGoPosition1Feedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Position1");
- _doGoPosition1On.Value = false;
- _position1Timer.Stop();
- }
- }
- if (_position2Timer.IsTimeout())
- {
- _position2Timer.Stop();
- if (_diGoPosition2Feedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到Position2");
- }
- }
- else if (_position2Timer.IsIdle() == false)
- {
- if (_diGoPosition2Feedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Position2");
- _doGoPosition2On.Value = false;
- _position2Timer.Stop();
- }
- }
- if (_position3Timer.IsTimeout())
- {
- _position3Timer.Stop();
- if (_diGoPosition3Feedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到Position3");
- }
- }
- else if (_position3Timer.IsIdle() == false)
- {
- if (_diGoPosition3Feedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Position3");
- _doGoPosition3On.Value = false;
- _position3Timer.Stop();
- }
- }
- if (_position4Timer.IsTimeout())
- {
- _position4Timer.Stop();
- if (_diGoPosition4Feedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到Position4");
- }
- }
- else if (_position4Timer.IsIdle() == false)
- {
- if (_diGoPosition4Feedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Position4");
- _doGoPosition4On.Value = false;
- _position4Timer.Stop();
- }
- }
- if (_position5Timer.IsTimeout())
- {
- _position5Timer.Stop();
- if (_diGoPosition5Feedback.Value == false)
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name} {_goPositionTime / 1000} s 内未到Position5");
- }
- }
- else if (_position5Timer.IsIdle() == false)
- {
- if (_diGoPosition5Feedback.Value == true)
- {
- LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"{Name} to Position5");
- _doGoPosition5On.Value = false;
- _position5Timer.Stop();
- }
- }
-
- _SetRealFloat(_aoLiftServoPosition1, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.LiftServoPosition1"));
- _SetRealFloat(_aoLiftServoPosition2, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.LiftServoPosition2"));
- _SetRealFloat(_aoLiftServoPosition3, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.LiftServoPosition3"));
- _SetRealFloat(_aoLiftServoPosition4, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.LiftServoPosition4"));
- _SetRealFloat(_aoLiftServoPosition5, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.LiftServoPosition5"));
-
- _SetRealFloat(_aoOriginSearchHighSpeed, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.OriginSearchHighSpeed"));
- _SetRealFloat(_aoOriginSearchLowSpeed, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.OriginSearchLowSpeed"));
- _SetRealFloat(_aoAbsMoveSpeed, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.AbsMoveSpeed"));
- _SetRealFloat(_aoMaximusMoveSpeed, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.MaximusMoveSpeed"));
- _SetRealFloat(_aoSoftDownLimit, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.SoftDownLimit"));
- _SetRealFloat(_aoSoftUpLimit, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.SoftUpLimit"));
-
- _SetRealFloat(_aoTemperatureSetPoint, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.Temperature"));
- _SetRealFloat(_aoRatio, (float)SC.GetValue<double>($"{Module}.HighTemperatureHeater.Ratio"));
- _doPowerOn.Value = SC.GetValue<bool>($"{Module}.HighTemperatureHeater.IsOn");
- }
- public void Reset()
- {
- }
- }
- }
|