Beispiel #1
0
 private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         {
             GreigeRoll roll = this.sewinQueue.Rolls[e.RowIndex];
             if (e.ColumnIndex == this.colMeasuredLength.Index)
             {
                 if (e.RowIndex < this.logic.CurrentRollIndex)
                 {
                     (e.CellStyle.ForeColor, e.CellStyle.BackColor) =
                         roll.RollLength == 0 ?
                         new CellColor {
                         ForeColor = this.dataGridView1.DefaultCellStyle.ForeColor, BackColor = this.dataGridView1.DefaultCellStyle.BackColor
                     } :
                     CellColor.GetFeetColor(roll.RollLength, (long)e.Value, this.serviceSettings);
                 }
             }
             else if (roll.IsComplete)
             {
                 (e.CellStyle.ForeColor, e.CellStyle.BackColor) = CellColor.IsCompletedColor;
             }
         }
     }
 }
Beispiel #2
0
        public RollTypeEnum DetermineRollType(GreigeRoll roll)
        {
            string[] sHPBackingCodes = { "XL", "XP", "HP" };

            string sBacking1 = "", sBacking2 = "";
            double nWidth1 = 0F, nWidth2 = 0F;

            int positionInQueue = this.Rolls.IndexOf(roll);

            if (string.Equals(roll.RollNo, GreigeRoll.CheckRollId, StringComparison.OrdinalIgnoreCase))
            {
                if (positionInQueue == this.Rolls.Count - 1)
                {
                    //since this is the last roll in the queue, we'll assume
                    //it's the "tailout"
                    return(RollTypeEnum.Leader);
                }

                //search backward in queue for first non-CheckRoll
                for (int n = positionInQueue - 1; n >= 0; n--)
                {
                    if (!string.Equals(this.Rolls[n].RollNo, GreigeRoll.CheckRollId, StringComparison.OrdinalIgnoreCase))
                    {
                        sBacking1 = this.Rolls[n].BackingCode;
                        nWidth1   = this.Rolls[n].RollWidth;
                        break;
                    }
                }

                //search forward in queue for first non-CheckRoll
                for (int n = positionInQueue + 1; n < this.Rolls.Count; n++)
                {
                    if (!string.Equals(this.Rolls[n].RollNo, GreigeRoll.CheckRollId, StringComparison.OrdinalIgnoreCase))
                    {
                        sBacking2 = this.Rolls[n].BackingCode;
                        nWidth2   = this.Rolls[n].RollWidth;
                        break;
                    }
                }

                if (nWidth1 != nWidth2)
                {
                    return(RollTypeEnum.Leader);
                }
                else if (!sHPBackingCodes.Contains(sBacking1) && sHPBackingCodes.Contains(sBacking2))
                {
                    return(RollTypeEnum.Leader);
                }
                else if (!sHPBackingCodes.Contains(sBacking2) && sHPBackingCodes.Contains(sBacking1))
                {
                    return(RollTypeEnum.Leader);
                }
                else
                {
                    return(RollTypeEnum.CheckRoll);
                }
            }

            return(RollTypeEnum.Greige);
        }
Beispiel #3
0
        public void SetCutSkewColor(DataGridViewCellFormattingEventArgs args, IServiceSettings settings)
        {
            GreigeRoll roll = this.carpetProcessor.PatternRepeatLogic.CurrentRoll;

            (args.CellStyle.ForeColor, args.CellStyle.BackColor) =
                CellColor.GetSkewColor(roll.BackingCode, (double)args.Value, this.serviceSettings);
        }
Beispiel #4
0
        private void GrdGreigeRoll_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            var col = this.grdGreigeRoll.Columns[e.ColumnIndex];

            if (e.RowIndex >= 0 && this.sewinQueueColumnNames.Contains(col.DataPropertyName))
            {
                this.SetCompletedColor(e);
            }

            GreigeRoll gridRoll = this.carpetProcessor.SewinQueue.Rolls[e.RowIndex];

            SetColor(this.carpetProcessor.MahloLogic, this.mahloColumnNames);
            SetColor(this.carpetProcessor.BowAndSkewLogic, this.bowAndSkewColumnNames);
            SetColor(this.carpetProcessor.PatternRepeatLogic, this.patternRepeatColumnNames);

            void SetColor(IMeterLogic logic, string[] names)
            {
                if (names.Contains(col.DataPropertyName))
                {
                    if (logic.CurrentRoll == gridRoll)
                    {
                        (e.CellStyle.ForeColor, e.CellStyle.BackColor) = CellColor.ActiveColor;
                    }
                    else if (e.RowIndex >= 0 && e.RowIndex < logic.CurrentRollIndex)
                    {
                        var action = this.grdGreigeRoll.Columns[e.ColumnIndex].Tag as CellFormattingAction;
                        action?.Invoke(e, this.serviceSettings);
                    }
                }
            }
        }
Beispiel #5
0
        public void SetSkewColor(DataGridViewCellFormattingEventArgs args, IServiceSettings settings)
        {
            GreigeRoll roll = (GreigeRoll)this.grdGreigeRoll.Rows[args.RowIndex].DataBoundItem;

            (args.CellStyle.ForeColor, args.CellStyle.BackColor) =
                CellColor.GetSkewColor(roll.BackingCode, (double)args.Value, this.serviceSettings);
        }
Beispiel #6
0
        public void SetCompletedColor(DataGridViewCellFormattingEventArgs args)
        {
            GreigeRoll roll = (GreigeRoll)this.grdGreigeRoll.Rows[args.RowIndex].DataBoundItem;

            (args.CellStyle.ForeColor, args.CellStyle.BackColor) =
                roll.IsComplete ? CellColor.GetIsCompletedColorColor() : this.defaultCellColor;
        }
        /// <summary>
        /// Copy all but RollId to the destination
        /// </summary>
        /// <param name="dest"></param>
        public GreigeRoll ToGreigeRoll()
        {
            GreigeRoll dest = new GreigeRoll
            {
                RollNo              = this.G2ROLL.Trim(),
                OrderNo             = this.G2SCH.Trim(),
                StyleCode           = this.G2STYL.Trim(),
                StyleName           = this.F2SDSC.Trim(),
                ColorCode           = this.G2CLR.Trim(),
                ColorName           = this.F2CDSC.Trim(),
                BackingCode         = this.G2SBK.Trim(),
                PatternRepeatLength = (double)this.G2RPLN,
                DefaultRecipe       = this.DefaultRecipe,

                RollLength      = this.G2LTF,
                ProductImageURL = this.ProductImageURL?.Trim() ?? string.Empty,
            };

            if (double.TryParse(this.G2WTF, out double wtf))
            {
                dest.RollWidth = wtf * 12 + this.G2WTI;
            }

            //dest.G2SJUL = this.G2SJUL;
            //dest.G2STME = this.G2STME;

            return(dest);
        }
Beispiel #8
0
        public static RollTypeEnum DetermineRollType(IList <GreigeRoll> rolls, GreigeRoll roll)
        {
            string[] sHPBackingCodes = { "XL", "XP", "HP" };

            string sBacking1 = "", sBacking2 = "";
            double nWidth1 = 0F, nWidth2 = 0F;

            int positionInQueue = rolls.IndexOf(roll);

            if (roll.RollNo.ToUpperInvariant() == GreigeRoll.CheckRollId)
            {
                if (positionInQueue == rolls.Count - 1)
                {
                    //since this is the last roll in the queue, we'll assume
                    //it's the "tailout"
                    return(RollTypeEnum.Leader);
                }

                //search backward in queue for first non-CheckRoll
                for (int n = positionInQueue - 1; n >= 0; n--)
                {
                    if (rolls[n].RollNo.ToUpperInvariant() != GreigeRoll.CheckRollId)
                    {
                        sBacking1 = rolls[n].BackingCode;
                        nWidth1   = rolls[n].RollWidth;
                        break;
                    }
                }

                //search forward in queue for first non-CheckRoll
                for (int n = positionInQueue + 1; n < rolls.Count; n++)
                {
                    if (rolls[n].RollNo.ToUpperInvariant() != GreigeRoll.CheckRollId)
                    {
                        sBacking2 = rolls[n].BackingCode;
                        nWidth2   = rolls[n].RollWidth;
                        break;
                    }
                }

                if (nWidth1 != nWidth2)
                {
                    return(RollTypeEnum.Leader);
                }
                else if (!sHPBackingCodes.Contains(sBacking1) && sHPBackingCodes.Contains(sBacking2))
                {
                    return(RollTypeEnum.Leader);
                }
                else if (!sHPBackingCodes.Contains(sBacking2) && sHPBackingCodes.Contains(sBacking1))
                {
                    return(RollTypeEnum.Leader);
                }
                else
                {
                    return(RollTypeEnum.CheckRoll);
                }
            }

            return(RollTypeEnum.Greige);
        }
Beispiel #9
0
 public void AddGreigeRoll(GreigeRoll roll)
 {
     using (var connection = this.GetOpenConnection())
     {
         connection.Insert(roll);
     }
 }
Beispiel #10
0
        public void Start(double feetPerMinute)
        {
            this.FeetPerMinute = feetPerMinute;
            if (this.rollIndex < this.sewinQueue.Rolls.Count)
            {
                this.currentRoll = this.sewinQueue.Rolls[this.rollIndex];
                this.isCheckRollEndSeamNeeded = this.currentRoll.IsCheckRoll;
                this.timer = Observable.Interval(TimeSpan.FromMinutes(1 / this.FeetPerMinute))
                             .ObserveOn(SynchronizationContext.Current)
                             .Subscribe(timer =>
                {
                    //Console.WriteLine($"{typeof(Model).Name}: FeetCounter={this.FeetCounter}");
                    double measuredLength    = this.FeetCounter - this.feetCounterAtRollStart;
                    var percentComplete      = measuredLength / this.currentRoll.RollLength;
                    this.BowInInches         = 2.0 * percentComplete;
                    this.SkewInInches        = 2.0 * percentComplete;
                    this.PatternRepeatLength = this.currentRoll.PatternRepeatLength * ((1.045 - 0.955) * percentComplete + 0.955);

                    if (this.isCheckRollEndSeamNeeded && this.currentRoll.IsCheckRoll)
                    {
                        //Console.WriteLine($"Left={currentRoll.RollLength - measuredLength}, Target={this.settings.MaxEndCheckRollPieceLength}");
                        if (this.currentRoll.RollLength - measuredLength < this.settings.MaxEndCheckRollPieceLength)
                        {
                            this.IsSeamDetected           = true;
                            this.isCheckRollEndSeamNeeded = false;
                            Console.WriteLine($"CheckRollSeam Seen at {measuredLength}");
                        }
                    }

                    if (this.FeetCounter - this.feetCounterAtRollStart >= this.currentRoll.RollLength)
                    {
                        this.cutRollCount           = 1;
                        this.IsSeamDetected         = true;
                        this.IsDoffDetected         = true;
                        this.feetCounterAtRollStart = this.FeetCounter;
                        this.rollIndex = this.sewinQueue.Rolls.IndexOf(this.currentRoll);
                        if (++this.rollIndex >= this.sewinQueue.Rolls.Count)
                        {
                            this.Stop();
                        }
                        else
                        {
                            this.currentRoll = this.sewinQueue.Rolls[this.rollIndex];
                            this.isCheckRollEndSeamNeeded = this.currentRoll.IsCheckRoll;
                        }
                    }
                    else if (typeof(Model) == typeof(PatternRepeatModel) &&
                             (int)measuredLength == this.cutRollCount * (this.currentRoll.RollLength / 4))
                    {
                        this.cutRollCount++;
                        this.dbMfg.CutRollCompleted();
                        this.IsDoffDetected = true;
                    }

                    this.FeetCounter += 1.0;
                });
            }
        }
Beispiel #11
0
        public void SetFeetColor(DataGridViewCellFormattingEventArgs args, IServiceSettings settings)
        {
            GreigeRoll roll           = (GreigeRoll)this.grdGreigeRoll.Rows[args.RowIndex].DataBoundItem;
            long       measuredLength = (long)args.Value;

            (args.CellStyle.ForeColor, args.CellStyle.BackColor) =
                roll.RollLength == 0 ? this.defaultCellColor :
                CellColor.GetFeetColor(roll.RollLength, (long)args.Value, this.serviceSettings);
        }
Beispiel #12
0
        public void AddRoll()
        {
            GreigeRoll roll = new GreigeRoll
            {
                RollNo              = this.nextRollNo.ToString(CultureInfo.InvariantCulture),
                OrderNo             = (this.nextRollNo + 1000000).ToString(CultureInfo.InvariantCulture),
                ColorCode           = "001",
                ColorName           = "Red",
                StyleCode           = "Plaid",
                StyleName           = "Checkerboard",
                BackingCode         = "SA",
                DefaultRecipe       = "Line Detection",
                RollWidth           = 144,
                RollLength          = 100,
                PatternRepeatLength = 2.35,
            };

            this.nextRollNo++;
            this.SewinQueue.Add(roll);
        }
Beispiel #13
0
        private void SwapWithTest()
        {
            GreigeRoll roll1 = new GreigeRoll
            {
                Id                  = 1,
                RollNo              = "Roll1",
                OrderNo             = "Order1",
                StyleCode           = "StyleCode1",
                StyleName           = "StyleName1",
                ColorCode           = "ColorCode1",
                ColorName           = "ColorName1",
                BackingCode         = "BackingCode1",
                RollLength          = 1,
                RollWidth           = 1.1,
                DefaultRecipe       = "DefaultRecipe1",
                PatternRepeatLength = 1.001,
                ProductImageURL     = "ProductImageURL1",
            };

            GreigeRoll roll2 = new GreigeRoll
            {
                Id                  = 2,
                RollNo              = "Roll2",
                OrderNo             = "Order2",
                StyleCode           = "StyleCode2",
                StyleName           = "StyleName2",
                ColorCode           = "ColorCode2",
                ColorName           = "ColorName2",
                BackingCode         = "BackingCode2",
                RollLength          = 2,
                RollWidth           = 2.2,
                DefaultRecipe       = "DefaultRecipe2",
                PatternRepeatLength = 2.002,
                ProductImageURL     = "ProductImageURL2",
            };

            // Id shouldn't swap, the others should swap
            roll1.SwapWith(roll2);

            Assert.Equal(2, roll2.Id);
            Assert.Equal("Roll1", roll2.RollNo);
            Assert.Equal("Order1", roll2.OrderNo);
            Assert.Equal("StyleCode1", roll2.StyleCode);
            Assert.Equal("StyleName1", roll2.StyleName);
            Assert.Equal("ColorCode1", roll2.ColorCode);
            Assert.Equal("ColorName1", roll2.ColorName);
            Assert.Equal("BackingCode1", roll2.BackingCode);
            Assert.Equal(1, roll2.RollLength);
            Assert.Equal(1.1, roll2.RollWidth);
            Assert.Equal("DefaultRecipe1", roll2.DefaultRecipe);
            Assert.Equal(1.001, roll2.PatternRepeatLength);
            Assert.Equal("ProductImageURL1", roll2.ProductImageURL);

            Assert.Equal(1, roll1.Id);
            Assert.Equal("Roll2", roll1.RollNo);
            Assert.Equal("Order2", roll1.OrderNo);
            Assert.Equal("StyleCode2", roll1.StyleCode);
            Assert.Equal("StyleName2", roll1.StyleName);
            Assert.Equal("ColorCode2", roll1.ColorCode);
            Assert.Equal("ColorName2", roll1.ColorName);
            Assert.Equal("BackingCode2", roll1.BackingCode);
            Assert.Equal(2, roll1.RollLength);
            Assert.Equal(2.2, roll1.RollWidth);
            Assert.Equal("DefaultRecipe2", roll1.DefaultRecipe);
            Assert.Equal(2.002, roll1.PatternRepeatLength);
            Assert.Equal("ProductImageURL2", roll1.ProductImageURL);
        }
Beispiel #14
0
 public void DeleteGreigeRoll(GreigeRoll roll)
 {
     throw new NotImplementedException();
 }