Skip to content

Commit c9deb3b

Browse files
Update to address issue #116
- Added "forceUpdate" optional parameter for IMTConnectAgent.AddObservation() methods which will force the observation to update regardless of any filters or duplicate values.
1 parent b2d8990 commit c9deb3b

File tree

2 files changed

+189
-150
lines changed

2 files changed

+189
-150
lines changed

libraries/MTConnect.NET-Common/Agents/IMTConnectAgent.cs

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 TrakHound Inc., All Rights Reserved.
1+
// Copyright (c) 2025 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using MTConnect.Agents.Metrics;
@@ -214,48 +214,52 @@ public interface IMTConnectAgent
214214
IEnumerable<IDevice> AddDevices(IEnumerable<IDevice> devices, bool intializeDataItems = true);
215215

216216

217-
/// <summary>
218-
/// Add a new Observation to the Agent for the specified DataItem
219-
/// </summary>
220-
/// <param name="dataItem">The DataItem to report</param>
221-
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
222-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
223-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
224-
/// <returns>True if the Observation was added successfully</returns>
225-
bool AddObservation(IDataItem dataItem, object value, bool? convertUnits = null, bool? ignoreCase = null);
217+
/// <summary>
218+
/// Add a new Observation to the Agent for the specified DataItem
219+
/// </summary>
220+
/// <param name="dataItem">The DataItem to report</param>
221+
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
222+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
223+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
224+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
225+
/// <returns>True if the Observation was added successfully</returns>
226+
bool AddObservation(IDataItem dataItem, object value, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
226227

227-
/// <summary>
228-
/// Add a new Observation to the Agent for the specified DataItem
229-
/// </summary>
230-
/// <param name="dataItem">The DataItem to report</param>
231-
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
232-
/// <param name="timestamp">The Timestamp of the Observation in Unix Ticks (1/10,000 of a millisecond)</param>
233-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
234-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
235-
/// <returns>True if the Observation was added successfully</returns>
236-
bool AddObservation(IDataItem dataItem, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null);
228+
/// <summary>
229+
/// Add a new Observation to the Agent for the specified DataItem
230+
/// </summary>
231+
/// <param name="dataItem">The DataItem to report</param>
232+
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
233+
/// <param name="timestamp">The Timestamp of the Observation in Unix Ticks (1/10,000 of a millisecond)</param>
234+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
235+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
236+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
237+
/// <returns>True if the Observation was added successfully</returns>
238+
bool AddObservation(IDataItem dataItem, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
237239

238-
/// <summary>
239-
/// Add a new Observation to the Agent for the specified DataItem
240-
/// </summary>
241-
/// <param name="dataItem">The DataItem to report</param>
242-
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
243-
/// <param name="timestamp">The Timestamp of the Observation</param>
244-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
245-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
246-
/// <returns>True if the Observation was added successfully</returns>
247-
bool AddObservation(IDataItem dataItem, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null);
240+
/// <summary>
241+
/// Add a new Observation to the Agent for the specified DataItem
242+
/// </summary>
243+
/// <param name="dataItem">The DataItem to report</param>
244+
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
245+
/// <param name="timestamp">The Timestamp of the Observation</param>
246+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
247+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
248+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
249+
/// <returns>True if the Observation was added successfully</returns>
250+
bool AddObservation(IDataItem dataItem, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
248251

249-
/// <summary>
250-
/// Add a new Observation to the Agent for the specified Device and DataItem
251-
/// </summary>
252-
/// <param name="deviceKey">The (Name or Uuid) of the Device</param>
253-
/// <param name="dataItemKey">The (Name, ID, or Source) of the DataItem</param>
254-
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
255-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
256-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
257-
/// <returns>True if the Observation was added successfully</returns>
258-
bool AddObservation(string deviceKey, string dataItemKey, object value, bool? convertUnits = null, bool? ignoreCase = null);
252+
/// <summary>
253+
/// Add a new Observation to the Agent for the specified Device and DataItem
254+
/// </summary>
255+
/// <param name="deviceKey">The (Name or Uuid) of the Device</param>
256+
/// <param name="dataItemKey">The (Name, ID, or Source) of the DataItem</param>
257+
/// <param name="value">The Value of the Observation (equivalent to ValueKey = Value)</param>
258+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
259+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
260+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
261+
/// <returns>True if the Observation was added successfully</returns>
262+
bool AddObservation(string deviceKey, string dataItemKey, object value, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
259263

260264
/// <summary>
261265
/// Add a new Observation to the Agent for the specified Device and DataItem
@@ -266,8 +270,9 @@ public interface IMTConnectAgent
266270
/// <param name="timestamp">The Timestamp of the Observation in Unix Ticks (1/10,000 of a millisecond)</param>
267271
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
268272
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
273+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
269274
/// <returns>True if the Observation was added successfully</returns>
270-
bool AddObservation(string deviceKey, string dataItemKey, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null);
275+
bool AddObservation(string deviceKey, string dataItemKey, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
271276

272277
/// <summary>
273278
/// Add a new Observation to the Agent for the specified Device and DataItem
@@ -278,8 +283,9 @@ public interface IMTConnectAgent
278283
/// <param name="timestamp">The Timestamp of the Observation</param>
279284
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
280285
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
286+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
281287
/// <returns>True if the Observation was added successfully</returns>
282-
bool AddObservation(string deviceKey, string dataItemKey, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null);
288+
bool AddObservation(string deviceKey, string dataItemKey, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
283289

284290
/// <summary>
285291
/// Add a new Observation to the Agent for the specified Device and DataItem
@@ -290,8 +296,9 @@ public interface IMTConnectAgent
290296
/// <param name="value">The Value of the Observation</param>
291297
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
292298
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
299+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
293300
/// <returns>True if the Observation was added successfully</returns>
294-
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, bool? convertUnits = null, bool? ignoreCase = null);
301+
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
295302

296303
/// <summary>
297304
/// Add a new Observation to the Agent for the specified Device and DataItem
@@ -303,8 +310,9 @@ public interface IMTConnectAgent
303310
/// <param name="timestamp">The Timestamp of the Observation in Unix Ticks (1/10,000 of a millisecond)</param>
304311
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
305312
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
313+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
306314
/// <returns>True if the Observation was added successfully</returns>
307-
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null);
315+
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, long timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
308316

309317
/// <summary>
310318
/// Add a new Observation to the Agent for the specified Device and DataItem
@@ -316,30 +324,33 @@ public interface IMTConnectAgent
316324
/// <param name="timestamp">The Timestamp of the Observation</param>
317325
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
318326
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
327+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
319328
/// <returns>True if the Observation was added successfully</returns>
320-
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null);
329+
bool AddObservation(string deviceKey, string dataItemKey, string valueKey, object value, DateTime timestamp, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
321330

322-
/// <summary>
323-
/// Add a new Observation to the Agent for the specified Device and DataItem
324-
/// </summary>
325-
/// <param name="observationInput">The Observation to add</param>
326-
/// <param name="ignoreTimestamp">Used to override the default configuration for the Agent to IgnoreTimestamp</param>
327-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
328-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
329-
/// <returns>True if the Observation was added successfully</returns>
330-
bool AddObservation(IObservationInput observationInput, bool? ignoreTimestamp = null, bool? convertUnits = null, bool? ignoreCase = null);
331+
/// <summary>
332+
/// Add a new Observation to the Agent for the specified Device and DataItem
333+
/// </summary>
334+
/// <param name="observationInput">The Observation to add</param>
335+
/// <param name="ignoreTimestamp">Used to override the default configuration for the Agent to IgnoreTimestamp</param>
336+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
337+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
338+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
339+
/// <returns>True if the Observation was added successfully</returns>
340+
bool AddObservation(IObservationInput observationInput, bool? ignoreTimestamp = null, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
331341

332342

333-
/// <summary>
334-
/// Add a new Observation to the Agent for the specified Device and DataItem
335-
/// </summary>
336-
/// <param name="deviceKey">The (Name or Uuid) of the Device. This overrides what is set in the "observationInput" parameter</param>
337-
/// <param name="observationInput">The Observation to add</param>
338-
/// <param name="ignoreTimestamp">Used to override the default configuration for the Agent to IgnoreTimestamp</param>
339-
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
340-
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
341-
/// <returns>True if the Observation was added successfully</returns>
342-
bool AddObservation(string deviceKey, IObservationInput observationInput, bool? ignoreTimestamp = null, bool? convertUnits = null, bool? ignoreCase = null);
343+
/// <summary>
344+
/// Add a new Observation to the Agent for the specified Device and DataItem
345+
/// </summary>
346+
/// <param name="deviceKey">The (Name or Uuid) of the Device. This overrides what is set in the "observationInput" parameter</param>
347+
/// <param name="observationInput">The Observation to add</param>
348+
/// <param name="ignoreTimestamp">Used to override the default configuration for the Agent to IgnoreTimestamp</param>
349+
/// <param name="convertUnits">Used to override the default configuration for the Agent to ConvertUnits</param>
350+
/// <param name="ignoreCase">Used to override the default configuration for the Agent to IgnoreCase of the Value</param>
351+
/// <param name="forceUpdate">Used to force the update of the Observation. This overrides any value or duplication filters.</param>
352+
/// <returns>True if the Observation was added successfully</returns>
353+
bool AddObservation(string deviceKey, IObservationInput observationInput, bool? ignoreTimestamp = null, bool? convertUnits = null, bool? ignoreCase = null, bool forceUpdate = false);
343354

344355
/// <summary>
345356
/// Add new Observations to the Agent for the specified Device

0 commit comments

Comments
 (0)