Graph Widgets

Discuss issues and ideas you have to configuring displays with PowerVision
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Graph Widgets

Post by cconner_aie » Fri May 19, 2017 3:16 pm

I have a question on the graph widgth, it seems like the graph is shifted right (new data added to the left) as new data comes in:

(looking at the blue data).
Image

Is there a way to make the 0 position on the X axis fixed so the new data is added to the right of the the current data rather than vice-versa? Sort of like this (excuse my paint skills).

Image

I found the mirroring option, but that just starts the graph on the right side. Not what I want.

Is this possible?
Coleby Conner
Controls Engineer, Anderson Industrial Engines
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: Graph Widgets

Post by cconner_aie » Fri May 19, 2017 3:22 pm

Here is how I add the data to the list:

Code: Select all

int mColdStartRow = 0;
double mColdStartRPM = 0.0;
double mColdStartAmbient = 0.0;
double mColdStartVoltage = 0.0;
double mColdStartCoolant = 0.0;

void $E_ColdStart_Power$ () 
{
	uint isLogging = VariableEnumerations.V_ColdStart_IsLogging_OFF;
	smRead(VariableIDs.V_ColdStart_IsLogging, isLogging);
	if (isLogging == VariableEnumerations.V_ColdStart_IsLogging_ON) {
		ColdStart_stopLoop();
	} else {
		ColdStart_clearList();
		ColdStart_getData();
		ColdStart_addItem(0);
		ColdStart_startLoop();
	}
	E_Engine_Power();
}

// every 250ms via timer ET_ColdStart_Loop
void $E_ColdStart_Loop$ () 
{
	uint isLogging = VariableEnumerations.V_ColdStart_IsLogging_OFF;
	smRead(VariableIDs.V_ColdStart_IsLogging, isLogging);
	
	if (isLogging == VariableEnumerations.V_ColdStart_IsLogging_OFF || mColdStartRow >= 480) {
		ColdStart_stopLoop();
	} else {
		ColdStart_getData();
		ColdStart_addItem(++mColdStartRow);
	}
}

void ColdStart_getData() {
	smRead(VariableIDs.V_J1939_IC1_EngineIntakeManifold1Temperature, mColdStartAmbient);
	smRead(VariableIDs.V_J1939_EEC1_EngineSpeed, mColdStartRPM);
	smRead(VariableIDs.V_J1939_VEP1_BatteryPotential, mColdStartVoltage);
	smRead(VariableIDs.V_J1939_ET1_EngineCoolantTemperature, mColdStartCoolant);
}

void ColdStart_addItem(int row)
{
	mColdStartRow = row;
	CustomListData data;
	data.WriteInt32(CustomListColumn.L_ColdStart_RowId, mColdStartRow);
	data.WriteDouble(CustomListColumn.L_ColdStart_Ambient, mColdStartAmbient);
	data.WriteDouble(CustomListColumn.L_ColdStart_RPM, mColdStartRPM);
	data.WriteDouble(CustomListColumn.L_ColdStart_Voltage, mColdStartVoltage);
	data.WriteDouble(CustomListColumn.L_ColdStart_Coolant, mColdStartCoolant);
        ListManagerAddItem(ListDataType.L_ColdStart, data);
	//ListManagerSetPosition(ListDataType.L_ColdStart, ListManagerGetCount(ListDataType.L_ColdStart) - 1);
}

void ColdStart_stopLoop() {
	SendAction(ApplicationIDs.CCM,
		ActionIDs.CCM_Cancel_Timer, TimerIDs.ET_ColdStart_Loop);
	smWrite(VariableIDs.V_ColdStart_IsLogging,
		VariableEnumerations.V_ColdStart_IsLogging_OFF);
}


void ColdStart_clearList() {
	int last = ListManagerGetCount(ListDataType.L_ColdStart) - 1;
	for (int i = last; i >= 0; i--) {
		ListManagerRemoveItem(ListDataType.L_ColdStart, i);
	}
	ListManagerSetPosition(ListDataType.L_ColdStart, 0);
}
Coleby Conner
Controls Engineer, Anderson Industrial Engines
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: Graph Widgets

Post by boyce » Mon May 22, 2017 4:48 pm

I finally got it to add to the right. Try this after the new item is added:

Code: Select all

	ListManagerMoveTo(ListDataType.L_ColdStart, 0);
	ListManagerSetPosition(ListDataType.L_ColdStart, ListManagerGetCount(ListDataType.L_ColdStart) - 1);
Boyce Schrack
Enovation Controls