Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [4diac-dev] Timeliterals in Lua

On Fri, 2019-07-12 at 14:47 +0000, Martin Melik-Merkumians wrote:
> It would result in a TIME variable with a correctly calculated internal value based on FORTE timer setting. Still want to state, that this is the wrong function in my humble opinion, as it describes a conversion between IEC 61131 data types. CIEC_TIME has already the perfectly suited function called setTimeFromNanoseconds and needs no exposure of this functionality towards ST. If such a conversion would be needed in ST I would say, the design is faulty.

The member function is only suitable when you already have an object of CIEC_TIME of you don't have that you need to create one and fill it. I see this
problematic with time literals used in different expressions. Therefore the idea with the ST helper function. Which IMHO we anyhow need, and I don't care how it
is called. Because I see definitely an use case where i have some mathematical calculations (e.g., in LREAL) and the result should then be interpreted as time.

Alois


>
> Best,
> Martin
>
> Von: 4diac-dev-bounces@xxxxxxxxxxx <4diac-dev-bounces@xxxxxxxxxxx> Im Auftrag von Jan Holzweber
> Gesendet: Freitag, 12. Juli 2019 16:43
> An: alois.zoitl@xxxxxx; 4diac-dev@xxxxxxxxxxx
> Betreff: Re: [4diac-dev] Timeliterals in Lua
>
> So we should call a C-Funtcion from the Lua code?
> And what should this function exactly do? What would be the result of LINT_TO_TIME_NS(23005000000)?
>
> Cheers,
> Jan
>
> Gesendet: Freitag, 12. Juli 2019 um 16:33 Uhr
> Von: "Alois Zoitl" <alois.zoitl@xxxxxx>
> An: 4diac-dev@xxxxxxxxxxx
> Betreff: Re: [4diac-dev] Timeliterals in Lua
> Hi,
>
> On Fri, 2019-07-12 at 16:09 +0200, Jan Holzweber wrote:
> > I also do not understand why we would need this function, as the time value is then just an integer. There is a time representation in Lua, but i would not use it for just the timespan, because it also always needs a day/month/year. For the timespan i would have just used a number variable.
>
> The problem how see is the following. Lets take a simple ST example
>
> VAR
> buf : TIME;
> END_VAR;
>
> ...(*some if or so here*)
> buf := T23s5ms;
>
>
> what code should be generated. Taken your discussion from above it would be the best if the Lua code generator would take the time literal and calculate an
> integer in ns out if it. But the lua code can not be:
>
> buf = 23005000000;
>
> because the value stored in TIME in forte depends on the configuration of FORTE's time base. So for the code generator it would be the easist if we could
> generate lua code which is equivalent to:
>
> buf = LINT_TO_TIME_NS(23005000000); //or what ever function name is apprriate here
>
> which would call the approriate ST function. Similar to the function Martin has already developed for the oposite direction. This would ensure at the one hand
> that the time base is adhered and that the code generator has a simple rule.
>
> Am I missing something?
>
>
> Cheers,
> Alois
>
>
> >
> > Cheers,
> > Jan
> >
> > Gesendet: Freitag, 12. Juli 2019 um 16:05 Uhr
> > Von: "Martin Melik-Merkumians" <Melik-Merkumians@xxxxxxxxxxxxxxxxx>
> > An: "alois.zoitl@xxxxxx" <alois.zoitl@xxxxxx>, "4diac developer discussions" <4diac-dev@xxxxxxxxxxx>
> > Betreff: Re: [4diac-dev] Timeliterals in Lua
> > I am not sure what this function should do you propose. If TIME and the Lua representation will save the time value in nanoseconds, the value should be simply copy-able? Or do I miss some detail?
> >
> > Thinking about it, will there be even a separate Lua representation? As far as I remember reading about Lua interpreters, the TIME datatype should be accessible and somehow useable via Lua anyhow?
> >
> > Best,
> > Martin
> >
> > -----Ursprüngliche Nachricht-----
> > Von: 4diac-dev-bounces@xxxxxxxxxxx <4diac-dev-bounces@xxxxxxxxxxx> Im Auftrag von Alois Zoitl
> > Gesendet: Freitag, 12. Juli 2019 15:58
> > An: 4diac-dev@xxxxxxxxxxx
> > Betreff: Re: [4diac-dev] Timeliterals in Lua
> >
> >
> > > we have a similar discussion currently running in
> > > https://bugs.eclipse.org/bugs/show_bug.cgi?id=549172
> > > I would suggest for ease of use and consistency to save all TIMEs in nanosecond resolution. Interactions between LUA and C code will be than easiest to implement.
> >
> > I was not sure about it but find it a good idea. However to make code generation easier and also more consistent / independent from FORTE configurations I think would should provide a function like LINT_TO_TIME_IN_NS which can then be uitlized by Jan.
> >
> > What do you think?
> >
> > Cheers,
> > Alois
> >
> >
> > >
> > > Best
> > > Martin
> > >
> > > Von: 4diac-dev-bounces@xxxxxxxxxxx <4diac-dev-bounces@xxxxxxxxxxx> Im
> > > Auftrag von Jan Holzweber
> > > Gesendet: Freitag, 12. Juli 2019 14:11
> > > An: 4diac-dev@xxxxxxxxxxx
> > > Betreff: [4diac-dev] Timeliterals in Lua
> > >
> > > Hello All!
> > >
> > > I have a question regarding time and in which unit we should convert time literals from structured text into lua variables.
> > > I already talked with Alois about this. He said in CPP he would do somethink like: CIEC_TIME().fromNanoSeconds(60E9). Should we aim to convert all times also into nanoseconds in Lua or should we do a different approach?
> > >
> > > Cheers,
> > > Jan
> > >
> > > _______________________________________________
> > > 4diac-dev mailing list
> > > 4diac-dev@xxxxxxxxxxx
> > > To change your delivery options, retrieve your password, or
> > > unsubscribe from this list, visit
> > > https://www.eclipse.org/mailman/listinfo/4diac-dev
> >
> > _______________________________________________
> > 4diac-dev mailing list
> > 4diac-dev@xxxxxxxxxxx
> > To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/4diac-dev
> > _______________________________________________
> > 4diac-dev mailing list
> > 4diac-dev@xxxxxxxxxxx
> > To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> > https://www.eclipse.org/mailman/listinfo/4diac-dev
> > _______________________________________________
> > 4diac-dev mailing list
> > 4diac-dev@xxxxxxxxxxx
> > To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> > https://www.eclipse.org/mailman/listinfo/4diac-dev
>
> _______________________________________________
> 4diac-dev mailing list
> 4diac-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/4diac-dev
> _______________________________________________
> 4diac-dev mailing list
> 4diac-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/4diac-dev



Back to the top