none
LitDev extensions RRS feed

  • Question

  • Thank you LitDev for yours extraordinary extensions.

    I made a program to control and display a hardware data acquisition system on serial port.

    1. Is possible to add a function in LDgraph to reload the array dynamically ( array loaded on previous with AddSeries command) , by exemple:

                  LDGraph.ReloadSeries(Shape_Graph,"Data_RX")

    because this code:

                  LDUtilities.PauseUpdates()
                  LDGraph.DeleteSeries(Shape_Graph,"Data_RX")
                  LDGraph.AddSeriesLine(Shape_Graph,"Data_RX",data_RX,"Blue")
                  LDUtilities.ResumeUpdates()

    works for reload series but the "graphicwindow" lose events like mouse events and "PauseUpdate" and "ResumeUpdate"are slow (whitout this commands program work faster but have fliker on delete and addseries)

    2. Is possible to implement a error report function for LDCommPort? By example on:

                 LDCommPort.OpenPort("Com3") to return "Failed" when have port opening error

    or to create LDCommPort.Errors to return some errors code.

    3. Is possible to create a new function on LDCommPort to read from buffer port all data on byte format  or modify RXAll function to do this?

    By example LDCommPort.RXAll return a string of bytes but data between 128 and 255 (0x80 and 0xFF) are changed in 0x1F.

    Thank you,

    mihaisrb

    Saturday, March 21, 2015 7:16 AM

Answers

  • LDGraph.AddSeriesLine .....   perfect!!!

    Very good idea.

    LDCommPort ..... perfect!

    Thank you!




    • Edited by mihaisrb Saturday, March 21, 2015 12:43 PM
    • Marked as answer by mihaisrb Saturday, March 21, 2015 12:44 PM
    Saturday, March 21, 2015 12:34 PM

All replies

  • Hi,

    A couple questions:

    1]LDGraph question

    Is the data (data_RX) the same - if so are all you doing is changing colour or is the data array content changing?

    The best approach to get a flicker free fast transition of some sort may not be a simple reload since this may effectively do a delete and add which could also flicker.

    Is it possible for you to create a short program (just 20 or so lines sort of thing) for me that shows the issue with or without the pause commands, e.g. flicker without them and slow+event loss with them.

    I would like to understand the issues and have a test code before trying to change anything.

    2] Error message should be easy

    3] I haven't used LDCommPort much, can you give an example of the data.  I am not really clear on "return a string of bytes but data between 128 and 255 (0x80 and 0xFF) are changed in 0x1F."

    1. The raw byte data received
    2. How it is returned to the user with RXAll
    3. How you would like it returned
    Saturday, March 21, 2015 8:39 AM
    Moderator
  • Hi,

    1. Data content changing periodically. No color, no name of array, no name of series changed. I give an example:

    GraphicsWindow.Show
    data_RXR[199] = 1023
    Shape_Graph = LDGraph.AddGraph(0,30,500,400,"","","")

    LDGraph.AddSeriesLine(Shape_Graph,"Data",data_RXR,"Blue")
    LDGraph.ScaleAxisX(Shape_Graph,0,20)
    LDGraph.ScaleAxisY(Shape_Graph,0,150)

    notWorking = "true"
    Timer.Interval = 100

    Timer.Tick = OnTick

    Sub onTick

          If notWorking then

               notWorking = "False"

               'get data, in my case read LDCommPort and I simulate here with random nr.

               For I = 0 to 199

                       Data_RX[I] = Math.GetRandomNumber(1023)

               EndFor

               'Follow code works but "PauseUpdate" and "ResumeUpdate" are slow and GraphicWindows lose events

               ' (by example mouse events are gone to under our window to running programs or desktop)

               LDUtilities.PauseUpdates()  
               LDGraph.DeleteSeries(Shape_Graph,"Data")
               LDGraph.AddSeriesLine(Shape_Graph,"Data",data_RX,"Blue")
               LDUtilities.ResumeUpdates()

               'LDGraph.ReloadSeries(Shape_Graph,"Data")   'That I propose data_RX is the same lenght array.

               notWorking = "True"

          EndIF

    EndSub

    Propose LDGraph.ReloadSeries with on your code:

     -   pause and resume your update engine

     -   first add new data and then delete old one (must see effect)

     -  make two engine set data to second one and hide first 

    2. Thanks

    3.  I want read all the RX CommPort buffer like:

        data_RX = LDCommPort.RXAll() 'Discard buffer 
        'I can't use LDCommPort.RXByte() becouse I don't now number of elements on buffer
        if data_RX <> "" then
          For i = 1 to Text.GetLength(data_RX)
                 val_H = Text.GetSubText(data_RX,i,1)
                 val_H = Text.GetCharacterCode(val_H) ' This code works only for val_H in range 0 to 127
                                                                           'like ASCII not Unicode characters
                 val_Hexa[i] = LDmath.Decimal2Base(val_H,16)
          EndFor
        EndIf

    But Text.GetCharacterCode() works with Unicode characters. By example

        x = math.GetRandomNumber(255)
        Text.GetCharacterCode(text.GetCharacter(x)) 'return x

    So problem is on function LDCommPort.RXAll() which return a ASCII string not Unicode string.

    Propose are to implement LDCommPort.RXAllBytes and return a array of data or RXAll to return a Unicode string

    4. Thanks





    • Edited by mihaisrb Saturday, March 21, 2015 10:55 AM
    Saturday, March 21, 2015 10:13 AM
  • Hi,

    For questions 2 and 3 try test beta uploaded, which includes some error checking and new command SetEncoding which may solve issue 3 in a general way (if not let me know).

    For question 1 I see the flicker/delay from your code - thanks.  I still want to understand the event issue and cannot reproduce with this code.

    GraphicsWindow.Show()
    data_RXR[199] = 1023
    Shape_Graph = LDGraph.AddGraph(0,30,500,400,"","","")
    
    LDGraph.AddSeriesLine(Shape_Graph,"Data",data_RXR,"Blue")
    LDGraph.ScaleAxisX(Shape_Graph,0,20)
    LDGraph.ScaleAxisY(Shape_Graph,0,150)
    
    notWorking = "true"
    Timer.Interval = 100
    
    Timer.Tick = OnTick
    GraphicsWindow.MouseDown = OnMouseDown
    
    Sub onTick
      If notWorking then
        notWorking = "False"
        'get data, in my case read LDCommPort and I simulate here with random nr.
        For I = 0 to 199
          Data_RX[I] = Math.GetRandomNumber(1023)
        EndFor
        'Follow code works but "PauseUpdate" and "ResumeUpdate" are slow and GraphicWindows lose events
        ' (by example mouse events are gone to under our window to running programs or desktop)
        
        LDUtilities.PauseUpdates()  
        LDGraph.DeleteSeries(Shape_Graph,"Data")
        LDGraph.AddSeriesLine(Shape_Graph,"Data",data_RX,"Blue")
        LDUtilities.ResumeUpdates()
        
        'LDGraph.ReloadSeries(Shape_Graph,"Data")   'That I propose data_RX is the same lenght array.
        
        notWorking = "True"
      EndIF
    EndSub
    
    Sub OnMouseDown
      GraphicsWindow.Title = GraphicsWindow.Title+1
    EndSub

    Saturday, March 21, 2015 11:28 AM
    Moderator
  • If mouse event are between PauseUpdate and ResumeUpdate then event are lost and propagate to the next window or desktop.

    By example if our form is directly over desktop a right ckick show you the desktop menu not LDGraph rightclick menu.

    So some clicks are ok some are not depending of time lose on refreshing graph

    I can not upload a printscreen to show that ("forum don't permit upload image until your account is not verified") (!!!!)

    • Edited by mihaisrb Saturday, March 21, 2015 12:05 PM
    Saturday, March 21, 2015 11:54 AM
  • I understand - thanks.

    As a test I have modified the AddSeries methods to just replace the data if the series name (label) is the same.  Beta test code uploaded.

        'LDUtilities.PauseUpdates()  
        'LDGraph.DeleteSeries(Shape_Graph,"Data")
        LDGraph.AddSeriesLine(Shape_Graph,"Data",data_RX,"Blue")
        'LDUtilities.ResumeUpdates()

    So no need to delete first.  The flicker was caused by the redraw with no data after the delete.

    EDIT

    Uploaded  a new test beta with some internal performance improvements - works for me smoothly at 10ms timer intervals

    Saturday, March 21, 2015 12:06 PM
    Moderator
  • LDGraph.AddSeriesLine .....   perfect!!!

    Very good idea.

    LDCommPort ..... perfect!

    Thank you!




    • Edited by mihaisrb Saturday, March 21, 2015 12:43 PM
    • Marked as answer by mihaisrb Saturday, March 21, 2015 12:44 PM
    Saturday, March 21, 2015 12:34 PM
  • I noticed that so did a second uploap after a mod to fix- try that
    Saturday, March 21, 2015 12:36 PM
    Moderator
  • Another little problem (is in current lib litdev and in the test.lib one):

    on LDGraph rightclick menu, item "Export to Excel" send error in textwindow:

    "GraphEngine.mnuExcel_Click : Exception from HRESULT: 0x800A03EC"

    I use Windows 8.1 and MS Office 2013.

    Saturday, March 21, 2015 1:05 PM
  • This is an issue if you don't set a title for the graph - you can set it to " " and it should work.  Thanks for reporting.

    The title is used to set the worksheet name and excel throws exception when this is "".  I will protect against this.

    Saturday, March 21, 2015 3:08 PM
    Moderator
  • Thank you.

    10+

    Saturday, March 21, 2015 3:25 PM
  • Hi,

    On LDGraph extension we have LDGraph.ScaleAxisX(Shape_name,min,int) and ScaleY... were "min" is minim desired value and int the interval value. Now if "int" = 0  - imposible value - the graph ignore both parameters. I propose for this special case, when "int" = 0, the graph function use only the "min" value and  interval will be calculated automatic from data max value. Or these functions enriched to (min,int,max) and:

    for valid value graph will be displayed normaly, no automatic calculations,

    ex: LDGraph.ScaleAxisY(name,0,10,100): min = 0, int = 10, max = 100 no automatic graph drawings

    for -  "int" = 0 the interval will be calculated automatic by graph function,

    ex: LDGraph.ScaleAxisY(name,0,0,100): min = 0, int = automatic, max = 100

    for "max" = "min" the maximum graph value are  displayed from the data value:

    ex: LDGraph.ScaleAxisY(name,5,10,5) -> display graph with min = 5, int = 10, max = automatic

    ex: LDGraph.ScaleAxisY(name,5,0,5) -> display graph with min = 5, int = automatic, max = automatic

    Thx

    Mihai


    • Edited by mihaisrb Saturday, March 28, 2015 11:42 AM
    Saturday, March 28, 2015 11:41 AM
  • Good ideas - I will look into this.  I just converted extension to new SB version so testing this now - if it remains OK furher developments will mainly be on it.  It looks good so far - and using .Net 4.5 will open some new possibilities.
    Saturday, March 28, 2015 2:08 PM
    Moderator
  • Perfect,

    But for those stuck in XP and SB 1.0 I think is good idea to implement in current 1.0 LDlib the LDGraph.ScaleAxis only: IF  "int = 0" then graph minim value are "min"  and "int" and "max" are automatic.

    I help someone with a graphic plot program and have only XP.

    M

    Saturday, March 28, 2015 3:15 PM

  • Beta test version SB(1.1) uploaded for test of the LDGraph option.  I will see if there are any requests for updated bits for version 1 before considering maintaing 2 versions.
    Saturday, March 28, 2015 6:16 PM
    Moderator
  • I tested and works perfect in all variants (normal value, int =0 and/or max =0 even if min > max generate a good solution)

    Saturday, March 28, 2015 7:00 PM