Real Time Value Updating

Hello,


I am using C++ Builder XE8 and the TMS Firemonkey packs and TMS Charts.  I have another post that I worked out the carriage box with text that holds the needles value.  However, is there a way that as the needle moves from point A to point B on the Linear Gauge, that the text can update along the way?  I would like this to be real time as possible and need to make sure the text being displayed is real.  I have an animation factor of 4, so when the needle moves from 40 to 100, it slowly moves up that way, as it should.  However, the text value is instantly set to 100 because it is not taking the current needles position value.  So the carriage box text instantly goes from 40 to 100 instead of being updated along the way.  Here is the sample of code I am using to update the carriage box:

void __fastcall TForm1::TMSFMXLinearGauge1ValueChanging(TObject *Sender, float Value)

{
TTMSFMXNeedleShape *n = TMSFMXLinearGauge1->GetNeedle();
        n->Repaint();
L1ValueText->Text = FloatToStr(TMSFMXLinearGauge1->Value);
}
//---------------------------------------------------------------------------

However, this just gets the value that is being set by another method.  I have a timer that is ticking every second adding 10 to the value of a linear gauge that goes from 0 to 280.  So when it moves from 0 to 10, the text I have that read the value does not update as it goes, it just instantly changes to 10 and then 20, and so on.  It would be nice if I could read the value as the needle moves.

Thanks for the help.  You have all been a great help getting these controls to work.

Sean M.

Another train of thought.  I am also struggling to get this to work for the CircularGauges and Charts as well.  I would like to get the current value of the needle and display it as text versus the value that is set, so as the animation moves, the text properly updates.


Thanks again.

Hi, 


This is currently not possible, but we have added a function CurrentValue that returns the value during animation instead of the value that the animation is going to. The next version will address this and you will be able to use the following code:

L1ValueText->Text = FloatToStr(TMSFMXLinearGauge1->CurrentValue);

Please note that this value will be the last value before reaching the actual value, so you could combine this with the OnValueChanged event and the original code to retrieve the value.

Kind Regards, 
Pieter


Pieter Scheldeman2015-10-02 09:13:02

Thank you Pieter.  When do you think the new version will be available for upgrade and/or purchase?

Hi, 


The new version 3.2.0.2 is already available.

Kind Regards, 
Pieter

Thank you, I have downloaded the latest release and I am installing now.  So if my understanding is right, the OnValueChanging() method is going to have the:


L1ValueText->Text = FloatToStr(TMSFMXLinearGauge1->CurrentValue);

The OnValueChanged() method is going to have:

L1ValueText->Text = FloatToStr(TMSFMXLinearGauge1->Value);

Thanks again for all of your help and we look forward to always doing business with TMS.

Regards,

Sean M.

That is correct !

So far it seems to be working but it is throwing a lot of numbers into that text field.  Is there a simple way I can limit it to say to decimal spots?  Right now it seems incredibly inaccurate.  I am getting about 7 digits in the text field instead of 2 and some decimals.  Is there a way to limit how the current value gets returned?

The idea would be to have it be 2.1, 2.2, 2.3.  Right now I am not sure what it is trying to display:


void __fastcall TForm1::TMSFMXLinearGauge1ValueChanging(TObject *Sender, float Value)

{
TTMSFMXNeedleShape *n = TMSFMXLinearGauge1->GetNeedle();
if(n && L1Carriage && L1ValueText)
{
L1ValueText->Text = FloatToStr(TMSFMXLinearGauge1->CurrentValue());
        this->Invalidate();
    }
}

Also, it seems I am constantly having to do a clean before I can run the Application again.  Should I be killing these in a deconstructor as well?

Another side note to this, when I had this method to the watch list to inspect the value, I get:


TMSFMXLinearGauge1->CurrentValue() - E2382 Side effects are not allowed

Also, after I step through enough times, I get a dialog box saying:

Source File Not Found: FMX.TMSGauge.pas

It wants me to add it to the debug path.  Could this be causing the issues?  I did the default install of the TMS Pack, so I dont know if I need to include the tmssoftware directory in my build path.  Let me know the proper way to handle this.  Thanks again.  Your support is fantastic.

Sean M.
It's unclear what is going wrong exactly. Perhaps you could try to assign the result to a variable for adding a watch, because CurrentValue is a function instead of a property.

You can use the Format function to accomplish the decimals issue:

  TVarRec vr[] = {TMSFMXLinearGauge1->CurrentValue()};
  L1ValueText->Text = Format("%.1f", vr, 2);

Kind Regards, 
Pieter

Pieter Scheldeman2015-10-02 16:42:46

Pieter,


You were correct.  I did assign it to a var to get the value and it is returning like 7 decimal places.  So I need to format this appropriately.  Thank you again for your help.

Regards,

Sean M.

I am now faced with an Ambiguity error using the code with a TVarRec:

    CDU.cpp(633): parsing: void _fastcall TForm1::TMSFMXLinearGauge1ValueChanging(System::TObject *,float)

Am I missing an include?

Didnt copy the whole error:


[bcc32 Error] CDU.cpp(639): E2015 Ambiguity between '_fastcall System::Sysutils::Format(const System::UnicodeString,const System::TVarRec *,const int) at c:\program files (x86)\embarcadero\studio\16.0\include\windows\rtl\System.SysUtils.hpp:3327' and '_fastcall System::Ansistrings::Format(const System::AnsiStringT<0>,const System::TVarRec *,const int) at c:\program files (x86)\embarcadero\studio\16.0\include\windows\rtl\System.AnsiStrings.hpp:36'

Scratch this, I found this issue was that Format() was calling the AnsiString version, so I had to specify it to use the System::SysUtils version of the Format() method.  Thanks again.  It appears to be working now.  Have a nice day and thanks again Pieter and all at TMS for your wonderful support.


Regards,

Sean Mackey

Hi, 


Thank you for your feedback that everything is working as expected now.

Kind Regards, 
Pieter