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 { static NLog.Logger logger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("PumpHandler"); protected IContext context; //range from 0 to 3,最终需要看A/D转换器有几路输入 private byte pinIndexOfGageConnectedInADConverter; //电流到压力的转换乘积因子 private int currentToPaMultiplyFactor; public Handler(int pinIndexOfGageConnectedInADConverter, int currentToPaMultiplyFactor) { this.pinIndexOfGageConnectedInADConverter = (byte)pinIndexOfGageConnectedInADConverter; this.currentToPaMultiplyFactor = currentToPaMultiplyFactor; } public void Init(IContext context) { this.context = context; var timeWindowWithActivePollingOutgoing = this.context.Outgoing as TimeWindowWithActivePollingOutgoing; timeWindowWithActivePollingOutgoing.PollingMsgProducer = () => new ReadAnalogDataRequest(this.pinIndexOfGageConnectedInADConverter); } public Task Process(IContext context) { var response = context.Incoming.Message as ReadAnalogDataResponse; logger.Debug("Pressure Gage on PIN " + this.pinIndexOfGageConnectedInADConverter + " read raw current value: " + response.Data); //CloudRestClient.Default.UploadDataAsync( // new DeviceUploadData_V1(this.context.Processor.SerialNumber, // Common.Cloud.Entity.Local.DataPriorityLevel.Info) // { // PressureValue = response.Data // }, null); return Task.CompletedTask; } } }