Exemplo n.º 1
0
        public FormMahlo(IMahloLogic logic, ISewinQueue sewinQueue, IMahloIpcClient ipcClient, IServiceSettings serviceSettings)
        {
            this.InitializeComponent();
            this.logic                    = logic;
            this.sewinQueue               = sewinQueue;
            this.ipcClient                = ipcClient;
            this.serviceSettings          = serviceSettings;
            this.statusBar1.StatusBarInfo = (IStatusBarInfo)this.logic;

            this.MahloPropertyChangedSubscription =
                Observable.FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                    h => ((INotifyPropertyChanged)this.logic).PropertyChanged += h,
                    h => ((INotifyPropertyChanged)this.logic).PropertyChanged -= h)
                .Where(args =>
                       args.EventArgs.PropertyName == nameof(this.logic.CurrentRoll))
                .Subscribe(args =>
            {
                this.srcCurrentRoll.DataSource = this.logic.CurrentRoll;
                int nextIndex = this.sewinQueue.Rolls.IndexOf(this.logic.CurrentRoll) + 1;
                this.srcNextRoll.DataSource = nextIndex < this.sewinQueue.Rolls.Count ? this.sewinQueue.Rolls[nextIndex] : new GreigeRoll();
                this.DataGridView1_SelectionChanged(this.dataGridView1, EventArgs.Empty);
                this.dataGridView1.EnsureVisibleRow(this.logic.CurrentRollIndex);
                this.myScrollBar1.AutoScrollPosition = this.logic.CurrentRollIndex - 2;
            });

            // Make column heading alignment match column data alignment
            foreach (DataGridViewColumn column in this.dataGridView1.Columns)
            {
                column.HeaderCell.Style.Alignment = column.DefaultCellStyle.Alignment;
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 public CarpetProcessor(
     ISewinQueue sewinQueue,
     IMahloLogic mahloLogic,
     IBowAndSkewLogic bowAndSkewLogic,
     IPatternRepeatLogic patternRepeatLogic)
 {
     this.SewinQueue         = sewinQueue;
     this.MahloLogic         = mahloLogic;
     this.BowAndSkewLogic    = bowAndSkewLogic;
     this.PatternRepeatLogic = patternRepeatLogic;
 }
Exemplo n.º 4
0
        public Task <(string message, string caption)> BasSetRecipe(string rollNo, string styleCode, string recipeName, bool isManualMode, RecipeApplyToEnum applyTo)
        {
            var tcs = new TaskCompletionSource <(string message, string caption)>();

            TaskUtilities.RunOnMainThreadAsync(async() =>
            {
                try
                {
                    IBowAndSkewLogic bas   = Program.Container.GetInstance <IBowAndSkewLogic>();
                    ISewinQueue sewinQueue = Program.Container.GetInstance <ISewinQueue>();
                    bool shouldApply       = false;
                    if (applyTo == RecipeApplyToEnum.Roll)
                    {
                        if (rollNo == bas.CurrentRoll.RollNo)
                        {
                            shouldApply = true;
                        }
                        else
                        {
                            // Make sure the selected roll isn't already passed.
                            var selectedRoll = sewinQueue.Rolls.FirstOrDefault(roll => roll.RollNo == rollNo);
                            if ((selectedRoll?.Id ?? 0) < bas.CurrentRoll.Id)
                            {
                                tcs.SetResult(($"Roll #{rollNo} is no longer the current roll. The recipe has not been changed.", "Not allowed!"));
                                return;
                            }
                        }
                    }
                    else
                    {
                        shouldApply = styleCode == bas.CurrentRoll.StyleCode;
                        rollNo      = string.Empty;
                    }

                    if (shouldApply)
                    {
                        await this.BasApplyRecipeAsync(recipeName, isManualMode);
                    }

                    // Save settings to the database
                    await this.dbMfg.BasUpdateDefaultRecipeAsync(styleCode, rollNo, recipeName);
                    await sewinQueue.RefreshAsync();
                    tcs.SetResult((string.Empty, string.Empty));
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }).NoWait();

            return(tcs.Task);
        }
Exemplo n.º 5
0
 public MahloIpcClient(
     ISewinQueue sewinQueue,
     ICutRollList cutRollList,
     IInspectionAreaList inspectionAreaList,
     IClientSettings appInfo,
     SynchronizationContext context)
 {
     this.appInfo            = appInfo;
     this.sewinQueue         = sewinQueue;
     this.cutRollList        = cutRollList;
     this.inspectionAreaList = inspectionAreaList;
     this.context            = context;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 public CarpetProcessor(
     ISewinQueue sewinQueue,
     IMahloLogic mahloLogic,
     IBowAndSkewLogic bowAndSkewLogic,
     IPatternRepeatLogic patternRepeatLogic,
     ICutRollLogic cutRollLogic,
     IOpcServerController opcServerController,
     IServiceSettings appInfo)
 {
     this.SewinQueue          = sewinQueue;
     this.MahloLogic          = mahloLogic;
     this.BowAndSkewLogic     = bowAndSkewLogic;
     this.PatternRepeatLogic  = patternRepeatLogic;
     this.CutRollLogic        = cutRollLogic;
     this.opcServerController = opcServerController;
     this.appInfo             = appInfo;
 }
Exemplo n.º 9
0
        public MeterLogic(IMahloIpcClient ipcClient, ISewinQueue sewinQueue, IServiceSettings serviceSettings)
        {
            this.ipcClient       = ipcClient;
            this.sewinQueue      = sewinQueue;
            this.serviceSettings = serviceSettings;

            this.sewinQueueChangedSubscription = Observable
                                                 .FromEventPattern <EventHandler, EventArgs>(
                h => this.sewinQueue.Changed += h,
                h => this.sewinQueue.Changed -= h)
                                                 .Subscribe(args =>
            {
                bool indexInRange = this.CurrentRollIndex >= 0 && this.currentRollIndex < this.sewinQueue.Rolls.Count;
                this.CurrentRoll  = indexInRange ? this.sewinQueue.Rolls[this.CurrentRollIndex] : new GreigeRoll();
            });

            this.updateMeterLogicSubscription = Observable
                                                .FromEvent <Action <(string, JObject)>, (string name, JObject jObject)>(
                h => this.ipcClient.MeterLogicUpdated += h,
                h => this.ipcClient.MeterLogicUpdated -= h)
                                                .Where(tuple => tuple.name == this.InterfaceName)
                                                .Subscribe(tuple =>
            {
                tuple.jObject.Populate(this);
                this.RefreshStatusDisplay();
            });

            this.connectionStateSubscription = Observable
                                               .FromEvent <Action <string>, string>(
                h => this.ipcClient.IpcStatusMessageChanged += h,
                h => this.ipcClient.IpcStatusMessageChanged -= h)
                                               .Subscribe(message => this.ConnectionStatusMessage = message);

            this.userAttentionsSubscription = Observable
                                              .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged += h,
                h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged -= h)
                                              .Subscribe(args => this.OnPropertyChanged(nameof(this.UserAttentions)));

            this.criticalStopsSubscription = Observable
                                             .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged += h,
                h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged += h)
                                             .Subscribe(args => this.OnPropertyChanged(nameof(this.CriticalStops)));
        }
Exemplo n.º 10
0
        public MahloServer(
            ILogger logger,
            ISewinQueue sewinQueue,
            CutRollList cutRolls,
            InspectionAreaList inspectionAreaList,
            IMahloLogic mahloLogic,
            IBowAndSkewLogic bowAndSkewLogic,
            IPatternRepeatLogic patternRepeatLogic,
            IScheduler scheduler)
        {
            this.log                = logger;
            this.sewinQueue         = sewinQueue;
            this.cutRolls           = cutRolls;
            this.inspectionAreaList = inspectionAreaList;
            this.mahloLogic         = mahloLogic;
            this.bowAndSkewLogic    = bowAndSkewLogic;
            this.patternRepeatLogic = patternRepeatLogic;

            this.disposables = new List <IDisposable>
            {
                Observable
                .Interval(TimeSpan.FromMilliseconds(1000), scheduler)
                .Subscribe(_ =>
                {
                    this.UpdateMeterLogic(nameof(IMahloLogic), this.mahloLogic);
                    this.UpdateMeterLogic(nameof(IBowAndSkewLogic), this.bowAndSkewLogic);
                    this.UpdateMeterLogic(nameof(IPatternRepeatLogic), this.patternRepeatLogic);
                    this.UpdateCutRollList();
                    this.UpdateInspectionArea();
                    if (this.sewinQueue.IsChanged)
                    {
                        this.UpdateSewinQueue();
                    }
                }),

                Observable
                .FromEvent(
                    h => this.sewinQueue.QueueChanged += h,
                    h => this.sewinQueue.QueueChanged -= h)
                .Subscribe(_ => this.UpdateSewinQueue()),
            };
        }
Exemplo n.º 11
0
 public MahloGridSource(ISewinQueue sewinQueue, IMahlo2 mahlo2, IMahloBowAndSkew bowAndSkew, IPatternRepeat patternRepeat)
 {
 }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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),
            };
        }
Exemplo n.º 14
0
        public void MoveQueueRoll(int rollIndex, int direction)
        {
            ISewinQueue sewinQueue = Program.Container.GetInstance <ISewinQueue>();

            sewinQueue.MoveRoll(rollIndex, direction);
        }
Exemplo n.º 15
0
 public PatternRepeatLogic(IMahloIpcClient ipcClient, ISewinQueue sewinQueue, IServiceSettings serviceSettings)
     : base(ipcClient, sewinQueue, serviceSettings)
 {
 }
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
 public ProductionLine(IDbLocal dbLocal, ISewinQueue sewinQueue, IMahlo2 machlo2, IBowAndSkew bowAndSkew, IPatternRepeat patternRepeat, )
 {
     this.dbLocal    = dbLocal;
     this.sewinQueue = sewinQueue;
 }
Exemplo n.º 18
0
 public MahloLogic(IMahloIpcClient ipcClient, ISewinQueue sewinQueue, IServiceSettings serviceSettings)
     : base(ipcClient, sewinQueue, serviceSettings)
 {
 }