April 28, 2024, 09:51:16 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Custom Chart question

Started by Andy, May 09, 2015, 05:28:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

I'm now getting to grips with the custom chart designer, and it seems quite easy to use.

But I do have a question, it takes a little explaining so bare with me:

You use the command -
SetTimerCLM( MyWin, 102, 550 )

This sets the timer / update for the chart (102) to update every 550 milliseconds....

Next you get the new updated data in the CASE @IDTIMER section of the handler, using this....

trackvalue.value1 = A     - this updates the chart 102.

Now, in my program to display live data I do use the CASE @IDTIMER in the handler for the live data screen (dy4).

Inside this "timer" I have a call to a sub routine called "LiveCommands"

    CASE @IDTIMER
            SETCONTROLTEXT dy4,static_10,"Reading vehicle data..."
            DataTestsDone = 1
            GOSUB LiveCommands
         
This sub then in turn checks sequentially which data tests you have selected (ticked) on the live data screen.

If a test has been selected to "get live data for this test" it will then in turn call a further sub routine called Mode1.

The Mode1 sub has the formulas for each test.

Example below is the test for 010C - Engine RPM

   z$ = y$
   A = Hex2Dec(z$)
   A = A * 256

   z2$ = y2$
 
   B = Hex2Dec(z2$)
   A = (A + B) / 4

   IF A < 0 THEN A = 0
   IF A > 16383.75 THEN A = 16383.75    

   SETCONTROLTEXT(dy4,da10,USING("%d#,###,###,###.##",A))

Where A is the actual value of the Engine RPM - here, deep down in this second sub routine I set the controltext of the live data screen (dy4) with the value of A on screen next to the text "Engine RPM".

So, if you have followed that - the question is where is the best place to put the line....

trackvalue.value1 = A     - update to chart 102.

The place where I used to set the controltext with the value?

   z$ = y$
   A = Hex2Dec(z$)
   A = A * 256

   z2$ = y2$
 
   B = Hex2Dec(z2$)
   A = (A + B) / 4

   IF A < 0 THEN A = 0
   IF A > 16383.75 THEN A = 16383.75    

   trackvalue.value1 = A 

        OR

        After I GOSUB LiveCommands in the CASE @IDTIMER section of the screen handler?


I am wondering also, what number of graphs I should display at any one time?
Someone could be "overloaded" with too much visual data at one go.

Hope that makes some kind of sense.....

Thanks,
Andy.
:)












Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

set it where ever you want but make sure that if the test isn't being run it get sets to zero if the chart is being displayed.

as to how many charts to display; that's entirely up to what you think looks good. 
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy


One thing that had me puzzled for around 2 hours as to why the graph was not plotting on screen.

I noticed that in the examples of the chart designer, a dialog was used instead of a window.

So I changed my window to a dialog, and the graph worked correctly.

This is no problem to me at all, but just wondered why I have to use a dialog screen?

And what really is the difference between a dialog and a window after all?

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Quote...wondered why I have to use a dialog screen?
somebody is not reading the help file ::)
I just happened to use dialogs in the examples

In the Chart Designer the default comments when the code is generated for a FT type chart it says this:

'The chart is created after the parent window/dialog is created.
   CreateCLM( MyWin , 0, 0, 400, 400, CLM_FT, CLM_SUNKEN, MyChart )

'The following must be placed in @IDINITDIALOG if the parent is a dialog;
'otherwise they may be placed after the CreateCLM function.

   CfgShellCLM( MyWin, MyChart, "C:\CCDLM\bmps\seasky.bmp", "C:\CCDLM\bmps\paper.bmp" )

As for the difference between windows and dialogs as it relates to why your charts didn't work at first.

when you create a window with OPENWINDOW it actually exists right then
immediately after that  you use the CONTROL statement and the controls actually exists right then

since the window exists you can immediately do things to modify it like change it's bg color
since the controls exist you can set their font, color, etc.

When you use the CREATEDIALOG command it only sorta exists; its more like you've allocated space for it and created its structure. The Only thing you can do to it is add controls to it with the CONTROL statement.  But when you do the controls don't really exist at that time so any commands you try to apply to them are simply ignored.

That why the comment above.  When you use the DOMODAL or SHOWDIALOG commands on dialog the information is taken and the actual dialog is created and along with any predefined controls. Any modification commands in the @IDINITDIALOG section will be applied before the dialog and controls are displayed.

A window has no need for the @IDINITDIALOG section and therefore does not process that command. A window processes the @IDCREATE command which is the proper place to always place the CENTERWINDOW command (if used) to prevent a flicker on startup).

Hope that sorta answers your questions.

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Yes,

That's interesting about dialogs and windows - thank you.

It's sometimes hard to balance two things at the same time - a huge piece of code and a new add-on, and trying to put the two together.

Anyway, thanks, I've managed it.

I decided that the maximum number of graphs would be 20, however it is unlikely there will ever be 20.

The attached is a screenshot of the program reading a log file from a live data test.

It is now just a matter of repeating this for actual live data, it won't be hard to do, just laborious as I have 90 possible vehicle tests, each has it's own formula, and you don't know what tests a vehicle can do, and what tests the user requests, so you have to cover them all.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.