// StatusStatic.cpp: implementation of the CStatusStatic class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "dashboard.h"
#include "StatusStatic.h"
#include "DashboardRecipient.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CStatusStatic::CStatusStatic()
: CLabel()
{

}

CStatusStatic::~CStatusStatic()
{
}


void CStatusStatic::setDeviceStatus(int s)
{
	CDashboardRecipient::DeviceStatus stat = CDashboardRecipient::int2dev(s);

	switch(stat){
	case CDashboardRecipient::Ok:
		SetBkColor(RGB(41,220,16));
		SetWindowText("OK");
		break;
	case CDashboardRecipient::Initializing:
		SetBkColor(RGB(101,3,233));
		SetWindowText("Initializing");
		break;
	case CDashboardRecipient::Offline:
		SetBkColor(RGB(97,125,139));
		SetWindowText("Offline");
		break;
	case CDashboardRecipient::Error:
		SetBkColor(RGB(202,206,30));
		SetWindowText("Error");
		break;
	case CDashboardRecipient::FailedInit:
		SetBkColor(RGB(198,38,138));
		SetWindowText("Failed Init");
		break;
	case CDashboardRecipient::FailedRead:
		SetBkColor(RGB(235,31,1));
		SetWindowText("Failed Read");
		break;
	case CDashboardRecipient::Failed:
		SetBkColor(RGB(217,19,88));
		SetWindowText("Failed");
		break;
	default:
		SetBkColor();
		SetWindowText("?");
	}
}

void CStatusStatic::setBatteryStatus(char c)
{
	switch(c){
	case 'c':
		SetBkColor(RGB(222,159,12));
		SetWindowText("Charge");
		break;
	case 'f':
		SetBkColor(RGB(85,103,149));
		SetWindowText("Off");
		break;
	case 'd':
		SetBkColor(RGB(39,194,44));
		SetWindowText("On");
		break;
	case 'u':
		SetBkColor(RGB(133, 32, 96));
		SetWindowText("Unknown");
	default:
		SetBkColor();
		SetWindowText("?");
	} 
}

void CStatusStatic::setBatteryError(int err)
{
	if(err == NOMINAL) {
		SetBkColor(RGB(39,194,44));
		SetWindowText("OK");
	} else if(err == WARNING) {
		SetBkColor(RGB(217,222,12));
		SetWindowText("Warn");
	} else if(err == DANGER) {
		SetBkColor(RGB(228,117,5));
		SetWindowText("Danger");
	} else if(err == ABORT) {
		SetBkColor(RGB(231,37,3));
		SetWindowText("Abort");
	} else {
		SetBkColor();
		SetWindowText("?");
	}
}

void CStatusStatic::setControlExecuteStatus(CString str)
{
	if(str == "not") {
		SetBkColor(RGB(162,162,162));
		SetWindowText("Not Running");
	}
	if(str == "initializing") {
		SetBkColor(RGB(101,3,233));
		SetWindowText("Initializing");
	} if (str == "waiting") {
		SetBkColor(RGB(52,203,184));
		SetWindowText("Waiting");
	} else if (str == "executing") {
		SetBkColor(RGB(32,228,27));
		SetWindowText("Executing");
	} else if (str == "goal") {
		SetBkColor(RGB(215,252,3));
		SetWindowText("At Goal");
	}
}
