public static IBM5250DataStreamCommand Factory(InputByteArray InputArray)
        {
            IBM5250DataStreamCommand dsCmd = null;

            if (InputArray.RemainingLength >= 2)
            {
                var buf = InputArray.PeekBytes(2);
                if (buf[0] == 0x04)
                {
                    var cmdCode = buf[1].ToCommandCode();
                    if (cmdCode != null)
                    {
                        if (cmdCode.Value == CommandCode.ClearUnit)
                        {
                            dsCmd = new ClearUnitCommand();
                        }

                        else if (cmdCode.Value == CommandCode.WTD)
                        {
                            dsCmd = WriteToDisplayCommand.Factory(InputArray);
                        }

                        if (dsCmd != null)
                        {
                            InputArray.AdvanceIndex(dsCmd.GetDataStreamLength());
                        }
                    }
                }
            }

            return(dsCmd);
        }
Beispiel #2
0
        public static WriteToDisplayCommand Factory(InputByteArray InputArray)
        {
            WriteToDisplayCommand wtdCmd = null;

            if (InputArray.RemainingLength >= 4)
            {
                var buf = InputArray.PeekBytes(4);
                if ((buf[0] == 0x04) && (buf[1] == 0x11))
                {
                    byte[] controlChars = new byte[2];
                    Array.Copy(buf, 3, controlChars, 0, 2);

                    wtdCmd = new WriteToDisplayCommand(InputArray, controlChars);
                    InputArray.AdvanceIndex(4);

                    // gather WTD orders and display characters.
                    while (true)
                    {
                        if (InputArray.RemainingLength == 0)
                        {
                            break;
                        }

                        var b1       = InputArray.PeekByte(0);
                        var wtdOrder = b1.ToWtdOrder();
                        if (wtdOrder != null)
                        {
                        }

                        else if (TextDataOrder.IsTextDataChar(b1))
                        {
                            var tdOrder = TextDataOrder.Factory(InputArray);
                            wtdCmd.OrderList.Add(tdOrder);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return(wtdCmd);
        }