Msmax

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by Msmax

  1. I have more then 2500 components with 4 status level for each... +10.000 bits to assign to have the component animated in the desired colors.
    All info is available in an Excel sheet which represents the Modbus registers.
    Tag name, description, modbus absolute bit in register

    From the Excel sheet I can generate text files which contains all the "defines" and list of the page the component belongs to (for animation on top level screen so user can click on the component on the overview screen and the next level page will show), which I then can load in Daqview.

    The idea is to have a universal symbol which I can place on the pages and just rename  to the tag name.
    The script inside the component will assign the bit number to a local variable (derived from the componentname and the define statements) and animation will work if the bits are set/reset in the registers. Saves me a lot of work to assign all the bits manually to every component.

    I will make a small test document with few components and upload here.

    And you are right.. the problem is that the defines are not yet loaded when the OnLoad() event in the component executes.
    If I copy the component from one to another page then the script shows the Indexes as coded for the copy component.

  2. I need a bit of help in retrieving a value using the component name in OnLoad event and evaluate.

    The next code is in a sequence which is run at start of the document:
    Define L001D001 = 1
    Define L001D002 = 2
    Define L001D004 = 3


    The next code is in the OnLoad event of the component:
    ?"Onload Event Start"

    local Index1 = evaluate(ComponentName)
    ? "OnLoad Event1: " + Index1

    local Index2 = evaluate(L001D001)
    ? "OnLoad Event2: " + Index2


    Upon loading the page I only see the text "Onload Event Start" in the Command/Alert window and nothing else..

    If I assign a value directly to the local var Index1 then the second line is also shown with 1 at the end.
    local Index1 = 1
    ? "OnLoad Event1: " + Index1


    If I enter ?L001D001 in the command window then the result "1" is shown, which is what I expect.

    Also... if I put the next code in the "Action - Quick Sequence" of the component then the result is also what I expect upon a click.
    local Index1 = evaluate(ComponentName)
    ? "OnLoad Event1: " + Index1

    So, it seems that the line "local Index1 = evaluate(ComponentName)" does not do what I expect it to do if written in the OnLoad event of a component.

    Any idea's how to make this work?

     

  3. Thanks for your reply.

    For now I made a small utility which is loaded with a ShellExecute() command by button press on the screen.
    I can add the log file "source' directory as a parameter in the ShellExecute() command line, so I can use it for different projects.

    The file list box will show all available log files and the number of files found.
    After pressing the refresh button, it will show all available USB drives and enable the copy and remove button.
    Simple but does what I need it to do... copy all log files to a selected USB drive.

     

    DAQView Copy Log.png

  4. My application writes a log file in a predefined directory. Filename is just date.txt. So for every day a new file is written with log data.

    The user can not switch to Windows Explorer to copy these files.
    I would like to have a popup where the user can select the inserted USB drive and just press copy or move, so the log files can be transferred to the USB.
    There should be no option to explore other area's on the hard disk of the computer, just select an output drive.

    Any idea's how to do this?


     

  5. Trying again to load my document in fullscreen and properly centered using some commands in script without any luck.

    The next commands does not work if used in a sequence:
    system.maximize()
    or
    system.fullscreen = 1

    Have put them in a sequence.
    My document window is NOT maximized.
    When sequence is started manually in "Workspace tree" then I expected something should happen... but nothing at all.

    Did find a post describing the same but no solution was posted yet to this problem.
    Any tips how to use these commands in script?
     

  6. 5 minutes ago, AzeoTech said:

    Well, you could get around it by using a local variable in the component and call evaluate() from the OnLoad().  Then evaluate() is only used once.   So, something like:

    local index = evaluate(componentName)

    Then you can use index in the expression.  Index is just a number so will execute quite fast, especially compared to evaluate().

    Note, the OnLoad() is only calculated when the component is created (i.e. when first displayed).  You can trigger this event after the fact using component.myComponent.redoLoadEvent()

    For speed though I would also make sure and do what I said about calculating a combined result for the entire array:

    MB_Status = MB_Faults + (MB_FaultsAck)*2 + MB_Fires*4 + MB_FiresAck*8+ MB_Inhibit*16

    and then the expression in component just becomes:

    MB_Status[index]

     

    Ok. I get the first part... that is clear for me now. Will need 18.1 to test that.

    The second part is interesting..
    MB_Status = MB_Faults + MB_FaultsAck*2 + MB_Fires*4 + MB_FiresAck*8+ MB_Inhibit*16

    This will calculate all in 1 line without using counters, indexes etc.?? 
    I can do this already with 17.1, this will save me a lot of time for sure. Only have to change 1 index in stead of 4 for each component.
    All arrays are the same size and the indexes do match. 
    Thanks!

  7. 11 minutes ago, AzeoTech said:

    That won't work because ComponentName returns a string.  So if ComponentName is "myComponent" doing:

    MB_Faults[componentName]

    would be the same as:

    MB_Faults["myComponent"]

    not

    MB_Faults[myComponent]

    You would have to do:

    MB_Faults[evaluate(myComponent)]

    and given the # of elements, you should avoid evaluate() because it is pretty slow.  

     

    OK.. then I have to forget evaluate. System must be fast responsive... don't want a slow system. 
    Customer will not be happy!

  8. Please ignore the previous post... accidently pressed save.
    Complete post is below.

     

    Thanks for the explanation. I do not get all of it yet, but will definately play with the setup as you advise as soon I get some spare time.

    I discovered that the ComponentName is not a number and can not be used like this, but I was thinking to use define statement to assign a number to a tag same as the componentname.
    For example... 
    At startup sequence:
    define L01D01 = 1
    define L01D02 = 2
    define L08D34 = 6
    define L10D80 = 8
    define L16D45 = 9

    Now I would place some components on the screen and name them:
    component 1: L01D01
    component 2: L01D02
    component 3: L08D34
    etc...

    The idea was to use in the component expression: 
    x= evaluate(ComponentName)
    MB_Faults[x] + (MB_FaultsAck[x])*2 + MB_Fires[x]*4 + MB_FiresAck[x]*8+ MB_Inhibit[x]*16

    Not sure if this will work. Have to install 18.1 to test this.


    I can not use the counting method because the name of the component, is the tag as used in the field and that is not in sequence.
    Later I would like to add display of the ComponentName in a popup text box when the mouse pointer is on top of the symbol. That would be very nice...

  9. I had to troubleshoot scripts on a PC running runtime license.
    So I copied my Pro license from my laptop to the USB key and did the troubleshooting.

    Now I like to have the license back on my laptop so I do not have to plug in the USB key everytime, but I do not see an option for that.
    Hoe to get the license back again on my laptop?

  10. Ok... not sure if I understand this right...

    If I create a user defined component, rename it to L01D01, and write in the Quick Sequence:
    ?"ComponentName: " ComponentName

    Then I expect to see the component name printed in the Command/Alert window if I click on the component... nothing printed.
    I expected to see: "ComponentName: L01D01"

    If I leave out the last word then "ComponentName:" is printed.

    Is this the right way to use ComponentName in a script within the component self?
     

  11. Thanks for your clear explanation. Think I was looking for ComponentName...

    I have created quite some user defined components which animates according bits set in several data registers filled via modbus read sequences.
    For each component I place on the screen I have to set the bit numbers (the "x" which refers to the index of the bit in the array) manually now which is very time consuming.

    MB_Faults[x] + (MB_FaultsAck[x])*2 + MB_Fires[x]*4 + MB_FiresAck[x]*8+ MB_Inhibit[x]*16

    I assume I can replace the "x" by ComponentName in the script inside the component and load a file which assigns the correct bit number to the ComponentName in memory.
    Then my script does not have to change if I rename the components correctly.

    Some where at startup I will load the "x" values for the components:
    ComponentName = Value
    L01D01 = 1
    L01D02 = 2

    etc...

    Next part is script within the component for animation:
    MB_Faults[ComponentName] + (MB_FaultsAck[ComponentName])*2 + MB_Fires[ComponentName]*4 + MB_FiresAck[ComponentName]*8+ MB_Inhibit[ComponentName]*16


    I will test this and if it does not work then I will make a small sample project to explain better what I'm looking for.
    The first project was more than 10.000 bits to assign... 
    The one I'm working on now has more or less 2500 bits to assign...

  12. Need some help with using/accessing component names and variables in component expression.

    Is it possible to use a local var in a component expression?

    My own created symbol has an expression like:
    MB_Faults[x] + (MB_FaultsAck[x])*2 + MB_Fires[x]*4 + MB_FiresAck[x]*8+ MB_Inhibit[x]*16

    Now I have to replace the "x" every time for every symbol with the index of the register, which is a lot of work if the component is used few hundred times.

    Would be great to use:
    private x = 770
    MB_Faults[x] + (MB_FaultsAck[x])*2 + MB_Fires[x]*4 + MB_FiresAck[x]*8+ MB_Inhibit[x]*16

    or even better if I can use the component name as reference:
    MB_Faults[MyName] + (MB_FaultsAck[MyName])*2 + MB_Fires[MyName]*4 + MB_FiresAck[MyName]*8+ MB_Inhibit[MyName]*16

    Then I could load the values from a file.

    But is it possible to get the component name in the expression?