123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump;
- using OPW_VaporRecoveryOnlineWatch_PressureGage.MessageEntity;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using System.Xml.Serialization;
- using Timer = System.Timers.Timer;
- namespace OPW_VaporRecoveryOnlineWatch_PressureGage
- {
- public class Handler : IDeviceHandler<byte[], PressureGageBaseMessage>
- {
- static NLog.Logger logger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("PumpHandler");
- protected IContext<byte[], PressureGageBaseMessage> context;
-
- private byte pinIndexOfGageConnectedInADConverter;
-
- private int currentToPaMultiplyFactor;
- public Handler(int pinIndexOfGageConnectedInADConverter, int currentToPaMultiplyFactor)
- {
- this.pinIndexOfGageConnectedInADConverter = (byte)pinIndexOfGageConnectedInADConverter;
- this.currentToPaMultiplyFactor = currentToPaMultiplyFactor;
- }
- public void Init(IContext<byte[], PressureGageBaseMessage> context)
- {
- this.context = context;
- var timeWindowWithActivePollingOutgoing = this.context.Outgoing as TimeWindowWithActivePollingOutgoing<byte[], PressureGageBaseMessage>;
- timeWindowWithActivePollingOutgoing.PollingMsgProducer = () => new ReadAnalogDataRequest(this.pinIndexOfGageConnectedInADConverter);
- }
- public Task Process(IContext<byte[], PressureGageBaseMessage> context)
- {
- var response = context.Incoming.Message as ReadAnalogDataResponse;
- logger.Debug("Pressure Gage on PIN " + this.pinIndexOfGageConnectedInADConverter + " read raw current value: " + response.Data);
-
-
-
-
-
-
- return Task.CompletedTask;
- }
- }
- }
|