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()); }
public static WorkstationCommandBase ParseFactory(InputByteArray InputArray) { WorkstationCommandBase wrkstnCmd = null; if (InputArray.RemainingLength >= 2) { // command codes as documented on 15.2 - 1 of 5494 function ref manual var buf = InputArray.PeekBytes(2); if (buf[0] == 0x04) { var funcCode = buf[1].ToWorkstationCode(); if (funcCode != null) { var code = funcCode.Value; if (code == WorkstationCode.ClearUnit) { wrkstnCmd = new ClearUnitCommand(InputArray); } else if (code == WorkstationCode.WTD) { wrkstnCmd = new WriteToDisplayCommand(InputArray); } else if (code == WorkstationCode.ReadMdtFields) { wrkstnCmd = new ReadMdtFieldsCommand(InputArray); } else if (code == WorkstationCode.ReadInputFields) { throw new Exception("read input fields workstation command not supported"); } // 04 F3. write structure field. Used as vehicle for the D9 70 5250 query // command. else if (code == WorkstationCode.WriteStructuredField) { wrkstnCmd = new WriteStructuredFieldCommand(InputArray); } else if (code == WorkstationCode.SaveScreen) { wrkstnCmd = new SaveScreenCommand(InputArray); } else if (code == WorkstationCode.RestoreScreen) { wrkstnCmd = new RestoreScreenCommand(InputArray); } else if (code == WorkstationCode.WriteErrorCode) { wrkstnCmd = new WriteErrorCodeCommand(InputArray); } else if (code == WorkstationCode.ReadScreen) { wrkstnCmd = new ReadScreenCommand(InputArray); } // 04 F4 - write single structured field. Use to set keyboard // buffering. else if (code == WorkstationCode.WriteSingleStructuredField) { wrkstnCmd = new WriteSingleStructuredFieldCommand(InputArray); } else if (code == WorkstationCode.ClearUnitAlternate) { wrkstnCmd = new ClearUnitAlternateCommand(InputArray); } else { throw new Exception( "workstation data stream command code not supported. " + code.ToString()); } } } } return(wrkstnCmd); }