Esempio n. 1
0
        public static byte[] BuildReadScreenResponse(ScreenContent ScreenContent)
        {
            var ra = new ByteArrayBuilder();

            // data stream header.
            {
                var buf = DataStreamHeader.Build(50, TerminalOpcode.ReadScreen, 0, 0);
                ra.Append(buf);
            }

            // screen regeneration buffer. each byte on the screen.
            {
                var buf = ScreenContent.GetRegenerationBuffer();
                ra.Append(buf);
            }

            // update length of response data stream.
            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                ra.CopyToBuffer(wk.ToByteArray(), 0);
            }

            // IAC EOR
            {
                ra.Append(EOR_Command.Build());
            }

            return(ra.ToByteArray());
        }
        /// <summary>
        /// build the entire 5250 query response stream. Starting from data stream header
        /// and concluding with IAC EOR.
        /// </summary>
        /// <returns></returns>
        public static byte[] BuildQuery5250Response()
        {
            var ra = new ByteArrayBuilder();

            // data stream header.
            {
                var buf = DataStreamHeader.Build(50, DataStreamOpcode.Noop, 0, 0);
                ra.Append(buf);
            }

            // response header.  send the special AID code - 0x88.
            {
                var buf = ResponseHeader.Build(0, 0, AidKey.Query5250Reply);
                ra.Append(buf);
            }

            // build the 5250 query response.
            {
                byte byteZero = 0x00;
                ra.AppendBigEndianShort(58);                            // LL. total length of structured field.
                ra.Append(new byte[] { 0xd9, 0x70, 0x80 });             // 5250 query response
                ra.Append(new byte[] { 0x06, 0x00 });                   // control unit code.
                ra.Append(new byte[] { 0x01, 0x03, 0x00 });             // code release level.
                ra.Append(byteZero.Repeat(16));                         // 16 bytes of null
                ra.Append(0x01);                                        // 01 - display station
                ra.Append("3180002".ToEbcdicBytes());                   // machine type and model.
                ra.Append(0x02);                                        // keyboard id
                ra.Append(0x00);                                        // extended keyboard id
                ra.Append(0x00);                                        // reserve
                ra.Append(new byte[] { 0x00, 0x61, 0x50, 0x00 });       // device serial number.
                ra.AppendBigEndianShort(256);                           // max number input fields.
                ra.Append(0x00);                                        // control unit customization
                ra.Append(new byte[] { 0x00, 0x00 });                   // reserved
                ra.Append(new byte[] { 0x18, 0x11, 0x00, 0x00, 0x00 }); //
                ra.Append(byteZero.Repeat(7));                          // 7 bytes of null.
            }

            // update length of response data stream.
            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                ra.CopyToBuffer(wk.ToByteArray(), 0);
            }

            // IAC EOR
            {
                ra.Append(EOR_Command.Build());
            }

            return(ra.ToByteArray());
        }
        public static byte[] BuildSaveScreenResponse(ScreenContent ScreenContent)
        {
            var ra = new ByteArrayBuilder();

            // data stream header.
            {
                var buf = DataStreamHeader.Build(50, TerminalOpcode.SaveScreen, 0, 0);
                ra.Append(buf);
            }

            // restore screen workstation command.
            {
                var cmd = new RestoreScreenCommand();
                ra.Append(cmd.ToBytes());
            }

            // clear unit command.
            if (ScreenContent.ScreenDim.GetIsWideScreen( ) == true)
            {
                var cmd = new ClearUnitAlternateCommand(0x00);
                ra.Append(cmd.ToBytes());
            }
            else
            {
                var cmd = new ClearUnitCommand();
                ra.Append(cmd.ToBytes());
            }

            // WTD command.
            {
                var ordersByteStream = ScreenContent.BuildOrderStream( );
                var buf = WriteToDisplayCommand.Build(0x00, 0x18, ordersByteStream);
                ra.Append(buf);
            }

            // update length of response data stream.
            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                ra.CopyToBuffer(wk.ToByteArray(), 0);
            }

            // IAC EOR
            {
                ra.Append(EOR_Command.Build());
            }

            return(ra.ToByteArray());
        }
        /// <summary>
        /// no longer used. called WorkstationCommandListExt.ProcessAndPaint, which
        /// itself is not used.
        /// </summary>
        /// <param name="VisualItems"></param>
        /// <param name="Caret"></param>
        /// <returns></returns>
        public static byte[] BuildSaveScreenResponse(
            ScreenVisualItems VisualItems, CanvasPositionCursor Caret)
        {
            var ra = new ByteArrayBuilder();

            // data stream header.
            {
                var buf = DataStreamHeader.Build(50, TerminalOpcode.SaveScreen, 0, 0);
                ra.Append(buf);
            }

            // restore screen workstation command.
            {
                var cmd = new RestoreScreenCommand();
                ra.Append(cmd.ToBytes());
            }

            // clear unit command.
            {
                var cmd = new ClearUnitCommand();
                ra.Append(cmd.ToBytes());
            }

            // WTD command.
            {
                var ordersByteStream = VisualItems.BuildOrderStream(Caret);
                var buf = WriteToDisplayCommand.Build(0x00, 0x18, ordersByteStream);
                ra.Append(buf);
            }

            // update length of response data stream.
            {
                var wk = new ByteArrayBuilder();
                wk.AppendBigEndianShort((short)ra.Length);
                ra.CopyToBuffer(wk.ToByteArray(), 0);
            }

            // IAC EOR
            {
                ra.Append(EOR_Command.Build());
            }

            return(ra.ToByteArray());
        }