package Ada_Store.PoST.Device.Printer

with Ada_Store.PoST.Input_Queue;

package Ada_Store.PoST.Device.Printer is
	
   type Instance 	is new Ada_Store.PoST.Device.Instance with private;

   type Printer_Status 	is ( Ok, Paper_Low, Paper_Out, Ink_Out );

   type Print_Station   is ( Receipt, Journal, Slip );

   function  Current_Status
     (Device : in Instance)
      return Printer_Status;
   
   function  Has_Station
     (Printer : in Instance;
      Station : in Print_Station)
       return Boolean;

   procedure Open
     (Printer : in out Instance);

   function  Lines
     (Printer : in Instance;
      Station : in Print_Station)
       return Integer;

   function  Columns
     (Printer : in Instance;
      Station : in Print_Station)
      return Positive;

   procedure Write
     (Printer : in out Instance;
      Station : in     Print_Station;
      Text    : in     String);

   procedure Cut_Paper
     (Printer : in out Instance;
      Station : in     Print_Station); 

   procedure Flush
     (Printer	 : in out Instance;
      Flush_Mode : in     Device_Mode);

   procedure Accept_Input
     (Printer : in out Instance;
      Input   : in     Input_Queue.Message_Ptr);
	
private
   type Instance 	is new Ada_Store.PoST.Device.Instance with 
      record
         Line           : Integer := 0;
      end record;

end Ada_Store.PoST.Device.Printer;

with Ada_Store.Support.Screen; package body Ada_Store.PoST.Device.Printer is package Screen renames Ada_Store.Support.Screen; function Current_Status (Device : in Instance) return Printer_Status is begin return Ok; end Current_Status; function Has_Station (Printer : in Instance; Station : in Print_Station) return Boolean is begin return True; end Has_Station; procedure Open (Printer : in out Instance) is begin Screen.Lock_Exclusive; Screen.Box(((3, 24), (21, 66))); Screen.Unlock; end Open; function Lines (Printer : in Instance; Station : in Print_Station) return Integer is begin return 0; end Lines; function Columns (Printer : in Instance; Station : in Print_Station) return Positive is begin return 40; end Columns; procedure Write (Printer : in out Instance; Station : in Print_Station; Text : in String) is Line : Integer := 4 + Printer.Line; Column : Screen.Width := 25; begin if Printer.Line <14 then Screen.Lock_Exclusive; Screen.Set_Cursor((Screen.Height(Line), Column)); Screen.Put(Text); Screen.Unlock; Printer.Line := Printer.Line + 1; else Screen.Lock_Exclusive; Screen.Scroll(Screen.Up, 1, ((4, 25), (20, 65))); Screen.Set_Cursor((Screen.Height(Line), Column)); Screen.Put(Text); Screen.Unlock; end if; end Write; procedure Cut_Paper (Printer : in out Instance; Station : in Print_Station) is begin for Line in 1 .. 14 loop Write(Printer, Station, ""); end loop; Printer.Line := 0; end Cut_Paper; procedure Flush (Printer : in out Instance; Flush_Mode : in Device_Mode) is begin null; end Flush; procedure Accept_Input (Printer : in out Instance; Input : in Input_Queue.Message_Ptr) is begin Input.all := (Action => Input_Queue.Unknown, Input => (others => Character'Val(0)), Length => 0); Input_Queue.Append(Input); end Accept_Input; end Ada_Store.PoST.Device.Printer;

Contents Page

Copyright © 1996 Simon Johnston &
Addison Wesley Longman