Q&A Forum
I've managed to write a basic Visual Basic program that converts units.
Lots to learn in terms of converting this to a plugin. I've had a quick look at the source for the speed and distance plugin. The first step for me is to pass a variable from YourDyno into my plugin. How do you know what the variables that can be taken from YourDyno are? E.g. if i want power, how do i know a) if is available and b) what it's name is.
Thanks.
Arrgh just tried to post a long post detailing it and forum timed out. Pushed back button and its gone.
In managed code you can view all the functions of the referenced dll and its values.
"DataConnection.OneProcessedSample" is where you want to be looking for processed data by the bluebox.
The speed distance plugin will give you the sort of method for polling values.
On of my plugins for example. In the main entry class of the plugin where it has "private DynoDataConnection dynoDataConnection;"
I make a timer that will poll the values and a static that will hold the values which I can read from anywhere else in my plugin.
--- Alright so forum times out if im including code in the post ---
You need to make some statics to store the values, Then a timer to update them so the rest of the plugin can access it.
So I have.
public static Timer dynodata = new Timer();
public static float DRPM;
public static float DHP;
public static float DNM;
and inside that timer.
if (dynoDataConnection != null)
{
DRPM = (float)dynoDataConnection?.polledDataSet.engineRPM;
DHP = (float)dynoDataConnection?.polledDataSet.wheelHP;
DNM = (float)dynoDataConnection?.polledDataSet.wheelTorque;
}
public class OneProcessedSample { public double engineRPM; public double timeStamp; public double engineHP; public double engineTorque; public double wheelHP; public double wheelTorque; public double wheelHP1; public double wheelTorque1; public double wheelHP2; public double wheelTorque2; public double aux1; public double EGT; public double aux2; public double aux3; public double instantEngineRPM; // used for gauge public double roller1RPM; public double roller2RPM; public double instantRoller1RPM; // used for PID reg public double instantRoller2RPM; // used for PID reg public float gearRatio; }
I can't see any of the above variables in the speedanddistamce source, do i need to import something else?
Also, there are no Static variables?
public void DynoDataReceivedEventHandler(object sender, OnDataReceivedEventArgs e)
{
float rollerRPM;
if (SensorAndBrakeConfig.NumberOfRPMSensors() == 2)
rollerRPM = (float)(e.processedDynoSample.instantRoller1RPM + e.processedDynoSample.instantRoller2RPM) / 2;
else
rollerRPM = (float)e.processedDynoSample.instantRoller1RPM;
if (Settings.Properties.Settings.Default.UnitSelection == "Metric")
{
speed.y = rollerRPM * Properties.Settings.Default.brakeCirc * 60 / 1000;
if (!dynoDataConnection.isLogging)
distance.y = 0;
else
distance.y += rollerRPM / 60 * Properties.Settings.Default.brakeCirc * (float)e.processedDynoSample.timeStamp;
}
In the above i can see a float created for rollerRPM. Does it have to be created in the plugin even if it is in the main code?
Speed distance plugin doesnt pass any of the variables to the form it creates so doesnt need any statics.
Its doing every thing within the guages its makes which is speed and distance.
Jostein really needs to finish off the plugin guide/instructions. I sort of just guessed my way though the code which is quite easy being dotnet.
I think i will wait for Jostein to do some more work on the guide, no doubt he has enough on his plate!
Ok the guide helped a lot, but am struggling.
I want to add a gauge to the speed and distance plugin that shows metric horse power.
I start by adding :
private OnePlugInDataConnection metricpower = new OnePlugInDataConnection();
then in public SpeedAndDistance()
I add:
metricpower.name = "MetricHP";
metricpower.unit = "PS";
metricpower.graphPane = 1;
metricpower.isY2Axis = false;
metricpower.showGaugeInRunWindow = true;
metricpower.applyNoiseFiltering = true;
data.Add(metricpower);
Then for the actual calculation which id done in public void DynoDataReceivedEventHandler(object sender, OnDataReceivedEventArgs e)
I create a float variable called metricpower.
The calculation is metricpower.y = wheelHP1 * (float)0.98632;
There errors are:
Severity Code Description Project File Line Suppression State
Error CS0165 Use of unassigned local variable 'metricpower' SpeedAndDistance C:\Users\Rick\source\SpeedAndDistance\SpeedAndDistance.cs 162 Active
Severity Code Description Project File Line Suppression State
Error CS1061 'float' does not contain a definition for 'y' and no accessible extension method 'y' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?) SpeedAndDistance C:\Users\Rick\source\SpeedAndDistance\SpeedAndDistance.cs 162 Active
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'wheelHP1' does not exist in the current context SpeedAndDistance C:\Users\Rick\source\SpeedAndDistance\SpeedAndDistance.cs 162 Active
Questions are:
what is the .y part for? Speed.y is not created as a variable and yet there is no error for it.
wheelHP1 is not found, yet rollerRPM is and they are both listed in DataConnection.OneProcessedSample
Thanks.
So at the top of the page where your defining the veriables you need to add.
private OnePlugInDataConnection metricpower = new OnePlugInDataConnection();
That will fix the first two errors, since its complaining about stuff not being defined.
3rd error you need to put the full location in.
metricpower.y = (float)dynoDataConnection?.polledDataSet.wheelHP * (float)0.98632;
With the Y value you can think of it as a line graph for they Dyno.
Time being X and Y being your set value. The guages will show the Y value at current time. While the other graphs will show Y vs X (time)
So at the top of the page where your defining the veriables you need to add.
private OnePlugInDataConnection metricpower = new OnePlugInDataConnection();That will fix the first two errors, since its complaining about stuff not being defined.
3rd error you need to put the full location in.
metricpower.y = (float)dynoDataConnection?.polledDataSet.wheelHP * (float)0.98632;
With the Y value you can think of it as a line graph for they Dyno.
Time being X and Y being your set value. The guages will show the Y value at current time. While the other graphs will show Y vs X (time)
private OnePlugInDataConnection metricpower = new OnePlugInDataConnection();
Is already defined line 22.
If i add:
metricpower.y = (float)dynoDataConnection?.polledDataSet.wheelHP * (float)0.98632;
With that line I get:
Severity Code Description Project File Line Suppression State
Error CS1061 'float' does not contain a definition for 'y' and no accessible extension method 'y' accepting a first argument of type 'float' could be found (are you missing a using directive or an assembly reference?) SpeedAndDistance C:\Users\Rick\source\SpeedAndDistance\SpeedAndDistance.cs 164 Active
Thanks for looking 🙂
Attach the complete source and I'll have a look
Thanks
Hi,
You had two definitions of metricpower. Remove
double
metricpower = 0;
metricpower.y = (float)(e.processedDynoSample.wheelHP * 1.01387);
And you're good to go.
Brilliant, all compiled. I will add some more unit conversions when I test this.
this statement converts the wheelHP into a float?
what does the e. property represent?