Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Writing CSV File Using CSVWriter
Writing CSV File Using CSVWriter [message #1817284] Tue, 19 November 2019 23:01 Go to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
How to write CSV file using CSVWriter?

I get the following error when I try it:

ERROR: T#2072284331816: [GEN_CSV_WRITER]: Can't write to file /home/nughii/4diac-ide/datacsv/datacsv.csv since it is not opened



Thank you
  • Attachment: csv.png
    (Size: 252.62KB, Downloaded 19 times)
Re: Writing CSV File Using CSVWriter [message #1817298 is a reply to message #1817284] Wed, 20 November 2019 07:43 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 185
Registered: February 2016
Senior Member
you need to trigger the INIT event once before the REQ
Re: Writing CSV File Using CSVWriter [message #1817341 is a reply to message #1817298] Wed, 20 November 2019 16:44 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
Please be aware to correctly save teh file you need at the and of your cvs writing also an init with QI := FALSE to correctly close the file. Otherwise you may loos data.
Re: Writing CSV File Using CSVWriter [message #1817997 is a reply to message #1817341] Wed, 04 December 2019 05:47 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Thank you very much
Re: Writing CSV File Using CSVWriter [message #1823200 is a reply to message #1817997] Sun, 22 March 2020 09:47 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Hi, I want to write FB's output into csv file. There is an error like this:
ERROR: T#29539802521: Event queue is full, event dropped!


This is the screenshoot of my app:
index.php/fa/37637/0/

I have set the
 FORTE_EventChainEventListSize = 256000
and
 FORTE_EventChainExternalEventListSize = 1000000
.
Is there any solution to overcome this?
Thank you
Re: Writing CSV File Using CSVWriter [message #1823205 is a reply to message #1823200] Sun, 22 March 2020 15:28 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 185
Registered: February 2016
Senior Member
Hi,
your FB pv_v2 is generating a lot of output events (618456 * 2) in less than a second. You probably have a loop inside of it somewhere that's outputing events but it's too fast that the events can be processed
Re: Writing CSV File Using CSVWriter [message #1823206 is a reply to message #1823205] Sun, 22 March 2020 17:16 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
Hi, to add to Jose's observation: I function block MUST NOT BLOCK!! As we can clearly see in your screenshot you have one two input event occurences (i.e., one to each: INIT, REQ) and then many output events. However the CVS writer does not get even a single input event delivered (except for the INIT). This is a clear sign that there is an issue within your pv_v2.
Re: Writing CSV File Using CSVWriter [message #1823268 is a reply to message #1823206] Tue, 24 March 2020 05:25 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Yes, there is a loop inside the FB. I want to check the algorithm by recording the loop algorithm output into a CSV file.

This is the ECC in the algorithm:
index.php/fa/37646/0/
  • Attachment: ecc_pv_v2.PNG
    (Size: 30.52KB, Downloaded 119 times)

[Updated on: Tue, 24 March 2020 05:49]

Report message to a moderator

Re: Writing CSV File Using CSVWriter [message #1823274 is a reply to message #1823268] Tue, 24 March 2020 08:14 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
This is not a valid IEC 614999 ECC. IEC 61499 clearly states that the invocation of an FB caused by an input event has to be algorithmic and end in a short amount of time. Furthermore IEC 61499 will not update any FB inputs without an input event so your algorithms will work on the same data all the time. In order that your algorithm works you need to close the loop outside of the FB (e.g., with an E_CYCLE FB regularly triggering the calculations).

If you wonder why this is the case: IEC 61499 targets reactive real-time systems. In such systems blocking operations are not permitted. this is similar to PLC programming with IEC 61131-3. There you have an implicit execution invocation from tasks (mostly cyclic). But in both you always have to react.
Re: Writing CSV File Using CSVWriter [message #1823500 is a reply to message #1823274] Fri, 27 March 2020 15:31 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Thank you for your advice. Now my FB is working properly.
-
Next I want to ask again. I conducted two CSV writing experiments.
1. I write csv using T # 0.99s on E_CYC.
2. I write csv using T # 1s or T # 1000ms on E_CYC.

The result:
1. Experiment 1, the data can be recorded in the data.csv file.
2. Experiment 2, the data is not recorded in the data1s.csv file.

index.php/fa/37678/0/

How to record data with a cycle of 1 second?

Re: Writing CSV File Using CSVWriter [message #1823509 is a reply to message #1823500] Fri, 27 March 2020 18:49 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
First of all please note that your 0.99s E_Cycle runs not on 0.99s it runs on 0ms because 0.99s is not a correct Time literal.

Secondly, the CVS_WRITER block will not close the file until you send it a second INIT event with QI set to false. This follows the IEC 61499 rules for SIFBs where an INIT(QI=TRUE) means initialization (in our case open file) INIT(QI=FALSE) means de-initialization (in our case close the file). Depending on your operating system and C library it may take some time until the data writen by the CVS_WRITER is arriving in your file.

In your left-case where you are writing a value very 1ms this happens much earlier then on the left where you are writing only every second. But eventually also here data will be in the file. To be perfectly sure and correct you should close the file (i.e., INIT(QI=FALSE)) when you are done with your writing.
Re: Writing CSV File Using CSVWriter [message #1823520 is a reply to message #1823509] Sat, 28 March 2020 04:28 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Thank you very much for the explanation...
Re: Writing CSV File Using CSVWriter [message #1823575 is a reply to message #1823520] Sun, 29 March 2020 12:02 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Hi...
I want to ask again...
Is it possible to generate event less than 1ms using E_CYCLE ?
Re: Writing CSV File Using CSVWriter [message #1823576 is a reply to message #1823575] Sun, 29 March 2020 12:29 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
In principle yes. However your results may vary a lot depending on the OS you are using.

In 4diac FORTE you can set the CMake option FORTE_TicksPerSecond (you can find it in the advanced section). Be increasing this number you may get a higher resolution for your E_CYCLES. Please be aware that this also greatly increases CPU resources consumed by the timer handling code in 4diac FORTE. If you only have one or two such high demanding timed events it may makes sense to write own SIFBs for that part.

BR,
Alois
Re: Writing CSV File Using CSVWriter [message #1823577 is a reply to message #1823576] Sun, 29 March 2020 13:06 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Ok, I have change FORTE_TicksPerSecond becomes 1000000.
How to write DT correctly? I tried writing DT = T#0.1ms, but E_CYCLE seemed to produce events slower than DT = T#1ms. I want to try to generate events every 1 microsecond.

[Updated on: Sun, 29 March 2020 13:13]

Report message to a moderator

Re: Writing CSV File Using CSVWriter [message #1823578 is a reply to message #1823577] Sun, 29 March 2020 13:19 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
What operating system are you on? If it is windows I would not expecting anything below 10ms.
Re: Writing CSV File Using CSVWriter [message #1823581 is a reply to message #1823578] Sun, 29 March 2020 14:12 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
I use windows. What if I use linux (manjaro) or raspbian?
Re: Writing CSV File Using CSVWriter [message #1823582 is a reply to message #1823581] Sun, 29 March 2020 15:13 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Update:
I tried to change FORTE_TicksPerSecond to 1. Then, I set the value DT = T # 1000s. When the application is deployed, the monitor displays a DT value of T# 1000000ms. I feel that the speed of E_CYCLE produces events is equivalent to 1 event / second.
index.php/fa/37692/0/

  • Attachment: t#.PNG
    (Size: 6.47KB, Downloaded 53 times)

[Updated on: Sun, 29 March 2020 15:29]

Report message to a moderator

Re: Writing CSV File Using CSVWriter [message #1823584 is a reply to message #1823582] Sun, 29 March 2020 16:02 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
For anyhting higher then app. 10ms E_CYCLE very accurate on most OSs. I don't know how the sitation is different on Linux. However I think that for anything below 1ms special code is needed anyhow.
Re: Writing CSV File Using CSVWriter [message #1823585 is a reply to message #1823584] Sun, 29 March 2020 16:45 Go to previous messageGo to next message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
What kind of special code needs to be added? Are there any articles that explain this kind of thing? If so, I hope I can mimic the steps to add special codes like that.
Re: Writing CSV File Using CSVWriter [message #1823586 is a reply to message #1823585] Sun, 29 March 2020 17:00 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 993
Registered: January 2014
Senior Member
Unfortunately there is not much documentation. The best documentation on the operations and architecture of 4diac FORTE is still in my book "Real-time Execution of IEC 61499". What you need to do is to develop an external event handler which provides the timed events. The external event handler would wake up your FB for generating the according output events. You can use the timer handler and E_CYCLE as an example for how to get started.

But first I think you need to find out means of getting high precision timing in C/C++. I would even recommend some experiments without 4diac FORTE first.
Re: Writing CSV File Using CSVWriter [message #1823587 is a reply to message #1823586] Sun, 29 March 2020 17:22 Go to previous message
ardianto vn is currently offline ardianto vnFriend
Messages: 31
Registered: May 2019
Member
Thanks for the explanation. I will try to learn and understand it first ...
Previous Topic:4Diac Forte and STM32
Next Topic:Validating FBOOT file by a runtime application
Goto Forum:
  


Current Time: Fri May 29 08:16:11 GMT 2020

Powered by FUDForum. Page generated in 0.06082 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top