Ewon TechForum
Providing technical solutions to technical requests


Export Historical CSV Report on your Extended User Memory card
simon Offline
eWON Support
#1
Hi guys,

As of the firmware 12.1s2, you can extend the Usr memory of your eWON by using a SD card (aka EUM card).

One of the use case is to store historical data reports on this memory extension.  You'll then be able to retrieve them by using your FTP client.

Here is an example of how to generate these historical data reports on an incremental way (to paste in the init section) :

Code:
CLS
REM GENERATE REPORT EVERY HOUR
ONDATE 1,"0 * * * *","GOTO GENERATE_REPORT"
ONSTATUS "GOTO SCHEDULEDACTION_END"
GOTO GENERATE_REPORT
END


GENERATE_REPORT:
//Check if SD card is inserted or if there is enough space
SETSYS INF,"LOAD"
SDCardSize$ = GETSYS INF, "SDExtFree"
SDCardSize_Int% = Val  SDCardSize$
IF SDCardSize_Int% > 5000 THEN   // 5 MB remains
   GOSUB READ_LASTTMS
   LAST_TIME$ = @GetCurrentTimeStamp$()
   EBD_STRING$ = "$dtHL$ftT$et" + LAST_TIME$ + "$st" + LASTTMS$
   FILENAME$ = "/usr/sdext/DataReport" + LAST_TIME$ + ".txt"
   WRITEEBD  EBD_STRING$, FILENAME$
   ActionID% = GETSYS Prg, "ACTIONID"
ELSE
  LOGEVENT "EUM Card full or not present", -1
ENDIF
END

SCHEDULEDACTION_END:
  CurID% = GETSYS Prg,"EVTINFO" : REM Get ActionID
   REM : Check if it is the right schedule action to save last timestamp otherwize do nothing
   If ActionID% = CurID% THEN
     SETSYS Prg, "ACTIONID", CurID%
     CurID_Status% = GETSYS Prg,"ACTIONSTAT"
     REM Action successfully done --> Write last timestamp in file
     IF CurID_Status% = 0 THEN
       LOGEVENT "FILE " + FILENAME$ + " SUCCESSFULLY EXPORTED", 100
       @WRITETMS(LAST_TIME$)
      ELSE
        LOGEVENT "FILE " + FILENAME$ + " NOT SUCCESSFULLY EXPORTED", 0
     ENDIF
   ENDIF
END

READ_LASTTMS:
SETSYS PRG,"RESUMENEXT",1
 REM GET LAST TIMESTAMP
OPEN "file:/usr/tms.dat" FOR BINARY INPUT AS 1
  LASTTMS$ = GET 1,15
CLOSE 1

Cur_Err% = GETSYS PRG,"LSTERR"
 
IF Cur_Err% = 33 THEN //REM File does not exist
  LASTTMS$= "01011970_000000"
  SETSYS PRG,"LSTERR",0
ENDIF

SETSYS PRG,"RESUMENEXT",0
CLS

RETURN

FUNCTION WriteTMS($LastTimeStamp$):
OPEN "file:/usr/tms.dat" FOR BINARY OUTPUT AS 1
  PUT 1,$LastTimeStamp$
CLOSE 1
ENDFN

FUNCTION GetCurrentTimeStamp$()
REM TIME$ = 19/12/2014 10:03:01
$EWON_TIME$ = TIME$
$GetCurrentTimeStamp$ = $EWON_TIME$(1 To 2) + $EWON_TIME$(4 To 5) + $EWON_TIME$(7 To 10) + "_" + $EWON_TIME$(12 To 13) + $EWON_TIME$(15 To 16)+ $EWON_TIME$(18 To 19)
ENDFN
Reply

iOne Offline
Ewon Distributor
#2
Hi!

I tested it and it works fine. O.K. I have to tried two different SD cards. The first one (SanDisk) was not working, the second one (maxflash) worked.
Then I pulled the SD during running and I got an error message "EBD fail". But even after inserting the SD again, the sdext directory came not back and also no more EBD was written.
So I think it is not allowed to pull the SD. Right? And how can I restart my system?

Thanks
iOne
Reply

Ludo Offline
eWON Support
#3
Hi Matthias,

You are right, the EUM Card shouldn't be taken off when the eWON is still running.
To get you system back up, simply perform a reset level 1 (with your EUM Card out if you want to save the data currently on it). It should put everything back to normal.

We also change the code here above.
We added a condition that checks if an EUM Card is inserted and if space is available (5Mb at least).
Reply

insyncs Offline
Member
#4
Hi, 

Trying this code. I haven't put an sd card in yet, so wanted to see if there were any errors.  is all the code supposed to be in the init section? do i need to add the tags?

see attached picture.

I inserted a card and got similar errors, see second pic.

Cheers M


Attached Files
.png   RT Error.PNG (Size: 9,56 KB / Downloads: 62)
.png   RT Error 2.PNG (Size: 9,8 KB / Downloads: 37)
Reply

Ludo Offline
eWON Support
#5
(12-04-2017, 10:02 PM)insyncs Wrote: Hi, 

Trying this code. I haven't put an sd card in yet, so wanted to see if there were any errors.  is all the code supposed to be in the init section? do i need to add the tags?

see attached picture.

I inserted a card and got similar errors, see second pic.

Cheers M

Hey Marcus,

Could you let us know what is the firmware version of your eWON?

For testing purpose, you don't have to necessarily create tags (the generated file will simply be void of any tag values).
And yes, the code should go inside the Init section.
Reply

insyncs Offline
Member
#6
Hi Ludo,

Using the latest version V12.0s1

Cheers M
Reply

Ludo Offline
eWON Support
#7
(13-04-2017, 05:52 PM)insyncs Wrote: Hi Ludo,

Using the latest version V12.0s1

Cheers M

Marcus,

On line 98, there seems to be an "S" character at the beginning of the line.
It shoud be (and only be)


Quote:  CurID% = GETSYS Prg,"EVTINFO" : REM Get ActionID

On line 84, the second variable is wrongly written. You need to add a space between "Val" and "SDCardSize$". It should be:

Quote:SDCardSize_Int% = Val  SDCardSize$


Hope this helps to get your code working Smile
Reply

Controls2347 Offline
Junior Member
#8
Hi,

I have copied the above code and it appears to be creating a data report on the SD card however the reports do not contain any of the tags that we have set up to log.

If I go into the historical logging table then I can see all my tags but they are not in the data reports on the card.

How do I get the tags to record onto the card?

Regards

Chris
Reply

simon Offline
eWON Support
#9
It is maybe à time issue... Try to delete thé file tms.dat and restart the script
Reply

Controls2347 Offline
Junior Member
#10
Hi Simon,

I tried that but it doesn't seem to have made a difference.

Attached is the tag list we have setup and the report it generated on the SD card.

Am I missing something really simple here?


Attached Files
.png   Tags.PNG (Size: 114,57 KB / Downloads: 40)
.png   data log.PNG (Size: 90,26 KB / Downloads: 44)
Reply

simon Offline
eWON Support
#11
The data are well there.
I think you were expecting to get tagnames inside while the tag Id is used because we export historical logging and not historical table.
Replace $dtHL by $dtHT in the export block descriptor used in the script.
Reply

Josh Offline
Member
#12
Hi Simon,

I like this idea of using the SD card to store reports of data but it would be much more useful in our application if we could simply expand the "1,000,00 data points of storage" with the SD card. Is there a reason we wouldn't be able to tell the eWON to use the SD card as the place to store data in real time?

Thanks!
Josh
Reply

simon Offline
eWON Support
#13
Josh,

This is indeed not available for the moment. We have developed the EUM feature because we saw it as a good value for the Flexy.
Could you tell me why you need more than 1.000.000 records ? Why keeping so much data in the Flexy ? Don't you push these data to a server ?
Reply

rmac Offline
Junior Member
#14
(27-01-2017, 04:39 PM)simon Wrote: Hi guys,

As of the firmware 12.1s2, you can extend the Usr memory of your eWON by using a SD card (aka EUM card).

One of the use case is to store historical data reports on this memory extension.  You'll then be able to retrieve them by using your FTP client.

Here is an example of how to generate these historical data reports on an incremental way (to paste in the init section) :

Code:
CLS
REM GENERATE REPORT EVERY HOUR
ONDATE 1,"0 * * * *","GOTO GENERATE_REPORT"
ONSTATUS "GOTO SCHEDULEDACTION_END"
GOTO GENERATE_REPORT
END


GENERATE_REPORT:
//Check if SD card is inserted or if there is enough space
SETSYS INF,"LOAD"
SDCardSize$ = GETSYS INF, "SDExtFree"
SDCardSize_Int% = Val  SDCardSize$
IF SDCardSize_Int% > 5000 THEN   // 5 MB remains
  GOSUB READ_LASTTMS
  LAST_TIME$ = @GetCurrentTimeStamp$()
  EBD_STRING$ = "$dtHL$ftT$et" + LAST_TIME$ + "$st" + LASTTMS$
  FILENAME$ = "/usr/sdext/DataReport" + LAST_TIME$ + ".txt"
  WRITEEBD  EBD_STRING$, FILENAME$
  ActionID% = GETSYS Prg, "ACTIONID"
ELSE
 LOGEVENT "EUM Card full or not present", -1
ENDIF
END

SCHEDULEDACTION_END:
  CurID% = GETSYS Prg,"EVTINFO" : REM Get ActionID
   REM : Check if it is the right schedule action to save last timestamp otherwize do nothing
   If ActionID% = CurID% THEN
     SETSYS Prg, "ACTIONID", CurID%
     CurID_Status% = GETSYS Prg,"ACTIONSTAT"
     REM Action successfully done --> Write last timestamp in file
     IF CurID_Status% = 0 THEN
       LOGEVENT "FILE " + FILENAME$ + " SUCCESSFULLY EXPORTED", 100
       @WRITETMS(LAST_TIME$)
     ELSE
       LOGEVENT "FILE " + FILENAME$ + " NOT SUCCESSFULLY EXPORTED", 0
     ENDIF
   ENDIF
END

READ_LASTTMS:
SETSYS PRG,"RESUMENEXT",1
 REM GET LAST TIMESTAMP
OPEN "file:/usr/tms.dat" FOR BINARY INPUT AS 1
  LASTTMS$ = GET 1,15
CLOSE 1

Cur_Err% = GETSYS PRG,"LSTERR"
 
IF Cur_Err% = 33 THEN //REM File does not exist
  LASTTMS$= "01011970_000000"
  SETSYS PRG,"LSTERR",0
ENDIF

SETSYS PRG,"RESUMENEXT",0
CLS

RETURN

FUNCTION WriteTMS($LastTimeStamp$):
OPEN "file:/usr/tms.dat" FOR BINARY OUTPUT AS 1
  PUT 1,$LastTimeStamp$
CLOSE 1
ENDFN

FUNCTION GetCurrentTimeStamp$()
REM TIME$ = 19/12/2014 10:03:01
$EWON_TIME$ = TIME$
$GetCurrentTimeStamp$ = $EWON_TIME$(1 To 2) + $EWON_TIME$(4 To 5) + $EWON_TIME$(7 To 10) + "_" + $EWON_TIME$(12 To 13) + $EWON_TIME$(15 To 16)+ $EWON_TIME$(18 To 19)
ENDFN


Simon, 
This is an old thread, but Im curious about the first part of the script.

CLS
REM GENERATE REPORT EVERY HOUR
ONDATE 1,"0 * * * *","GOTO GENERATE_REPORT"
ONSTATUS "GOTO SCHEDULEDACTION_END"
GOTO GENERATE_REPORT
END


GENERATE_REPORT:
//Check if SD card is inserted or if there is enough space
SETSYS INF,"LOAD"

What is the purpose of having these two lines: 

GOTO GENERATE_REPORT
END

... right after ONSTATUS "" and before the beginning of the GENERATE_REPORT procedure description?
Reply

simon Offline
eWON Support
#15
Hi,

Indeed you are right. These two lines are useless :-)
Good point !

Simon
Reply



Possibly Related Threads…
  Export Block Data Started by dlong0
2 Replies - 14 Views
3 hours ago
Last Post: dlong0
14-02-2020, 06:05 PM
Last Post: simon
13-11-2019, 12:43 PM
Last Post: simon
15-05-2019, 09:49 PM
Last Post: Bernd
01-02-2019, 05:11 PM
Last Post: simon
30-01-2019, 01:31 PM
Last Post: samore
  Send Report via Email Started by mtappa
1 Replies - 1.635 Views
13-12-2018, 04:45 PM
Last Post: ziozetti
28-11-2018, 01:44 PM
Last Post: simon
17-11-2018, 03:30 PM
Last Post: schlottke
  Creating User Started by jhartnett
2 Replies - 1.366 Views
20-07-2018, 03:58 PM
Last Post: jhartnett



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy