private static void Remap(IIoDeviceRunTarget ioDevice, RemapTagsParameter parameter, RemapTagsResult result) { bool readOnly = !parameter.DigWriteIds.Any() && !parameter.NumWriteIds.Any(); if (readOnly) { ioDevice.EnterReadLock(); } else { ioDevice.EnterWriteLock(); } try { if (!readOnly) { WriteDigValues(ioDevice, parameter.DigWriteIds, parameter.DigWriteValues); WriteNumValues(ioDevice, parameter.NumWriteIds, parameter.NumWriteValues); } result.DigReadValues = ReadDigValues(ioDevice, parameter.DigReadIds); result.NumReadValues = ReadNumValues(ioDevice, parameter.NumReadIds); result.Notifications = GetNotifications(ioDevice.Reporter.Notifications); } finally { if (readOnly) { ioDevice.ExitReadLock(); } else { ioDevice.ExitWriteLock(); } } }
private void ApplyForNumericTags(RemapTagsResult result) { for (var i = 0; i < _readNumericTags.Count; i++) { var tag = _readNumericTags[i]; tag.UpdateValue(result.NumReadValues[i]); } }
private void ApplyForDigitalTags(RemapTagsResult result) { for (var i = 0; i < _readDigitalTags.Count; i++) { var tag = _readDigitalTags[i]; tag.UpdateValue(result.DigReadValues[i]); } }
protected override void EstablishContext() { base.EstablishContext(); Result = new RemapTagsResult { DigReadValues = new bool?[] { false }, NumReadValues = new double?[] { RandomGenerator.GetRandomInt32() } }; IoDevice.ApplyRemapResult(Result); }
internal override void ApplyRemapResult(RemapTagsResult result) { if (result != null) { ApplyForDigitalTags(result); ApplyForNumericTags(result); } else { ApplyForDigitalTagsNull(); ApplyForNumericTagsNull(); } }
protected override void EstablishContext() { base.EstablishContext(); Service = new Mock <IService>(); Notification = new WcfNotification { StartTime = DateTime.UtcNow, Message = "Message", ShortDescription = "ShortDescription", LongDescription = "LongDescription" }; Result = new RemapTagsResult { Notifications = new[] { Notification } }; Service.Setup(s => s.RemapTags(It.Is <RemapTagsParameter[]>(p => p.Length == 1 && p[0] == Parameter))) .Returns(new[] { Result }).Verifiable(); }
public RemapTagsResult[] RemapTags(RemapTagsParameter[] parameters) { if (NotValid()) { return(null); } var results = new RemapTagsResult[parameters.Length]; for (var parameterIndex = 0; parameterIndex < parameters.Length; parameterIndex++) { var parameter = parameters[parameterIndex]; var result = new RemapTagsResult(); results[parameterIndex] = result; var ioDevice = _project.IoDeviceRunTargets[parameter.IoDeviceId]; Remap(ioDevice, parameter, result); } return(results); }
private void ApplyResult(IoDeviceAbstract ioDevice, RemapTagsResult result) { _reporter.Report(result.Notifications); ioDevice.ApplyRemapResult(result); }
internal abstract void ApplyRemapResult(RemapTagsResult result);