예제 #1
0
        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();
                }
            }
        }
예제 #2
0
 private void ApplyForNumericTags(RemapTagsResult result)
 {
     for (var i = 0; i < _readNumericTags.Count; i++)
     {
         var tag = _readNumericTags[i];
         tag.UpdateValue(result.NumReadValues[i]);
     }
 }
예제 #3
0
 private void ApplyForDigitalTags(RemapTagsResult result)
 {
     for (var i = 0; i < _readDigitalTags.Count; i++)
     {
         var tag = _readDigitalTags[i];
         tag.UpdateValue(result.DigReadValues[i]);
     }
 }
예제 #4
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Result = new RemapTagsResult {
         DigReadValues = new bool?[] { false },
         NumReadValues = new double?[] { RandomGenerator.GetRandomInt32() }
     };
     IoDevice.ApplyRemapResult(Result);
 }
예제 #5
0
 internal override void ApplyRemapResult(RemapTagsResult result)
 {
     if (result != null)
     {
         ApplyForDigitalTags(result);
         ApplyForNumericTags(result);
     }
     else
     {
         ApplyForDigitalTagsNull();
         ApplyForNumericTagsNull();
     }
 }
예제 #6
0
 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();
 }
예제 #7
0
        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);
        }
예제 #8
0
 private void ApplyResult(IoDeviceAbstract ioDevice, RemapTagsResult result)
 {
     _reporter.Report(result.Notifications);
     ioDevice.ApplyRemapResult(result);
 }
예제 #9
0
 internal abstract void ApplyRemapResult(RemapTagsResult result);