Skip to content. | Skip to navigation

Personal tools




// DGH.H
//  Last updated: 6/24/2000
//  Part of the source code for the Vane End Actuator Control System
// This file contains all DGH communication constants/routines

// DGH communication constants

#define DGHTimeout 2000 /* Timeout duration for DGH commands */
#define DGHPrePause 10 /* Pause after a transmit for RS-485 to switch modes */
#define DGHInitString "xx01A1C2"
#define DGHInitStringF11 "xx0101C2"
#define DGHInitStringF5 "xx0101C2"

#define AXIAL 0 /* Used for DGHType */
#define RADIAL 1
#define F11	2
#define F5	3

#define Guest 1 /* All DGHs are downstream on COM2:, which is port 1 */
#define MaxDGHErrors 4
#define FatalDGHErrors 1

// 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 tensions.

class CDGH
	float Reading; 				// Current reading of the DGH
	float Tension; 				// Current tension reading of the DGH in pounds
	int TensionOK;				// Status of the tensions.. 0=OK,1=Near limit,2 = Error
	float MaxTension; 		// Maximum allowable tension in pounds
	float MinTension; 		// Minimum allowable tension in pounds
	float Cal0,Cal1,Cal2; // 0,1st,2nd order calibration constants for mV->Pounds
	int x0,y0; 						// Upper left corner for tension display location
	int QueryFlag;				// Current DGH read step (query, wait for response)
	char Response[80];		// DGH's response
	int QueryTime;				// Time when the query was sent
	int ResponseLength; 	// Length of DGH's response to query
	int ErrorCount;
	int Alarm;						// 1 if DGH's alarm is triggered, 0 if not
	int Disabled;					// Flag is 1 if we're ignoring this DGH

	int Init(int dghType,char address,int X0,int Y0);
	// Initializes the associated DGH module with its init string, and
	// the hard limit. Pass it:
	//  dghType: either AXIAL or RADIAL
	//  address: single character address "a" - "h"
	//  X0,Y0: upper left corner of tension display area
	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 tension and updates the onscreen display
	void Display();
	// Displays the DGHs current reading onscreen

	char Address; // The one letter address (example, 'a')
	char InitString[10]; // The DGHs initialization string
	int DGHType; // AXIAL, RADIAL, F11 or F5

// Open a DGH Terminal
void DGHTerminal();

// Configure all the DGHs at once- return 0 on success, 1 on failure
int ConfigDGHs();

// 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
Document Actions