Esempio n. 1
0
 public CarpetProcessor(
     ISewinQueue sewinQueue,
     IMahloLogic mahloLogic,
     IBowAndSkewLogic bowAndSkewLogic,
     IPatternRepeatLogic patternRepeatLogic)
 {
     this.SewinQueue         = sewinQueue;
     this.MahloLogic         = mahloLogic;
     this.BowAndSkewLogic    = bowAndSkewLogic;
     this.PatternRepeatLogic = patternRepeatLogic;
 }
Esempio n. 2
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);
        }
Esempio n. 3
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;
 }
Esempio n. 4
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()),
            };
        }
Esempio n. 5
0
        public FormBowAndSkew(IBowAndSkewLogic logic, ISewinQueue sewinQueue, IMahloIpcClient mahloClient, IServiceSettings serviceSettings)
        {
            this.InitializeComponent();
            this.statusBar1.StatusBarInfo = (IStatusBarInfo)logic;
            this.logic           = logic;
            this.sewinQueue      = sewinQueue;
            this.mahloClient     = mahloClient;
            this.serviceSettings = serviceSettings;

            this.disposables.AddRange(new[] {
                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.myScrollBar.AutoScrollPosition = this.logic.CurrentRollIndex - 2;
                }),

                Observable.FromEventPattern <EventHandler, EventArgs>(
                    h => Application.Idle += h,
                    h => Application.Idle -= h)
                .Subscribe(args => this.btnSetRecipe.Enabled = this.dataGridView1.WideRowIndex >= 0),
            });

            // Make column heading alignment match column data alignment
            foreach (DataGridViewColumn column in this.dataGridView1.Columns)
            {
                column.HeaderCell.Style.Alignment = column.DefaultCellStyle.Alignment;
            }
        }