示例#1
0
        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();
        }
示例#2
0
        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;
        }
示例#3
0
 public OpcServerController(IOpcSettings opcSettings, ILogger logger)
 {
     this.opcSettings = opcSettings;
     this.logger      = logger;
     this.processName = Path.GetFileNameWithoutExtension(opcSettings.OpcServerPath);
 }