internal AsyncDataProducerV2(byte register, byte mask, DataTypeBase dataTypeBase, IModuleBoardBridge bridge) : base(register, dataTypeBase, bridge) { this.mask = mask; }
public void Invoke(DataTypeBase data) { ((Delegate)delegateObject).DynamicInvoke(data); //Will compile }
private new Element CreateChildBuildElement(PropertyInfo propInfo, XmlNode xml, PropertyDictionary properties, FrameworkInfo framework) { MethodInfo getter = null; MethodInfo setter = null; Element childElement = null; Type elementType = null; setter = propInfo.GetSetMethod(true); getter = propInfo.GetGetMethod(true); if (getter != null) { try { childElement = (Element)propInfo.GetValue(Element, null); } catch (InvalidCastException ex) { throw new BuildException( string.Format( "Property \"{0}\" for class \"{1}\" is backed by \"{2}\" which does not derive from \"{3}\".", propInfo.Name, Element.GetType().FullName, propInfo.PropertyType.FullName, typeof(Element).FullName), ex ); } if (childElement == null) { if (setter == null) { throw new BuildException(string.Format("Property {0} cannot return null (if there is no set method) for class {1}", propInfo.Name, Element.GetType().FullName), Location); } else { getter = null; this.Project.Log(Level.Debug, string.Format("{0}_get() returned null; will go the route of set method to populate.", propInfo.Name)); } } else { elementType = childElement.GetType(); } } if (getter == null && setter != null) { elementType = setter.GetParameters()[0].ParameterType; if (elementType.IsAbstract) { DataTypeBaseBuilder Builder; Builder = TypeFactory.DataTypeBuilders[xml.Name]; if (Builder == null) { throw new InvalidOperationException(string.Format("Abstract type: {0} for {2}.{1}", elementType.Name, propInfo.Name, Name)); } childElement = Builder.CreateDataTypeBase(); } else { childElement = (Element)Activator.CreateInstance(elementType, (BindingFlags.NonPublic | (BindingFlags.Public | BindingFlags.Instance)), null, null, CultureInfo.InvariantCulture); } } childElement = Element.InitializeBuildElement(Element, xml, childElement, elementType); DataTypeBase dataType = (DataTypeBase)childElement; if (dataType != null && xml.Attributes["refid"] != null) { if (setter == null) { throw new BuildException(string.Format("DataType child element '{0}' in class '{1}' must define a set method.", propInfo.Name, this.GetType().FullName)); } getter = null; } if (setter != null && getter == null) { setter.Invoke(Element, new object[] { childElement }); } return(childElement); }
public static TDst Try_Cast <TDst>(object expression, DataTypeBase data_type) => throw new InvalitContextException(nameof(Try_Cast));
public static TDst Try_Parse <TDst>(object string_value, DataTypeBase data_type, string culture) => throw new InvalitContextException(nameof(Try_Parse));
/// <summary> /// Initializes a new instance of the <see cref="SnapshotElementComparer" /> class. /// </summary> /// <param name="region">The parent region that contains this element.</param> /// <param name="pointerIncrementMode">The method by which to increment element pointers.</param> /// <param name="constraints">The constraints to use for the element comparisons.</param> public unsafe SnapshotElementComparer(SnapshotRegion region, PointerIncrementMode pointerIncrementMode, DataTypeBase dataType) { this.Region = region; this.CurrentTypeCode = Type.GetTypeCode(dataType); // The garbage collector can relocate variables at runtime. Since we use unsafe pointers, we need to keep these pinned this.CurrentValuesHandle = GCHandle.Alloc(this.Region.ReadGroup.CurrentValues, GCHandleType.Pinned); this.PreviousValuesHandle = GCHandle.Alloc(this.Region.ReadGroup.PreviousValues, GCHandleType.Pinned); this.InitializePointers(); this.SetConstraintFunctions(); this.SetPointerFunction(pointerIncrementMode); }
private void GenerateCodeFromType(DataTypeBase dataType, TextWriter writer, CodeGeneratorOptions options) { if (dataType != null) { if (dataType is CharacterString) { CharacterString cs = (CharacterString)dataType; switch (cs.Type) { case CharacterStringTypes.NVarChar: writer.Write("nvarchar"); break; case CharacterStringTypes.Binary: writer.Write("binary"); break; case CharacterStringTypes.Char: writer.Write("char"); break; case CharacterStringTypes.Image: writer.Write("image"); break; case CharacterStringTypes.NChar: writer.Write("nchar"); break; case CharacterStringTypes.NText: writer.Write("ntext"); break; case CharacterStringTypes.Text: writer.Write("text"); break; case CharacterStringTypes.VarBinary: writer.Write("varbinary"); break; case CharacterStringTypes.VarChar: writer.Write("varchar"); break; } // LIKELY NOT VALID FOR ALL CHARACTER TYPES! if (cs.Size != null) { writer.Write("("); GenerateCodeFromExpression(cs.Size, writer, options); writer.Write(")"); } } else if (dataType is DateTime) { DateTime dt = (DateTime)dataType; switch (dt.Type) { case DateTimeTypes.Date: writer.Write("date"); break; case DateTimeTypes.DateTime: writer.Write("datetime"); break; case DateTimeTypes.DateTime2: writer.Write("datetime2"); break; case DateTimeTypes.DateTimeOffset: writer.Write("datetimeoffset"); break; case DateTimeTypes.SmallDateTime: writer.Write("smalldatetime"); break; case DateTimeTypes.Time: writer.Write("time"); break; } } else if (dataType is Numeric) { Numeric n = (Numeric)dataType; switch (n.Type) { case NumericTypes.BigInt: writer.Write("bigint"); break; case NumericTypes.Bit: writer.Write("bit"); break; case NumericTypes.Decimal: case NumericTypes.Numeric: if (n.Type == NumericTypes.Decimal) { writer.Write("decimal"); } else { writer.Write("numeric"); } if (n.Precision.HasValue) { if (n.Scale.HasValue) { writer.Write(string.Concat("(", n.Precision.Value, ",", n.Scale.Value, ")")); } else { writer.Write(string.Concat("(", n.Precision.Value, ")")); } } break; case NumericTypes.Float: writer.Write(string.Concat("float", n.Precision.HasValue ? string.Concat("(", n.Precision.Value, ")") : string.Empty)); break; case NumericTypes.Int: writer.Write("int"); break; case NumericTypes.Money: writer.Write("money"); break; case NumericTypes.Real: writer.Write("real"); break; case NumericTypes.SmallInt: writer.Write("smallint"); break; case NumericTypes.SmallMoney: writer.Write("smallmoney"); break; case NumericTypes.TinyInt: writer.Write("tinyint"); break; } } } }
public StoredProcedureParameter(string name, DataTypeBase dataType, IConstant defaultValue, bool isOut) : this(name, dataType, defaultValue) { IsOut = isOut; }
public StoredProcedureParameter(string name, DataTypeBase dataType, IConstant defaultValue, bool isOut, bool isReadonly) : this(name, dataType, defaultValue, isOut) { IsReadonly = isReadonly; }
/* [ { @parameter [ type_schema_name. ] data_type } [ VARYING ] [ = default ] [ OUT | OUTPUT ] [READONLY] ] [ ,...n ] */ public StoredProcedureParameter(string name, DataTypeBase dataType) { Name = name; DataType = dataType; }
public StoredProcedureParameter(string name, DataTypeBase dataType, IConstant defaultValue) : this(name, dataType) { DefaultValue = defaultValue; }
public Int32 Handle() { DataTypeBase dataType = ScanSettings.DataType; ScanConstraint.ConstraintType constraintType = ScanConstraint.ConstraintType.Equal; if (String.IsNullOrWhiteSpace(this.Constraint)) { // Default to equals this.Constraint = "e"; } switch (this.Constraint.ToLower()) { case "le": break; case "l": break; case "g": break; case "ge": break; case "e": break; case "c": break; case "u": break; case "i": break; case "d": break; default: Console.WriteLine("Unknown constraint type '" + this.Constraint + "', defaulting to equal"); break; } if (!SyntaxChecker.CanParseValue(dataType, this.Value)) { Console.WriteLine("Failed to parse '" + this.Value + "' as data type " + dataType?.ToString()); return(-1); } ScanConstraint scanConstraints = new ScanConstraint(constraintType, dataType, Conversions.ParsePrimitiveStringAsPrimitive(dataType, this.Value)); // Collect values TrackableTask <Snapshot> valueCollectorTask = ValueCollector.CollectValues( SessionManager.Session.SnapshotManager.GetActiveSnapshotCreateIfNone(SessionManager.Session.OpenedProcess, dataType), TrackableTask.UniversalIdentifier); // Perform manual scan Snapshot snapshot = valueCollectorTask.Result; TrackableTask <Snapshot> scanTask = ManualScanner.Scan( snapshot, scanConstraints, TrackableTask.UniversalIdentifier); SessionManager.Session.SnapshotManager.SaveSnapshot(scanTask.Result); Console.WriteLine(); return(0); }
/// <summary> /// Changes the active scan results type. /// </summary> /// <param name="newType">The new scan results type.</param> private void ChangeType(DataTypeBase newType) { this.ActiveType = newType; }
/// <summary> /// Updates the active type. /// </summary> /// <param name="activeType">The new active type.</param> public void Update(DataTypeBase activeType) { this.PointerRetargetAddressHexDecBoxViewModel.DataType = activeType; }
public bool Equals(DataTypeBase <TBaseType, TConcreteDataType> other) => InternalEquals(other as IDataType);
/// <summary> /// Sets the element type to which all constraints apply. /// </summary> /// <param name="elementType">The new element type.</param> public abstract void SetElementType(DataTypeBase elementType);
/// <summary> /// Gets the enumerator for an element reference within this snapshot region. /// </summary> /// <param name="pointerIncrementMode">The method for incrementing pointers.</param> /// <param name="constraints">The constraint to use for element comparisons.</param> /// <returns>The enumerator for an element reference within this snapshot region.</returns> public IEnumerator <SnapshotElementComparer> IterateComparer(SnapshotElementComparer.PointerIncrementMode pointerIncrementMode, Constraint constraints, DataTypeBase dataType) { Int32 elementCount = this.GetElementCount(dataType.Size); SnapshotElementComparer snapshotElement = new SnapshotElementComparer(region: this, pointerIncrementMode: pointerIncrementMode, constraints: constraints, dataType: dataType); for (Int32 elementIndex = 0; elementIndex < elementCount; elementIndex++) { yield return(snapshotElement); snapshotElement.IncrementPointers(); } }
public static DataTypeBase Identity(DataTypeBase dataType, string columnName, int seed, int increment) => throw new InvalitContextException(nameof(Identity));
/// <summary> /// Initializes a new instance of the <see cref="SnapshotElementComparer" /> class. /// </summary> /// <param name="region">The parent region that contains this element.</param> /// <param name="pointerIncrementMode">The method by which to increment element pointers.</param> /// <param name="constraints">The constraints to use for the element comparisons.</param> public unsafe SnapshotElementComparer(SnapshotRegion region, PointerIncrementMode pointerIncrementMode, Constraint constraints, DataTypeBase dataType) : this(region, pointerIncrementMode, dataType) { this.ElementCompare = this.BuildCompareActions(constraints); }
internal AsyncDataProducer(byte register, DataTypeBase dataTypeBase, IModuleBoardBridge bridge) : base(dataTypeBase, bridge) { enableRegister = register; }
public static TDst Cast <TDst>(object target, DataTypeBase destinationType) => throw new InvalitContextException(nameof(Cast));
public Column(object column, DataTypeBase type) { throw new InvalitContextException("new " + nameof(Column)); }
public static TDst Try_Convert <TDst>(DataTypeBase type, object expression) => throw new InvalitContextException(nameof(Try_Convert));
public Column(object column, DataTypeBase type, params ConstraintBase[] constraints) { throw new InvalitContextException("new " + nameof(Column)); }
/// <summary> /// Gets the standard collection of values to display in a drop down. /// </summary> /// <param name="context">Type descriptor context.</param> /// <returns>The standard collection of values.</returns> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return(new StandardValuesCollection(DataTypeBase.GetScannableDataTypes() .Select(dataType => Conversions.DataTypeToName(dataType)) .ToList())); }
public AggregateArgument(string variable, DataTypeBase type) => throw new InvalitContextException(nameof(AggregateArgument));
/// <summary> /// Performs a pointer scan for a given address. /// </summary> /// <param name="address">The address for which to perform a pointer scan.</param> /// <param name="maxOffset">The maximum pointer offset.</param> /// <param name="depth">The maximum pointer search depth.</param> /// <param name="alignment">The pointer scan alignment.</param> /// <param name="taskIdentifier">The unique identifier to prevent duplicate tasks.</param> /// <returns>Atrackable task that returns the scan results.</returns> public static TrackableTask <PointerBag> Scan(Process process, PointerBag previousPointerBag, Boolean readMemory, Boolean performUnchangedScan, String taskIdentifier = null) { try { TrackableTask <PointerBag> pointerScanTask = TrackableTask <PointerBag> .Create(PointerRebase.Name, taskIdentifier, out UpdateProgress updateProgress, out CancellationToken cancellationToken); return(pointerScanTask.With(Task <PointerBag> .Run(() => { try { cancellationToken.ThrowIfCancellationRequested(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); DataTypeBase pointerDataType = previousPointerBag.PointerSize.ToDataType(); ScanConstraint scanConstraint = new ScanConstraint(ScanConstraint.ConstraintType.Unchanged); ScanConstraints scanConstraints = new ScanConstraints(pointerDataType, scanConstraint); IList <Level> oldLevels = previousPointerBag.Levels; IList <Level> newLevels = new List <Level>(); for (Int32 levelIndex = 0; levelIndex < oldLevels.Count; levelIndex++) { Snapshot updatedStaticPointers = oldLevels[levelIndex].StaticPointers; Snapshot updatedHeapPointers = oldLevels[levelIndex].HeapPointers; // Step 1) Re-read values of all pointers if (readMemory) { TrackableTask <Snapshot> staticValueCollector = ValueCollector.CollectValues(process, updatedStaticPointers); // Does not apply to target address if (levelIndex > 0) { TrackableTask <Snapshot> heapValueCollector = ValueCollector.CollectValues(process, updatedHeapPointers); updatedHeapPointers = heapValueCollector.Result; } updatedStaticPointers = staticValueCollector.Result; } // Step 2) A neat (optional) trick: Scan for unchanged values to filter out dynamic pointers if (performUnchangedScan) { TrackableTask <Snapshot> staticValueScanner = ManualScanner.Scan(updatedStaticPointers, scanConstraints); // Does not apply to target address if (levelIndex > 0) { TrackableTask <Snapshot> heapValueScanner = ManualScanner.Scan(updatedHeapPointers, scanConstraints); updatedHeapPointers = heapValueScanner.Result; } updatedStaticPointers = staticValueScanner.Result; } Stopwatch levelStopwatch = new Stopwatch(); levelStopwatch.Start(); // Step 3) Rebase heap onto new previous heap if (levelIndex > 0) { IVectorSearchKernel heapSearchKernel = SearchKernelFactory.GetSearchKernel(newLevels.Last().HeapPointers, previousPointerBag.MaxOffset, previousPointerBag.PointerSize); TrackableTask <Snapshot> heapFilterTask = PointerFilter.Filter(pointerScanTask, updatedHeapPointers, heapSearchKernel, previousPointerBag.PointerSize, newLevels.Last().HeapPointers, previousPointerBag.MaxOffset); updatedHeapPointers = heapFilterTask.Result; } // Step 4) Filter static pointers that still point into the updated heap IVectorSearchKernel staticSearchKernel = SearchKernelFactory.GetSearchKernel(updatedHeapPointers, previousPointerBag.MaxOffset, previousPointerBag.PointerSize); TrackableTask <Snapshot> staticFilterTask = PointerFilter.Filter(pointerScanTask, updatedStaticPointers, staticSearchKernel, previousPointerBag.PointerSize, updatedHeapPointers, previousPointerBag.MaxOffset); updatedStaticPointers = staticFilterTask.Result; levelStopwatch.Stop(); Logger.Log(LogLevel.Info, "Pointer rebase from level " + (levelIndex) + " => " + (levelIndex + 1) + " completed in: " + levelStopwatch.Elapsed); newLevels.Add(new Level(updatedHeapPointers, updatedStaticPointers)); } // Exit if canceled cancellationToken.ThrowIfCancellationRequested(); PointerBag pointerBag = new PointerBag(newLevels, previousPointerBag.MaxOffset, previousPointerBag.PointerSize); stopwatch.Stop(); Logger.Log(LogLevel.Info, "Pointer rebase complete in: " + stopwatch.Elapsed); return pointerBag; } catch (OperationCanceledException ex) { Logger.Log(LogLevel.Warn, "Pointer rebase canceled", ex); } catch (Exception ex) { Logger.Log(LogLevel.Error, "Error performing pointer rebase", ex); } return null; }, cancellationToken))); } catch (TaskConflictException ex) { Logger.Log(LogLevel.Warn, "A pointer scan is already scheduled."); throw ex; } }
public OpenWithElement(object column, DataTypeBase type, string path) { throw new InvalitContextException("new " + nameof(OpenWithElement)); }
internal AsyncDataProducerV2(byte mask, DataTypeBase dataTypeBase, IModuleBoardBridge bridge) : this(dataTypeBase.eventConfig[1], mask, dataTypeBase, bridge) { }
public OpenWithElementTypeAsJson(object column, DataTypeBase type) { throw new InvalitContextException("new " + nameof(OpenWithElementTypeAsJson)); }
/// <summary> /// Sets the element type to which all constraints apply. /// </summary> /// <param name="elementType">The new element type.</param> public override void SetElementType(DataTypeBase elementType) { this.Left?.SetElementType(elementType); this.Right?.SetElementType(elementType); }
/// <summary> /// Determines if a hex value can be parsed from the given string. /// </summary> /// <param name="dataType">The type of the given value.</param> /// <param name="value">The value to be parsed.</param> /// <returns>A boolean indicating if the value is parseable as hex.</returns> public static Boolean CanParseHex(DataTypeBase dataType, String value) { if (value == null) { return(false); } // Remove 0x hex specifier if (value.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { value = value.Substring(2); } // Remove trailing 0s while (value.StartsWith("0") && value.Length > 1) { value = value.Substring(1); } // Remove negative sign from signed integer types, as TryParse methods do not handle negative hex values switch (dataType) { case DataTypeBase type when type == DataTypeBase.Byte || type == DataTypeBase.Int16 || type == DataTypeBase.Int32 || type == DataTypeBase.Int64: if (value.StartsWith("-")) { value = value.Substring(1); } break; default: break; } switch (dataType) { case DataTypeBase type when type == DataTypeBase.Byte: return(IsByte(value, true)); case DataTypeBase type when type == DataTypeBase.SByte: return(IsSByte(value, true)); case DataTypeBase type when type == DataTypeBase.Int16: return(IsInt16(value, true)); case DataTypeBase type when type == DataTypeBase.Int32: return(IsInt32(value, true)); case DataTypeBase type when type == DataTypeBase.Int64: return(IsInt64(value, true)); case DataTypeBase type when type == DataTypeBase.UInt16: return(IsUInt16(value, true)); case DataTypeBase type when type == DataTypeBase.UInt32: return(IsUInt32(value, true)); case DataTypeBase type when type == DataTypeBase.UInt64: return(IsUInt64(value, true)); case DataTypeBase type when type == DataTypeBase.Single: return(IsSingle(value, true)); case DataTypeBase type when type == DataTypeBase.Double: return(IsDouble(value, true)); default: return(false); } }
/// <summary> /// Sets the element type to which all constraints apply. /// </summary> /// <param name="elementType">The new element type.</param> public override void SetElementType(DataTypeBase elementType) { this.ElementType = elementType; this.RootConstraint?.SetElementType(elementType); }
public void BitSeriesFunctionalTest() { // set up a source tag, put it in a dictionary (like in the FDA), and make the dictionary available to the derived tags class Dictionary <Guid, FDADataPointDefinitionStructure> srcTags = new Dictionary <Guid, FDADataPointDefinitionStructure>(); FDADataPointDefinitionStructure srcTag = new FDADataPointDefinitionStructure { DPDUID = Guid.NewGuid(), DPDSEnabled = true }; srcTags.Add(srcTag.DPDUID, srcTag); DerivedTag.Tags = srcTags; DataTypeBase datatype = Modbus.ModbusProtocol.DataType.UINT32; // extract bit 0 only BitSeriesDerivedTag softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":0:1"); softTag.Initialize(); softTag.DPDSEnabled = true; UInt32 expectedDerivedVal; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(srcTag.LastRead.Timestamp, softTag.LastRead.Timestamp); Assert.AreEqual(srcTag.LastRead.Quality, softTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = testVal & 1; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract bit 31 only softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":31:1"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(softTag.LastRead.Timestamp, srcTag.LastRead.Timestamp); Assert.AreEqual(softTag.LastRead.Quality, srcTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = (testVal & (UInt32)Math.Pow(2, 31)) >> 31; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract bit 20 only softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":20:1"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(softTag.LastRead.Timestamp, srcTag.LastRead.Timestamp); Assert.AreEqual(softTag.LastRead.Quality, srcTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = (testVal & (UInt32)Math.Pow(2, 20)) >> 20; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract bits 0-1 softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":0:2"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(softTag.LastRead.Timestamp, srcTag.LastRead.Timestamp); Assert.AreEqual(softTag.LastRead.Quality, srcTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = testVal & ((UInt32)Math.Pow(2, 1) + (UInt32)Math.Pow(2, 0)) >> 0; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract bits 10-13 softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":10:4"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(softTag.LastRead.Timestamp, srcTag.LastRead.Timestamp); Assert.AreEqual(softTag.LastRead.Quality, srcTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = (testVal & ((UInt32)Math.Pow(2, 10) + (UInt32)Math.Pow(2, 11) + (UInt32)Math.Pow(2, 12) + (UInt32)Math.Pow(2, 13))) >> 10; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // "extract" all the bits softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":0:32"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(softTag.LastRead.Timestamp, srcTag.LastRead.Timestamp); Assert.AreEqual(softTag.LastRead.Quality, srcTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = testVal; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract the highest 6 bits softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":26:6"); softTag.Initialize(); softTag.DPDSEnabled = true; foreach (UInt32 testVal in TestValues) { // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 192, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // check that the derived tag has the same timestamp and quality as the source tag Assert.AreEqual(srcTag.LastRead.Timestamp, softTag.LastRead.Timestamp); Assert.AreEqual(srcTag.LastRead.Quality, softTag.LastRead.Quality); // check that the value of the derived tag is correct expectedDerivedVal = expectedDerivedVal = (testVal & ((UInt32)Math.Pow(2, 26) + (UInt32)Math.Pow(2, 27) + (UInt32)Math.Pow(2, 28) + (UInt32)Math.Pow(2, 29) + (UInt32)Math.Pow(2, 30) + (UInt32)Math.Pow(2, 31))) >> 26; Assert.AreEqual(expectedDerivedVal, softTag.LastRead.Value); } // extract the highest 6 bits, source tag has bad quality softTag = (BitSeriesDerivedTag)DerivedTag.Create(Guid.NewGuid().ToString(), "bitser", srcTag.DPDUID.ToString() + ":26:6"); softTag.Initialize(); softTag.DPDSEnabled = true; FDADataPointDefinitionStructure.Datapoint lastread_before; foreach (UInt32 testVal in TestValues) { lastread_before = softTag.LastRead; // update the value in the source tag srcTag.LastRead = new FDADataPointDefinitionStructure.Datapoint( testVal, 0, DateTime.Now, "", datatype, DataRequest.WriteMode.Insert); // soft tag should not have updated Assert.AreSame(lastread_before, softTag.LastRead); } }