public OpcClient( IEasyDAClient opcClient, IUserAttentions <Model> userAttentions, ICriticalStops <Model> criticalStops, IOpcSettings mahloSettings, //IPlcSettings seamSettings, SynchronizationContext synchronizationContext, ILogger logger) { this.opcClient = opcClient; this.userAttentions = userAttentions; this.criticalStops = criticalStops; this.mahloSettings = mahloSettings; //this.seamSettings = seamSettings; this.synchronizationContext = synchronizationContext; this.log = logger; this.criticalAlarmsSubscription = Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.criticalStops).PropertyChanged += h, h => ((INotifyPropertyChanged)this.criticalStops).PropertyChanged -= h) .Where(args => args.EventArgs.PropertyName == nameof(CriticalStops <Model> .Any)) .Subscribe(_ => this.SetCriticalAlarmIndicator(this.criticalStops.Any)); this.userAttentionsSubscription = Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.userAttentions).PropertyChanged += h, h => ((INotifyPropertyChanged)this.userAttentions).PropertyChanged -= h) .Where(args => args.EventArgs.PropertyName == nameof(UserAttentions <Model> .Any)) .Subscribe(_ => this.SetStatusIndicator(this.userAttentions.Any)); this.Initialize(); }
public PatternRepeatLogic( IDbLocal dbLocal, CutRollList cutRolls, InspectionAreaList inspectionAreaList, ISapRollAssigner sapRollAssigner, IPatternRepeatSrc srcData, ISewinQueue sewinQueue, IServiceSettings serviceSettings, IUserAttentions <PatternRepeatModel> userAttentions, ICriticalStops <PatternRepeatModel> criticalStops, IProgramState programState, IScheduler scheduler) : base(dbLocal, srcData, sewinQueue, serviceSettings, userAttentions, criticalStops, programState, scheduler) { this.dbLocal = dbLocal; this.cutRolls = cutRolls; this.inspectionAreaList = inspectionAreaList; this.sapRollAssigner = sapRollAssigner; this.serviceSettings = serviceSettings; this.srcData = srcData; this.sewinQueue = sewinQueue; this.programState = programState; this.nextCutRollId = dbLocal.GetNextCutRollId(); this.SeamDelayLine.DelayTicks = serviceSettings.SeamToCutKnife; programState.Saving += this.SaveState; this.KeepBowAndSkewUpToDateAsync().NoWait(); }
public MahloLogic( IDbLocal dbLocal, IMahloSrc mahloSrc, ISewinQueue sewinQueue, IServiceSettings appInfo, IUserAttentions <MahloModel> userAttentions, ICriticalStops <MahloModel> criticalStops, IProgramState programState, IScheduler scheduler) : base(dbLocal, mahloSrc, sewinQueue, appInfo, userAttentions, criticalStops, programState, scheduler) { this.dbLocal = dbLocal; }
public BowAndSkewLogic( IDbLocal dbLocal, IBowAndSkewSrc dataSrc, ISewinQueue sewinQueue, IServiceSettings appInfo, IUserAttentions <BowAndSkewModel> userAttentions, ICriticalStops <BowAndSkewModel> criticalStops, IProgramState programState, IScheduler scheduler) : base(dbLocal, dataSrc, sewinQueue, appInfo, userAttentions, criticalStops, programState, scheduler) { this.dbLocal = dbLocal; this.dataSrc = dataSrc; this.SeamDelayLine.DelayTicks = appInfo.SeamToBowAndSkew; }
public OpcSrcSim( IDbMfgSim dbMfg, ISewinQueue sewinQueue, IUserAttentions <Model> userAttentions, ICriticalStops <Model> criticalStops, IOpcSettings mahloSettings, IProgramState programState, SynchronizationContext synchronizationContext, ILogger logger, IServiceSettings settings) { this.dbMfg = dbMfg; this.sewinQueue = sewinQueue; this.userAttentions = userAttentions; this.criticalStops = criticalStops; this.mahloSettings = mahloSettings; //this.seamSettings = seamSettings; this.synchronizationContext = synchronizationContext; this.programState = programState; this.log = logger; this.settings = settings; this.disposables.AddRange(new IDisposable[] { Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.criticalStops).PropertyChanged += h, h => ((INotifyPropertyChanged)this.criticalStops).PropertyChanged -= h) .Where(args => args.EventArgs.PropertyName == nameof(CriticalStops <Model> .Any)) .Subscribe(_ => this.SetCriticalAlarmIndicator(this.criticalStops.Any)), Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.userAttentions).PropertyChanged += h, h => ((INotifyPropertyChanged)this.userAttentions).PropertyChanged -= h) .Where(args => args.EventArgs.PropertyName == nameof(UserAttentions <Model> .Any)) .Subscribe(_ => this.SetStatusIndicator(this.userAttentions.Any)), }); var state = programState.GetSubState(nameof(OpcSrcSim <Model>), typeof(Model).Name); this.cutRollCount = state.Get <int?>(nameof(this.cutRollCount)) ?? 0; this.rollIndex = state.Get <int?>(nameof(this.rollIndex)) ?? 0; this.FeetCounter = state.Get <double?>(nameof(this.FeetCounter)) ?? this.FeetCounter; this.feetCounterAtRollStart = state.Get <double?>(nameof(this.feetCounterAtRollStart)) ?? this.feetCounterAtRollStart; // state = this.programState.GetSubState(nameof(MeterLogic <MahloModel>), typeof(Model).Name); string rollNo = state.Get <string>(nameof(GreigeRoll.RollNo)) ?? string.Empty; if (!string.IsNullOrEmpty(rollNo)) { var currentRoll = this.sewinQueue.Rolls.FirstOrDefault(item => item.RollNo == rollNo) ?? new GreigeRoll(); this.rollIndex = this.sewinQueue.Rolls.IndexOf(currentRoll); } programState.Saving += ps => { ps.GetSubState(nameof(OpcSrcSim <Model>)) .Set(typeof(Model).Name, new { this.cutRollCount, this.rollIndex, this.FeetCounter, this.feetCounterAtRollStart, }); }; this.isCheckRollEndSeamNeeded = this.sewinQueue.Rolls.FirstOrDefault()?.IsCheckRoll ?? false; }
public MeterLogicTests() { const int roll1Length = 100; const int roll2Length = 200; const int roll3Length = 300; const int roll4Length = 400; const int roll5Length = 400; const int roll6Length = 400; const int roll7Length = 400; this.srcData = new MockMeterSrc <MahloModel>(); this.sewinQueue = Substitute.For <ISewinQueue>(); this.dbMfg = Substitute.For <IDbMfg>(); this.dbLocal = Substitute.For <IDbLocal>(); this.appInfo = Substitute.For <IServiceSettings>(); this.userAttentions = Substitute.For <IUserAttentions <MahloModel> >(); this.criticalStops = Substitute.For <ICriticalStops <MahloModel> >(); this.appInfo.MinRollLengthForStyleAndRollCounting = 1; this.appInfo.MinRollLengthForLengthChecking = 1; var stateProvider = Substitute.For <IProgramStateProvider>(); stateProvider.GetProgramState().Returns("{}"); this.programState = new ProgramState(stateProvider); var roll1 = new MahloService.Models.GreigeRoll() { Id = 1, RollNo = "12345", RollLength = roll1Length, }; var roll2 = new MahloService.Models.GreigeRoll() { Id = 2, RollNo = "12346", RollLength = roll2Length, }; var roll3 = new MahloService.Models.GreigeRoll() { Id = 3, RollNo = "12347", RollLength = roll3Length, }; var roll4 = new MahloService.Models.GreigeRoll() { Id = 4, RollNo = "12348", RollLength = roll4Length, }; var roll5 = new MahloService.Models.GreigeRoll() { Id = 5, RollNo = "12349", RollLength = roll5Length, }; var roll6 = new MahloService.Models.GreigeRoll() { Id = 6, RollNo = "12350", RollLength = roll6Length, }; var roll7 = new MahloService.Models.GreigeRoll() { Id = 7, RollNo = "12351", RollLength = roll7Length, }; this.greigeRolls = new List <GreigeRoll> { roll1, roll2, roll3, roll4, roll5, roll6, roll7 }; this.sewinQueue.Rolls.Returns(new BindingList <GreigeRoll>(this.greigeRolls)); this.target = new MahloLogic(this.dbLocal, this.srcData, this.sewinQueue, this.appInfo, this.userAttentions, this.criticalStops, this.programState, this.testSchedulers) { CurrentRoll = this.sewinQueue.Rolls[0] }; this.sewinQueue.QueueChanged += Raise.Event <Action>(); Assert.True(this.userAttentions.VerifyRollSequence); Assert.NotNull(this.target.CurrentRoll); this.userAttentions.ClearAll(); this.target.Start(); }
public MeterLogic( IDbLocal dbLocal, IMeterSrc <Model> srcData, ISewinQueue sewinQueue, IServiceSettings appInfo, IUserAttentions <Model> userAttentions, ICriticalStops <Model> criticalStops, IProgramState programState, IScheduler scheduler) { this.dbLocal = dbLocal; this.sewinQueue = sewinQueue; this.srcData = srcData; this.appInfo = appInfo; this.UserAttentions = userAttentions; this.CriticalStops = criticalStops; this.programState = programState; programState.Saving += this.SaveState; this.Disposables = new List <IDisposable> { Observable .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.srcData).PropertyChanged += h, h => ((INotifyPropertyChanged)this.srcData).PropertyChanged -= h) .Subscribe(args => this.OpcValueChanged(args.EventArgs.PropertyName)), Observable .Interval(TimeSpan.FromSeconds(1), scheduler) .Subscribe(_ => { this.Recipe = this.srcData.Recipe; this.IsManualMode = this.srcData.IsAutoMode; }), Observable .FromEvent( h => this.sewinQueue.QueueChanged += h, h => this.sewinQueue.QueueChanged -= h) .Subscribe(_ => this.SewinQueueChanged()), Observable .FromEventPattern <CancelEventHandler, CancelEventArgs>( h => this.sewinQueue.CanRemoveRollQuery += h, h => this.sewinQueue.CanRemoveRollQuery -= h) .Subscribe(args => args.EventArgs.Cancel |= args.Sender == this.currentRoll), Observable .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged += h, h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged -= h) .Subscribe(_ => { this.IsMapValid &= this.UserAttentions.Any; this.IsChanged = true; }), Observable .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged += h, h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged -= h) .Subscribe(_ => { this.IsMapValid &= this.CriticalStops.Any; this.IsChanged = true; }), Observable .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>( h => ((INotifyPropertyChanged)this.sewinQueue).PropertyChanged += h, h => ((INotifyPropertyChanged)this.sewinQueue).PropertyChanged -= h) .Where(args => args.EventArgs.PropertyName == nameof(this.sewinQueue.Message)) .Subscribe(args => this.QueueMessage = this.sewinQueue.Message), }; }