예제 #1
0
        public void SendSubstitution(Substitution s)
        {
            string delimiter = s.Delimiter;

            for (int i = 0; i < s.SubRule.Length; i++)
            {
                SubstitutionRule r = s.SubRule[i];
                if (Enum.TryParse(r.Type, true, out ccSR type))
                {
                    if (XMLwriter != null)
                    {
                        XMLwriter.WriteStartElement(r.Type);
                    }
                    SetSubValues(type, r, delimiter);
                    if (XMLwriter != null)
                    {
                        XMLwriter.WriteEndElement();
                    }
                }
                else
                {
                    Log?.Invoke(p, $"Unknown substitution rule type =>{r.Type}<=");
                }
            }
        }
예제 #2
0
        // Send the message portion of the Lab
        private void SendMessage(Msg m)
        {
            // Set to only one item in printer (Deletes are done in individual mode)
            XMLwriter.WriteStartElement("DeleteOld");
            p.DeleteAllButOne();

            XMLwriter.WriteEndElement();

            if (m.Column != null)
            {
                Log?.Invoke(this, " \n// Loading new message\n ");
                XMLwriter.WriteStartElement("BuildNew");
                AllocateRowsColumns(m);
                XMLwriter.WriteEndElement();
            }
        }
예제 #3
0
        // Send the Calendar and Counter settings
        private void SendDateCount(Msg m)
        {
            // Get calendar and count blocks assigned by the printer
            Log?.Invoke(p, $" \n// Get number of Calendar and Count blocks used\n ");
            XMLwriter.WriteStartElement("CalCountUsage");
            for (int c = 0; c < m.Column.Length; c++)
            {
                for (int r = 0; r < m.Column[c].Item.Length; r++)
                {
                    Item item  = m.Column[c].Item[r];
                    int  index = m.Column[c].Item[r].Location.Index - 1;
                    if (item.Date != null)
                    {
                        item.Location.calCount = p.GetDecAttribute(ccPF.Number_of_Calendar_Blocks, index);
                        item.Location.calStart = p.GetDecAttribute(ccPF.First_Calendar_Block, index);
                    }
                    if (item.Counter != null)
                    {
                        item.Location.countCount = p.GetDecAttribute(ccPF.Number_Of_Count_Blocks, index);
                        item.Location.countStart = p.GetDecAttribute(ccPF.First_Count_Block, index);
                    }
                }
            }
            XMLwriter.WriteEndElement();

            for (int c = 0; c < m.Column.Length; c++)
            {
                for (int r = 0; r < m.Column[c].Item.Length; r++)
                {
                    Item item = m.Column[c].Item[r];
                    if (item.Date != null)
                    {
                        XMLwriter.WriteStartElement("Calendar");
                        XMLwriter.WriteAttributeString("Block", item.Location.calStart.ToString());
                        SendCalendar(item);
                        XMLwriter.WriteEndElement();
                    }
                    if (item.Counter != null)
                    {
                        XMLwriter.WriteStartElement("Count");
                        XMLwriter.WriteAttributeString("Block", item.Location.countStart.ToString());
                        SendCount(item);
                        XMLwriter.WriteEndElement();
                    }
                }
            }
        }
예제 #4
0
        // Set the Barcode after conditions have been loaded
        private void SetBarcode(Msg m)
        {
            // Change message to free layout
            Log?.Invoke(p, $" \n// Load needed Barcode Formats\n ");
            XMLwriter.WriteStartElement("SetBarcode");
            int index = 0;

            p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
            for (int c = 0; c < m.Column.Length; c++)
            {
                for (int r = 0; r < m.Column[c].Item.Length; r++)
                {
                    Item item = m.Column[c].Item[r];
                    if (item.BarCode != null)
                    {
                        p.SetAttribute(ccPF.Barcode_Type, index, item.BarCode.DotMatrix);
                    }
                    index++;
                }
            }
            p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
            XMLwriter.WriteEndElement();
        }
예제 #5
0
        // Send count settings
        private void SendCount(Item item)
        {
            int countStart = item.Location.countStart;
            int countCount = item.Location.countCount;

            for (int i = 0; i < item.Counter.Length; i++)
            {
                Counter c = item.Counter[i];
                if (c.Block <= countCount)
                {
                    int index = countStart + c.Block - 2; // Both count start and count block are 1-origin

                    Log?.Invoke(p, $" \n// Set up count {index + 1}\n ");
                    XMLwriter.WriteStartElement("Count");
                    XMLwriter.WriteAttributeString("Block", (countStart + i).ToString());
                    // Process Range
                    Range r = c.Range;
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    if (r != null)
                    {
                        if (r.Range1 != null)
                        {
                            p.SetAttribute(ccCount.Count_Range_1, index, r.Range1);
                        }
                        if (r.Range2 != null)
                        {
                            p.SetAttribute(ccCount.Count_Range_2, index, r.Range2);
                        }
                        if (r.JumpFrom != null)
                        {
                            p.SetAttribute(ccCount.Jump_From, index, r.JumpFrom);
                        }
                        if (r.JumpTo != null)
                        {
                            p.SetAttribute(ccCount.Jump_To, index, r.JumpTo);
                        }
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                    // Process Count
                    Count cc = c.Count;
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    if (cc != null)
                    {
                        if (cc.InitialValue != null)
                        {
                            p.SetAttribute(ccCount.Initial_Value, index, cc.InitialValue);
                        }
                        if (cc.Increment != null)
                        {
                            p.SetAttribute(ccCount.Increment_Value, index, cc.Increment);
                        }
                        if (cc.Direction != null)
                        {
                            p.SetAttribute(ccCount.Direction_Value, index, cc.Direction);
                        }
                        if (cc.ZeroSuppression != null)
                        {
                            p.SetAttribute(ccCount.Zero_Suppression, index, cc.ZeroSuppression);
                        }
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                    // Process Reset
                    Reset rr = c.Reset;
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    if (rr != null)
                    {
                        if (rr.Type != null)
                        {
                            p.SetAttribute(ccCount.Type_Of_Reset_Signal, index, rr.Type);
                        }
                        if (rr.Value != null)
                        {
                            p.SetAttribute(ccCount.Reset_Value, index, rr.Value);
                        }
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                    // Process Misc
                    Misc m = c.Misc;
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    if (m != null)
                    {
                        if (m.UpdateUnit != null)
                        {
                            p.SetAttribute(ccCount.Update_Unit_Unit, index, m.UpdateUnit);
                        }
                        if (m.UpdateIP != null)
                        {
                            p.SetAttribute(ccCount.Update_Unit_Halfway, index, m.UpdateIP);
                        }
                        if (m.ExternalCount != null)
                        {
                            p.SetAttribute(ccCount.External_Count, index, m.ExternalCount);
                        }
                        if (m.Multiplier != null)
                        {
                            p.SetAttribute(ccCount.Count_Multiplier, index, m.Multiplier);
                        }
                        if (m.SkipCount != null)
                        {
                            p.SetAttribute(ccCount.Count_Skip, index, m.SkipCount);
                        }
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                    XMLwriter.WriteEndElement();
                }
            }
        }
예제 #6
0
        // Send Calendar settings
        private void SendCalendar(Item item)
        {
            int calStart = item.Location.calStart;
            int calCount = item.Location.calCount;

            for (int i = 0; i < item.Date.Length; i++)
            {
                Date date = item.Date[i];
                if (date.Block <= calCount && int.TryParse(date.SubstitutionRule, out int ruleNumber) && ruleNumber > 0)
                {
                    if (date.Offset != null || date.ZeroSuppress != null || date.Substitute != null || date.TimeCount != null || date.Shifts != null)
                    {
                        Log?.Invoke(p, $" \n// Load settings for Substitution rule {1}\n ");
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                        p.SetAttribute(ccIDX.Substitution_Rule, ruleNumber); // date.SubstitutionRule
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                        int index = calStart + date.Block - 2; // Cal start and date.Block are both 1-origin
                        Log?.Invoke(p, $" \n// Set up calendar {index + 1}\n ");
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                        // Process Offset
                        Offset o = date.Offset;
                        if (o != null)
                        {
                            XMLwriter.WriteStartElement("Offset");
                            if (o.Year != 0)
                            {
                                p.SetAttribute(ccCal.Offset_Year, index, o.Year);
                            }
                            if (o.Month != 0)
                            {
                                p.SetAttribute(ccCal.Offset_Month, index, o.Month);
                            }
                            if (o.Day != 0)
                            {
                                p.SetAttribute(ccCal.Offset_Day, index, o.Day);
                            }
                            if (o.Hour != 0)
                            {
                                p.SetAttribute(ccCal.Offset_Hour, index, o.Hour);
                            }
                            if (o.Minute != 0)
                            {
                                p.SetAttribute(ccCal.Offset_Minute, index, o.Minute);
                            }
                            XMLwriter.WriteEndElement();
                        }

                        // Process Zero Suppress
                        ZeroSuppress zs = date.ZeroSuppress;
                        if (zs != null)
                        {
                            XMLwriter.WriteStartElement("ZeroSuppress");
                            if (zs.Year != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Year, index, zs.Year);
                            }
                            if (zs.Month != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Month, index, zs.Month);
                            }
                            if (zs.Day != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Day, index, zs.Day);
                            }
                            if (zs.Hour != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Hour, index, zs.Hour);
                            }
                            if (zs.Minute != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Minute, index, zs.Minute);
                            }
                            if (zs.Week != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_Weeks, index, zs.Week);
                            }
                            if (zs.DayOfWeek != ZS.None)
                            {
                                p.SetAttribute(ccCal.Zero_Suppress_DayOfWeek, index, zs.DayOfWeek);
                            }
                            XMLwriter.WriteEndElement();
                        }

                        // Process Substitutions
                        Substitute s = date.Substitute;
                        if (s != null)
                        {
                            XMLwriter.WriteStartElement("Substitutions");
                            if (s.Year != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Year, index, s.Year);
                            }
                            if (s.Month != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Month, index, s.Month);
                            }
                            if (s.Day != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Day, index, s.Day);
                            }
                            if (s.Hour != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Hour, index, s.Hour);
                            }
                            if (s.Minute != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Minute, index, s.Minute);
                            }
                            if (s.Week != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_Weeks, index, s.Week);
                            }
                            if (s.DayOfWeek != ED.Disable)
                            {
                                p.SetAttribute(ccCal.Substitute_DayOfWeek, index, s.DayOfWeek);
                            }
                            XMLwriter.WriteEndElement();
                        }

                        // Process shifts
                        if (date.Shifts != null)
                        {
                            Log?.Invoke(p, $" \n// Set up shifts\n ");
                            XMLwriter.WriteStartElement("Shifts");
                            for (int j = 0; j < date.Shifts.Length; j++)
                            {
                                XMLwriter.WriteStartElement("Shift");
                                XMLwriter.WriteAttributeString("Shift", (j + 1).ToString());
                                p.SetAttribute(ccSR.Shift_Start_Hour, j, date.Shifts[j].StartHour);
                                p.SetAttribute(ccSR.Shift_Start_Minute, j, date.Shifts[j].StartMinute);
                                p.SetAttribute(ccSR.Shift_End_Hour, j, date.Shifts[j].EndHour);
                                p.SetAttribute(ccSR.Shift_End_Minute, j, date.Shifts[j].EndMinute);
                                p.SetAttribute(ccSR.Shift_String_Value, j, date.Shifts[j].ShiftCode);
                                XMLwriter.WriteEndElement();
                            }
                            XMLwriter.WriteEndElement();
                        }

                        // Process TimeCount
                        TimeCount tc = date.TimeCount;
                        if (tc != null)
                        {
                            Log?.Invoke(p, $" \n// Set up Time Count\n ");
                            XMLwriter.WriteStartElement("TimeCount");
                            p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                            p.SetAttribute(ccSR.Update_Interval_Value, tc.Interval);
                            p.SetAttribute(ccSR.Time_Count_Start_Value, tc.Start);
                            p.SetAttribute(ccSR.Time_Count_End_Value, tc.End);
                            p.SetAttribute(ccSR.Reset_Time_Value, tc.ResetTime);
                            p.SetAttribute(ccSR.Time_Count_Reset_Value, tc.ResetValue);
                            p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                            XMLwriter.WriteEndElement();
                        }
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                    }
                }
            }
        }
예제 #7
0
        // Use the column/item structure of a Lab to allocate items in the printer
        private void AllocateRowsColumns(Msg m)
        {
            bool barCodesExist  = false;
            int  index          = 0;
            bool hasDateOrCount = false; // Save some time if no need to look
            int  charPosition   = 0;

            for (int c = 0; c < m.Column.Length; c++)
            {
                XMLwriter.WriteStartElement("AllocateColumn");
                XMLwriter.WriteAttributeString("Column", (c + 1).ToString());
                if (c > 0)
                {
                    Log?.Invoke(p, $" \n// Add column {c + 1}\n ");
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    p.SetAttribute(ccPF.Add_Column, c + 1);
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                }

                Log?.Invoke(p, $" \n// Set column {c + 1} to {m.Column[c].Item.Length} items\n ");
                p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                p.SetAttribute(ccPF.Column, c + 1);
                p.SetAttribute(ccPF.Line, m.Column[c].Item.Length);
                p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                if (m.Column[c].Item.Length > 1)
                {
                    Log?.Invoke(p, $" \n// Set ILS for items {index + 1} to {index + m.Column[c].Item.Length}\n ");
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    for (int j = 0; j < m.Column[c].Item.Length; j++)
                    {
                        p.SetAttribute(ccPF.Line_Spacing, index + j, m.Column[c].InterLineSpacing);
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                }

                for (int r = 0; r < m.Column[c].Item.Length; r++)
                {
                    Log?.Invoke(p, $" \n// Fill in item {index + 1}\n ");
                    XMLwriter.WriteStartElement("AllocateItem");
                    XMLwriter.WriteAttributeString("Row", (r + 1).ToString());
                    Item item = m.Column[c].Item[r];
                    if (item.Font != null)
                    {
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                        p.SetAttribute(ccPF.Dot_Matrix, index, item.Font.DotMatrix);
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                        p.SetAttribute(ccPF.InterCharacter_Space, index, item.Font.InterCharacterSpace);
                        p.SetAttribute(ccPF.Character_Bold, index, item.Font.IncreasedWidth);
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);

                        if (item.BarCode != null)
                        {
                            barCodesExist = true;
                        }
                    }

                    string s = p.HandleBraces(item.Text);
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                    p.SetAttribute(ccPC.Characters_per_Item, index, s.Length);
                    while (s.Length > 0)
                    {
                        int len = Math.Min(s.Length, 32);
                        p.SetAttribute(ccPC.Print_Character_String, charPosition, s.Substring(0, len));
                        s             = s.Substring(len);
                        charPosition += len;
                    }
                    p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                    hasDateOrCount |= item.Date != null | item.Counter != null;
                    index++;
                    XMLwriter.WriteEndElement();
                }
                XMLwriter.WriteEndElement();
            }
            //
            // Is this message free layout?
            if (m.Layout == "FreeLayout")
            {
                XMLwriter.WriteStartElement("PositionItems");
                // Change message to free layout
                Log?.Invoke(p, $" \n// Change message to free layout\n ");
                XMLwriter.WriteStartElement("SetLayout");
                p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                p.SetAttribute(ccPF.Format_Setup, m.Layout);
                p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                XMLwriter.WriteEndElement();
                index        = 0;
                charPosition = 0;
                for (int c = 0; c < m.Column.Length; c++)
                {
                    for (int r = 0; r < m.Column[c].Item.Length; r++)
                    {
                        Log?.Invoke(p, $" \n// Position item {index + 1}\n ");
                        XMLwriter.WriteStartElement("Item");
                        XMLwriter.WriteAttributeString("Index", (index + 1).ToString());
                        Item   item = m.Column[c].Item[r];
                        string s    = p.HandleBraces(item.Text);
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 1);
                        if (item.Location != null)
                        {
                            p.SetAttribute(ccPF.X_Coordinate, index, item.Location.X);
                            p.SetAttribute(ccPF.Y_Coordinate, index, item.Location.Y);
                        }
                        p.SetAttribute(ccPC.Characters_per_Item, index, s.Length);
                        while (s.Length > 0)
                        {
                            int len = Math.Min(s.Length, 32);
                            p.SetAttribute(ccPC.Print_Character_String, charPosition, s.Substring(0, len));
                            s             = s.Substring(len);
                            charPosition += len;
                        }
                        p.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
                        charPosition += s.Length;
                        index++;
                        XMLwriter.WriteEndElement();
                    }
                }
                XMLwriter.WriteEndElement();
            }
            // Process calendar and count if needed
            if (hasDateOrCount)
            {
                SendDateCount(m);
            }
            // At this point, barcode settings can be set
            if (barCodesExist)
            {
                SetBarcode(m);
            }
        }