Skip to content. | Skip to navigation

Personal tools

lcu/dgh.h

lcu/dgh.h

lcu/dgh.h

/////////////////////////////////////////////////////////////////////////////
// DGH.H
//
//  Last updated: 1/29/2005
//
//  Part of the source code for the Remote M3 Turret
//
// This file contains all DGH communication constants/routines
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// DGH communication constants
//#define DGHPrePause 10
#define DGHTimeout 1000 // Timeout duration for DGH commands in msecs
#define DGHInitString "xx0104C2"

/////////////////////////////////////////////////////////////////////////////
// CDGH Class Definition
//
//  The CDGH class encapsulates the DGH modules.  The class can initialize
//  the DGH modules, send and receive commands, and read the current
//  DGH readings.

class CDGH
{
  public:
  float Reading;  // Current reading of the DGH
  int Step;       // Current DGH read step (query, wait for response)
  char Response[80];  // DGH's response
  unsigned long Time; // Time when the query was sent
  int ResponseLength; // Length of DGH's response to query
  int ErrorCount;
  int CheckSetup; // Flags DGH module to check setup on boot

  void Init(char address);
  // Initializes class and checks DGH init string.
  void Send(char *Data);
  // Sends the string Data to the DGH
  int Receive(char *Response,int Timeout);
  // Puts a DGH response into string Response.
  // Waits up to Timeout milliseconds for the response to be completed.
  // Returns a 0 on success, 1 on failure.
  int Command(char *Data,char *Response,int Timeout);
  // Sends the command in Data, and waits for a Response for Timeout ms.
  int Update();
  // Reads the DGHs current reading and updates the onscreen display

  private:
  char Address; // The one letter address (example, 'a')
  char InitString[10]; // The DGHs initialization string
} DGHs[3];

/////////////////////////////////////////////////////////////////////////////
// DGHFormat - returns a float in a string properly formatted for the DGHs
char * DGHFormat(float f,char *s);
// Pass the float to be formatted in f, and the string will be returned in s
// Returns f in the format "+00000.00"

Generated by GNU Enscript 1.6.5.2.
Document Actions