Class Rulbus

Header file

/*
   d_rulbus.hpp

   Header file for rulbus drivers.

   Copyright (C), 1992 by Rijksuniversiteit Leiden.

   Version: 0.07
   Date   : 9 Oct 1992
   Disk   : ruldev\inc\ruldev
   Author : M.J. Moene

   Compiler        : Borland C++ 2.0
   Operating system: MS-DOS 3.21
   Hardware system : PC XT, AT
*/

#ifndef __D_RULBUS_HPP				// already included?
#define __D_RULBUS_HPP

#ifndef __D_DEVICE_HPP				// already included?
#include <ruldev\d_device.hpp>
#endif


#define DEF_NAME	"Rulbus"		// default device name
#define DEF_ADDR	0xFF			// default rulbus address (invalid)
#define DEF_RACK	0			// default rulbus rack address
#define DEF_BASE	0x200			// default rulbus converter address


// Rulbus class definition

class Rulbus : public Device			// Rulbus base class
{
public:                                         // public part
  ~Rulbus ();                                   // destructor
   Rulbus ( const char *n = DEF_NAME,           // constructor
		  int   a = DEF_ADDR,
		  int   r = DEF_RACK,
		  int   b = DEF_BASE );

   virtual int          getRulbusAddress (        );		// rulbus address
   virtual Status       putRulbusAddress (int addr);
   virtual int          getRackAddress   (        );		// rulbus rack number
   virtual Status       putRackAddress   (int rack);
   virtual unsigned int getBaseAddress   (                 );	// rulbus converter
   virtual Status       putBaseAddress   (unsigned int base);	//   address

   static  void 	SelectRack	 (unsigned int base, int rack);

   void       groupDialog () ;			// (ezview) dialog

   classType  isA         () const = 0;   	// type info
   char      *nameOf      () const = 0;		// type info

protected:                                      // protected part
   void  	  selectRack ();
   int   	  getReg     (int offset);
   void  	  putReg     (int offset, int byte);
   int            getByte    (int offset);
   void           putByte    (int offset, int byte);

   Status  _scan  (istream &is = cin ) = 0;	// scan object
   Status  _print (ostream &os = cout) = 0;	// print object

private:                                        // private part
   int  addr;					// rulbus base address
   int  rack;					// rulbus rack number
   int  base;					// rulbus converter address

   static int currentRack;			// rack currently selected
};


#undef DEF_NAME					// default device name
#undef DEF_ADDR					// default rulbus address (invalid)


#endif						// #ifndef __D_RULBUS_HPP


/*** End of file ***/


Programmer's reference

------------------------------------------------------------------------------
Rulbus - Base Class for Rulbus Devices
------------------------------------------------------------------------------

Class		Rulbus

Derived from	Device	(ruldev library)

Remarks		Class Rulbus is the base class for all rulbus modules. 
		It contains the properties common to all Rulbus devices.
			
		Class Rulbus provides functions to:
		- get and set the rulbus address,
		- get and set the rack address,
		- get and set the rulbus-converter base address.


------------------------------------------------------------------------------
constructor								Rulbus
------------------------------------------------------------------------------

Function	construct an instance of class Rulbus.

Syntax		#include <ruldev\d_rulbus.hpp>
		Rulbus::Rulbus(const char *name, int addr, int rack, int base);

Prototype in	d_rulbus.hpp

Remarks		This is the constructor for class Rulbus.

Arguments	name: name of instance		 (default: "Rulbus")
		addr: rulbus address of instance (default: 0xFF)
		rack: rulbus rack number	 (default: 0)
		base: rulbus converter address	 (default: 0x200)

Return value	none


------------------------------------------------------------------------------
destructor								Rulbus
------------------------------------------------------------------------------

Function	destruct an instance of class Rulbus

Syntax		#include <ruldev\d_rulbus.hpp>
		virtual Rulbus::~Rulbus()

Prototype in	d_rulbus.hpp

Remarks		This is the destructor for class Rulbus.

Arguments	none

Return value	none


------------------------------------------------------------------------------
isA									Rulbus
------------------------------------------------------------------------------

Function	return type information.

Syntax		#include <ruldev\d_rulbus.hpp>
		virtual classType Rulbus::isA() const = 0;

Prototype in	d_rulbus.hpp

Remarks		method isA of classes derived from Rulbus should return a
		unique number to identify that class. This can be used for
		type checking. (class identifiers are in file d_clstyp.hpp.)

		isA is defined purely virtual in this class, so no instances
		of this base class can be defined.

Arguments	none

Return value	an unique number, representing a type.


------------------------------------------------------------------------------
nameOf								    Rulbus
------------------------------------------------------------------------------

Function	return the type name of this device instance.

Syntax		#include <ruldev\d_rulbus.hpp>
		virtual char *Rulbus::nameOf() const;

Prototype in	d_rulbus.hpp

Remarks		nameOf returns a string representation of the name
		of this type. For derived types it should be like "RBxxxx".

Arguments	none

Return value	"Rulbus".


------------------------------------------------------------------------------
getRulbusAddress							Rulbus
------------------------------------------------------------------------------

Function	get the rulbus address of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		int Rulbus::getRulbusAddress();

Prototype in	d_rulbus.hpp

Remarks		getRulbusAddress returns the rulbus address of this device.

Arguments	none

Return value	0x00..0xFE


------------------------------------------------------------------------------
putRulbusAddress							Rulbus
------------------------------------------------------------------------------

Function	set the rulbus address of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		Status Rulbus::putRulbusAddress(int address);

Prototype in	d_rulbus.hpp

Remarks		putRulbusAddress returns Ok if the rulbus address is set
		properly, otherwise it returns BadValue.

Arguments	address: 0x00..0xFE	(rulbus address)

Return value	Ok, BadValue


------------------------------------------------------------------------------
getRackAddress								Rulbus
------------------------------------------------------------------------------

Function	get the rulbus rack number of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		int Rulbus::getRackAddress();

Prototype in	d_rulbus.hpp

Remarks		getRackAddress returns the rulbus rack number of this device.

Arguments	none

Return value	0..14


------------------------------------------------------------------------------
putRackAddress								Rulbus
------------------------------------------------------------------------------

Function	set the rulbus rack number of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		Status Rulbus::putRackAddress(int address);

Prototype in	d_rulbus.hpp

Remarks		putRackAddress returns Ok if the rulbus rack number is set
		properly, otherwise it returns BadValue.

Arguments	address: 0..14	(rulbus rack address)

Return value	Ok, BadValue


------------------------------------------------------------------------------
getBaseAddress								Rulbus
------------------------------------------------------------------------------

Function	get the rulbus converter base address of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		unsigned int Rulbus::getBaseAddress();

Prototype in	d_rulbus.hpp

Remarks		getBaseAddress returns the rulbus converter base address of
		this device.

Arguments	none

Return value	0x0000..0xFF00 step 0x100.


------------------------------------------------------------------------------
putBaseAddress								Rulbus
------------------------------------------------------------------------------

Function	set the rulbus converter base address of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		Status Rulbus::putBaseAddress(unsigned int address);

Prototype in	d_rulbus.hpp

Remarks		putBaseAddress returns Ok if the rulbus converter base address
		is set properly, otherwise it returns BadValue.

Arguments	address: 0x000..0xFF00 step 0x100

Return value	Ok, BadValue


------------------------------------------------------------------------------
SelectRack								Rulbus
------------------------------------------------------------------------------

Function	select the specified rulbus rack.

Syntax		#include <ruldev\d_rulbus.hpp>
		static void Rulbus::SelectRack(unsigned int base, int rack);

Prototype in	d_rulbus.hpp

Remarks		selectRack selects the specified rulbus rack, using the
		Rulbus converter base address base.

Arguments	base: Rulbus converter base address,
		rack: rack to select.

Return value	none


------------------------------------------------------------------------------
(_scan)									Rulbus
------------------------------------------------------------------------------

Function	initialize the device from a stream.

Syntax		#include "d_rulbus.h"
		virtual Status Rulbus::_scan(istream &is = cin);

Prototype in	d_rulbus.h

Remarks		_scan reads the device representation as created by _print
		and initializes the device with these settings. _scan returns
		Ok when it properly read the object, otherwise it returns
		BadInput if a stream input error occurred.
		See also Device::scan and Device::print.

Arguments	is: reference to the input stream	(default: cin)

Return value	Ok, BadInput.


------------------------------------------------------------------------------
(_print)								Rulbus
------------------------------------------------------------------------------

Function	write an initialization record for this object to a stream.

Syntax		#include "d_rulbus.h"
		virtual Status Rulbus::_print(ostream &os = cout);

Prototype in	d_rulbus.h

Remarks		_print writes a device represention to a stream from which
		_scan can initialize the device. _print returns Ok when it
		properly wrote the object, otherwise it returns BadOutput
		if a stream write error occurred. See also Device::print.

Arguments	os: reference to the output stream	(default: cout)

Return value	Ok, BadOutput.


------------------------------------------------------------------------------
(selectRack)								Rulbus
------------------------------------------------------------------------------

Function	select the rulbus rack of this device.

Syntax		#include <ruldev\d_rulbus.hpp>
		void Rulbus::selectRack();

Prototype in	d_rulbus.hpp

Remarks		selectRack selects the rulbus rack of this device.

Arguments	none

Return value	none


------------------------------------------------------------------------------
(getReg)								Rulbus
------------------------------------------------------------------------------

Function	get the contents of the specified register.

Syntax		#include <ruldev\d_rulbus.hpp>
		int Rulbus::getReg(int offset);

Prototype in	d_rulbus.hpp

Remarks		getReg returns the contents of the specified register on the
		rulbus. It does NOT select the proper rack first!

Arguments	offset: register address offset with respect to the rulbus address
			of this device (0x00..0xFE).

Return value	0..255


------------------------------------------------------------------------------
(putReg)								Rulbus
------------------------------------------------------------------------------

Function	set the contents of a rulbus register to the specified value.

Syntax		#include <ruldev\d_rulbus.hpp>
		Status Rulbus::putReg(int offset, int byte);

Prototype in	d_rulbus.hpp

Remarks		putReg returns Ok if the register is written to properly,
		otherwise it returns BadValue. putReg does NOT select the
		proper rack first!

Arguments	offset: register address offset with respect to the rulbus
			address of this device (0x00..0xFE),
		byte  : value to write to register (0..255).

Return value	Ok, BadValue


------------------------------------------------------------------------------
(getByte)								Rulbus
------------------------------------------------------------------------------

Function	get the contents of the specified register.

Syntax		#include <ruldev\d_rulbus.hpp>
		int Rulbus::getByte(int offset);

Prototype in	d_rulbus.hpp

Remarks		getByte first selects the proper rulbus rack, then it returns
		the contents of the specified register on the rulbus.

Arguments	offset: register address offset with respect to the rulbus
			address of this device.

Return value	0..255


------------------------------------------------------------------------------
(putByte)								Rulbus
------------------------------------------------------------------------------

Function	set the contents of a rulbus register to the specified value.

Syntax		#include <ruldev\d_rulbus.hpp>
		Status Rulbus::putByte(int offset, int byte);

Prototype in	d_rulbus.hpp

Remarks		putByte first selects the proper rulbus rack, then it sets
		the contents of the register to the specified value. putByte
		returns Ok if the register is written to properly, otherwise
		it returns BadValue.

Arguments	offset: register address offset with respect to the rulbus
			address of this device (0x00..0xFE),
		byte  : value to write to register (0..255).

Return value	Ok, BadValue


Martin J. Moene   (e-mail)  /  Revised: .