public void Test_ProductionEventsFactory_EventListCreation(ProductionEventType eventType, Type listType) { var factory = new ProductionEventsFactory(); var list = factory.NewEventList(-1, Guid.Empty, eventType); Assert.True(list.GetType() == listType, $"Event list created by factory for {eventType} is of type {list.GetType()} not {listType}"); Assert.True(list.Count() == 0, "Events list not empty after construction"); Assert.True(list.EventsChanged == false, "Events changed after construction"); }
public static string EventChangeListPersistantFileName(short machineID, ProductionEventType eventListType) => $"{machineID}-Events-{eventListType}-Summary.evt";
public static bool Equals_ProductionEventType(ProductionEventType x, ProductionEventType y) => x == y;
public SiteModelMachineTargetValueTrackingState(IProductionEventLists machineEventLists, ProductionEventType eventType) { EventList = (IProductionEvents <T>)machineEventLists.GetEventList(eventType); StartDate = Consts.MIN_DATETIME_AS_UTC; EndDate = Consts.MIN_DATETIME_AS_UTC; Index = -1; Stamp = -1; ThisEvent = default; NextEvent = default; }
/// <summary> /// Create an event list of the requested type /// </summary> /// <param name="siteModelID"></param> /// <param name="eventType"></param> /// <param name="machineID"></param> /// <returns></returns> public IProductionEvents NewEventList(short machineID, Guid siteModelID, ProductionEventType eventType) { switch (eventType) { case ProductionEventType.TargetCCV: return(new ProductionEvents <short>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.TargetPassCount: return(new ProductionEvents <ushort>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadUInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.MachineMapReset: return(null); //throw new NotImplementedException("ProductionEventType.MachineMapReset not implemented"); case ProductionEventType.TargetLiftThickness: return(new ProductionEvents <float>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadSingle(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.GPSModeChange: return(new ProductionEvents <GPSMode>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (GPSMode)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.VibrationStateChange: return(new ProductionEvents <VibrationState>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (VibrationState)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.AutoVibrationStateChange: return(new ProductionEvents <AutoVibrationState>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (AutoVibrationState)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.MachineGearChange: return(new ProductionEvents <MachineGear>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (MachineGear)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.MachineAutomaticsChange: return(new ProductionEvents <AutomaticsType>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (AutomaticsType)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.MachineRMVJumpValueChange: return(new ProductionEvents <short>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.ICFlagsChange: return(new ProductionEvents <byte>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.ElevationMappingModeStateChange: return(new ProductionEvents <ElevationMappingMode>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (ElevationMappingMode)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.GPSAccuracyChange: return(new ProductionEvents <GPSAccuracyAndTolerance>(machineID, siteModelID, eventType, (w, s) => { w.Write(s.GPSTolerance); w.Write((byte)s.GPSAccuracy); }, r => { var tolerance = r.ReadUInt16(); var accuracy = (GPSAccuracy)r.ReadByte(); return new GPSAccuracyAndTolerance(accuracy, tolerance); }, ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.PositioningTech: return(new ProductionEvents <PositioningTech>(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (PositioningTech)r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.TempWarningLevelMinChange: return(new ProductionEvents <ushort>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadUInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.TempWarningLevelMaxChange: return(new ProductionEvents <ushort>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadUInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.TargetMDP: return(new ProductionEvents <short>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.LayerID: return(new ProductionEvents <ushort>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadUInt16(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.DesignOverride: return(new ProductionEvents <OverrideEvent <int> >(machineID, siteModelID, eventType, (w, s) => { w.Write(s.EndDate.ToBinary()); w.Write(s.Value); }, r => new OverrideEvent <int>(DateTime.FromBinary(r.ReadInt64()), r.ReadInt32()), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.LayerOverride: return(new ProductionEvents <OverrideEvent <ushort> >(machineID, siteModelID, eventType, (w, s) => { w.Write(s.EndDate.ToBinary()); w.Write(s.Value); }, r => new OverrideEvent <ushort>(DateTime.FromBinary(r.ReadInt64()), r.ReadUInt16()), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.TargetCCA: return(new ProductionEvents <byte>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadByte(), ProductionEventStateEqualityComparer.Equals)); case ProductionEventType.StartEndRecordedData: return(new StartEndProductionEvents(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (ProductionEventType)r.ReadByte())); case ProductionEventType.MachineStartupShutdown: return(new StartEndProductionEvents(machineID, siteModelID, eventType, (w, s) => w.Write((byte)s), r => (ProductionEventType)r.ReadByte())); case ProductionEventType.DesignChange: return(new ProductionEvents <int>(machineID, siteModelID, eventType, (w, s) => w.Write(s), r => r.ReadInt32(), ProductionEventStateEqualityComparer.Equals)); default: return(null); } }