Skip to content. | Skip to navigation

Personal tools

flags.cpp

flags.cpp

flags.cpp

/////////////////////////////////////////////////////////////////////////////
// FLAGS.CPP
//
//  Last updated: 05/24/2000
//
//  Part of the source code for the Vane End Actuator Control System
//
//  This file contains the flags for the program
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// CFlags::Init - Initialization of all flag variables
void CFlags::Init()
{
	TensionDisplay = TDPounds;
	Status = 0;
	Fatal = 0;
	MoveStage = MSIdle;
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::DisplayAll - Displays all flags on-screen appropriately
void CFlags::DisplayAll()
{
	int x,y;

	// Tension Display
	x = 196;
  y = 58;
	if (TensionDisplay == TDmV)
	{
		PutString16(" mV",x,x+24,y,BLACK,SHECMEDGRAY);
		PutString16(" mV",x+256,x+256+24,y,BLACK,SHECMEDGRAY);
	}
	else
	{
		PutString16("Lbs",x,x+24,y,BLACK,SHECMEDGRAY);
		PutString16("Lbs",x+256,x+256+24,y,BLACK,SHECMEDGRAY);
	}

	// Fatal Flags
	x = 520+12;
	y = fbty+26;
	if (Fatal & FFINIFile)
		PutChar16('þ',x,y,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y,BLACK,SHECMEDGRAY);
	if (Fatal & FFHome)
		PutChar16('þ',x,y+16,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+16,BLACK,SHECMEDGRAY);
	if (Fatal & FFOverheat)
		PutChar16('þ',x,y+32,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+32,BLACK,SHECMEDGRAY);
	if (Fatal & FFEmergencyStop)
		PutChar16('þ',x,y+48,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+48,BLACK,SHECMEDGRAY);
	if (Fatal & FFNoMotorResponse)
		PutChar16('þ',x,y+64,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+64,BLACK,SHECMEDGRAY);
	if (Fatal & FFCheckFatal)
		PutChar16('þ',x,y+80,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+80,BLACK,SHECMEDGRAY);
	if (Fatal & FFEncoders)
		PutChar16('þ',x,y+96,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+96,BLACK,SHECMEDGRAY);
	if (Fatal & FFTensions)
		PutChar16('þ',x,y+112,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+112,BLACK,SHECMEDGRAY);
	if (Fatal & FFEncoderLimit)
		PutChar16('þ',x,y+128,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+128,BLACK,SHECMEDGRAY);
	if (Fatal & FFTensionLimit)
		PutChar16('þ',x,y+144,SHECRED,SHECMEDGRAY);
	else
		PutChar16('þ',x,y+144,BLACK,SHECMEDGRAY);
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::ToggleTensionDisplay - Toggle tensions between pounds and mV
void CFlags::ToggleTensionDisplay()
{
	if (TensionDisplay == TDPounds)
		TensionDisplay = TDmV;
	else
		TensionDisplay = TDPounds;
	DisplayAll();
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::SetStatus - Set a status flag passed in SF
void CFlags::SetStatus(int SF)
{
	if ((SF == SFMoveInProgress) && (Fatal != 0))
		EDSLog.Add(18,"Move ignored, fatal errors exist");
	else
		Status |= SF;
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::ClearStatus - Clear the status flag passed in SF
void CFlags::ClearStatus(int SF)
{
	Status &= 65535 - SF;
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::CheckStatus - Return the status flag passed in SF
int CFlags::CheckStatus(int SF)
// Returns a 1 if the status flag SF is set, otherwise returns a 0
{
	if (Status & SF)
		return(1);
	else
		return(0);
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::SetFatal - Sets the fatal flag passed in FF
void CFlags::SetFatal(int FF)
{
	char s[255];

	// Only take action if this fatal flag hasn't already been set
	if ((Fatal & FF) == 0)
	{
		// Dump the running log to a time-stamped file if this is the first fatal
		// and if fatal log dumps are enabled
		if ((Fatal == 0) && (DumpLogOnFatal))
		{
			Fatal |= FF;
			Log.Dump(1);
		}
		else
			Fatal |= FF;
		// Update the appropriate LED
		DisplayAll();
		// Stop any current movement
		SetMoveStage(MSIdle);
		ClearStatus(SFMoveInProgress);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::ClearFatal - Clears the fatal flag passed in FF
void CFlags::ClearFatal(int FF)
{
	Fatal &= 65535 - FF;
	DisplayAll();
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::CheckFatal - Returns the fatal flag passed in FF
int CFlags::CheckFatal(int FF)
// Returns a 1 if the fatal flag FF is set, otherwise returns a 0
{
	if (Fatal & FF)
		return(1);
	else
		return(0);
}

/////////////////////////////////////////////////////////////////////////////
// CFlags::SetMoveStage - Sets the movement stage passed in MS
void CFlags::SetMoveStage(int MS)
// Sets the current movement stage, and updates the onscreen display
{
	if ((MS != MSIdle) && !(Status & SFMoveInProgress))
		MS = MSIdle;
	MoveStage = MS;
	if (MoveStage == MSIdle)
		ClearStatus(SFMoveInProgress);
}


Generated by GNU Enscript 1.6.5.2.
Document Actions