Ewon Technical Forum

Full Version: EWON FLEXY : record the data in a specific time interval
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

How can I record only the values between 6am and 10pm?
Hello.

I'm currently working on a script to do it.
I'm just wondering...How many tags do you record in your Flexy ?
(15-09-2022, 05:24 PM)alma Wrote: [ -> ]Hello.

I'm currently working on a script to do it.
I'm just wondering...How many tags do you record in your Flexy ?

Hello,

Thank you for your answer,
I have 22 Tags and the recording frequency is 120s
Hello.

Here's the BASIC code. You just have to include all the tags that you want to record in one (or several) group(s). Do you have any question regarding the code ?

Code:
Rem --- eWON start section: Init Section
eWON_init_section:
Rem --- eWON user (start)
// First select the groups that you want to record (value "1" to record)
GroupA$ = "1"
GroupB$ = "0"
GroupC$ = "0"
GroupD$ = "0"

// Set values for logging parameters
LogDeadBand% = 3
LogTimer% = 20

ONDATE 1,"0 6 * * *", "@LogEnable(LogDeadBand%,LogTimer%)" // Enable HL at 6AM
ONDATE 2,"0 22 * * *", "@LogDisable()" // Disable HL at 10PM


FUNCTION LogEnable($logDB%,$logTimer%)
$NBTAGS% = GETSYS PRG,"NBTAGS"
    For $i%=0 To $NBTAGS%-1
   
        Setsys Tag,"load",-$i%
        $IVGroupA$= GETSYS TAG,"IVGROUPA"
        $IVGroupB$= GETSYS TAG,"IVGROUPB"
        $IVGroupC$= GETSYS TAG,"IVGROUPC"
        $IVGroupD$= GETSYS TAG,"IVGROUPD"
       
        IF (GroupA$ = "1" And $IVGroupA$= "1") OR (GroupB$ = "1" And $IVGroupB$= "1") Or (GroupC$ = "1" And $IVGroupC$= "1") Or (GroupD$ = "1" And $IVGroupD$= "1")  THEN
        SETSYS TAG, "LogEnabled", 1
        SETSYS TAG, "LogDB", $logDB%
        SETSYS TAG, "LogTimer", $logTimer%
        SETSYS TAG, "save"
        Endif
       
    Next $i%
   
PRINT "Log Enabled"
ENDFN

FUNCTION LogDisable()
$NBTAGS% = GETSYS PRG,"NBTAGS"
    For $i%=0 To $NBTAGS%-1
   
        Setsys Tag,"load",-$i%
        $IVGroupA$= GETSYS TAG,"IVGROUPA"
        $IVGroupB$= GETSYS TAG,"IVGROUPB"
        $IVGroupC$= GETSYS TAG,"IVGROUPC"
        $IVGroupD$= GETSYS TAG,"IVGROUPD"
       
        IF (GroupA$ = "1" And $IVGroupA$= "1") OR (GroupB$ = "1" And $IVGroupB$= "1") Or (GroupC$ = "1" And $IVGroupC$= "1") Or (GroupD$ = "1" And $IVGroupD$= "1")  THEN
        SETSYS TAG, "LogEnabled", 0
        SETSYS TAG, "save"
        Endif
       
    Next $i%
   
PRINT "Log Disabled"
ENDFN


Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section
Hello.
Is it possible to add a timestamp at filename so that there is a separate file for each case?
I want to make a local storage with access by ftp (\usr\records\val.csv or \usr\records\val.txt for example). I want to have unique filename for every time I do a tag log.

I'm also interesting at tags gathering for several Pages only. Is it possible to group tags to be recorded by Pages instead of by Group name?
I want to divide the tags into more than four sections while we only have four (Group A, B, C and D).

I can't find any information on RG-006...
Hi,

Yes, you can use the time of the Ewon to create a unique filename like
MyAction:
T$=Time$ //T$ = 17/10/2022 15:03:40
A$="/usr/MyData/Data"+T$(7 To 10)+"-"+T$(4 To 5)+"-"+T$(1 To 2)+".csv" ///usr/MyData/Data2022-10-17.csv
PUTFTP A$,"[$dtHL $ftT $st_d1 $et_s0 $tnTestTag]"
END

Regarding the Tag pages, you cannot use them if you export the Historical Logging using the Export Block Descriptor--> https://tools.ewonsupport.biz/ebd/. Only Tag groups can be used.
However if you create a txt file yourself in BASIC script (OPEN, PUT, CLOSE) without using the EBD., you can get the Tag pages of your Tags from the BASIC script.

NB%= GETSYS PRG,"NBTAGS"
FOR i% = 0 TO NB%-1
SETSYS Tag, "load",-i%
PageID$ = GETSYS TAG, "PageId" //You get here the ID
SETSYS Sys, "Load"
PRINT GETSYS SYS, "Page" + PageID$
NEXT i%
Thank you Simon.
I'm tried to use part of data T$ to change the filename. My mistake was to use t$(1 to 19). I'd got the "/" symbols at a$ so PUTFTP was getting a incorrect path to use.
I had to use [T$(7 to 10)+"some_separator_good_for_file_system"+T$(4 to 5) etc] to set correct filename.

Can I use any method to use T$ at Configure Alarm actions tab as the Destination File Name?
The Basic IDE now work good. But I have to stop script every time I make changes.
Hi,

Good you find a solution :-)

No it is not possible to use a BASIC expression in the Ewon Configuration menu (like Alarm notification menu). Sad