From 1e52327a3d837f0c8eaaeeba4800b970d2903666 Mon Sep 17 00:00:00 2001 From: Peter Butzhammer Date: Fri, 9 Feb 2024 15:05:40 +0100 Subject: [PATCH] Fix some typos --- Sharp7.Rx/Sharp7Plc.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Sharp7.Rx/Sharp7Plc.cs b/Sharp7.Rx/Sharp7Plc.cs index a50d24d..3727bc9 100644 --- a/Sharp7.Rx/Sharp7Plc.cs +++ b/Sharp7.Rx/Sharp7Plc.cs @@ -15,9 +15,9 @@ public class Sharp7Plc : IPlc { private readonly CompositeDisposable disposables = new(); private readonly ConcurrentSubjectDictionary multiVariableSubscriptions = new(StringComparer.InvariantCultureIgnoreCase); - private readonly List performanceCoutner = new(1000); + private readonly List performanceCounter = new(1000); private readonly PlcConnectionSettings plcConnectionSettings; - private readonly CacheVariableNameParser varaibleNameParser = new CacheVariableNameParser(new VariableNameParser()); + private readonly CacheVariableNameParser variableNameParser = new CacheVariableNameParser(new VariableNameParser()); private bool disposed; private Sharp7Connector s7Connector; @@ -30,11 +30,11 @@ public class Sharp7Plc : IPlc /// /// /// - /// Polling interval used to read multi variable requests from PLC. + /// Polling interval for multi variable read from PLC. /// /// /// This is the wait time between two successive reads from PLC and determines the - /// time resolution for all variable reads reated with CreateNotification. + /// time resolution for all variable reads related with CreateNotification. /// /// /// Default is 100 ms. The minimum supported time is 5 ms. @@ -43,7 +43,7 @@ public class Sharp7Plc : IPlc public Sharp7Plc(string ipAddress, int rackNumber, int cpuMpiAddress, int port = 102, TimeSpan? multiVarRequestCycleTime = null) { plcConnectionSettings = new PlcConnectionSettings {IpAddress = ipAddress, RackNumber = rackNumber, CpuMpiAddress = cpuMpiAddress, Port = port}; - s7Connector = new Sharp7Connector(plcConnectionSettings, varaibleNameParser); + s7Connector = new Sharp7Connector(plcConnectionSettings, variableNameParser); ConnectionState = s7Connector.ConnectionState; if (multiVarRequestCycleTime != null) @@ -80,15 +80,15 @@ public class Sharp7Plc : IPlc var address = ParseAndVerify(variableName, typeof(TValue)); var disp = new CompositeDisposable(); - var disposeableContainer = multiVariableSubscriptions.GetOrCreateObservable(variableName); - disposeableContainer.AddDisposableTo(disp); + var disposableContainer = multiVariableSubscriptions.GetOrCreateObservable(variableName); + disposableContainer.AddDisposableTo(disp); var observable = - // Directly read variable first. + // Read variable with GetValue first. // This will propagate any errors due to reading from invalid addresses. Observable.FromAsync(() => GetValue(variableName)) .Concat( - disposeableContainer.Observable + disposableContainer.Observable .Select(bytes => ValueConverter.ReadFromBuffer(bytes, address)) ); @@ -206,7 +206,7 @@ public class Sharp7Plc : IPlc } stopWatch.Stop(); - performanceCoutner.Add(stopWatch.ElapsedMilliseconds); + performanceCounter.Add(stopWatch.ElapsedMilliseconds); PrintAndResetPerformanceStatistik(); @@ -215,7 +215,7 @@ public class Sharp7Plc : IPlc private VariableAddress ParseAndVerify(string variableName, Type type) { - var address = varaibleNameParser.Parse(variableName); + var address = variableNameParser.Parse(variableName); if (!address.MatchesType(type)) throw new DataTypeMissmatchException($"Address \"{variableName}\" does not match type {type}.", type, address); @@ -224,17 +224,17 @@ public class Sharp7Plc : IPlc private void PrintAndResetPerformanceStatistik() { - if (performanceCoutner.Count == performanceCoutner.Capacity) + if (performanceCounter.Count == performanceCounter.Capacity) { - var average = performanceCoutner.Average(); - var min = performanceCoutner.Min(); - var max = performanceCoutner.Max(); + var average = performanceCounter.Average(); + var min = performanceCounter.Min(); + var max = performanceCounter.Max(); Logger?.LogTrace("Performance statistic during {0} elements of plc notification. Min: {1}, Max: {2}, Average: {3}, Plc: '{4}', Number of variables: {5}, Batch size: {6}", - performanceCoutner.Capacity, min, max, average, plcConnectionSettings.IpAddress, + performanceCounter.Capacity, min, max, average, plcConnectionSettings.IpAddress, multiVariableSubscriptions.ExistingKeys.Count(), MultiVarRequestMaxItems); - performanceCoutner.Clear(); + performanceCounter.Clear(); } }