Ankündigung

Einklappen
Keine Ankündigung bisher.

Python syntax

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Warichet
    antwortet
    The Baustein is (finally) working.
    I use it to display the status of the A/D converter and the thermostat (RTR).

    Thanks to all for their kind help
    If someone wants to play the beta tester, he is welcome.

    Einen Kommentar schreiben:


  • makki
    antwortet
    Zitat von Warichet Beitrag anzeigen
    Maybe a pointer to it ?
    http://www.python.org/download/
    Just download the Windows binarys, this includes the "idle shell". perfect for testing..

    Makki

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von MarcNaroska Beitrag anzeigen
    I think this is only used for the iKO and not for the internal variables used by the Bausteine.
    OK, that might be a coherent explanation, indeed.
    I must admit I totally missed this aspect of the problem.

    Do you know of other "specialities" and "pit fall" ? before I discover them all , one by one .

    Thank you.

    Einen Kommentar schreiben:


  • MarcNaroska
    antwortet
    But I was referring to the
    Experte/Stammdaten/Kommunikationsobjekte/Intern
    and there, the "Status byte" is defined as "8-Bit (0..255/EIS 2,6)". Isn't that an integer ?. Also, the title of the line is "Datentyp", sooo
    Thats right, but I think this is only used for the iKO and not for the internal variables used by the Bausteine. Its a little bit like the "Variant" type in VB...

    Well, I'm collecting a terrific amount of experience these days
    I know what you experience with getting this kind of experience...

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von MarcNaroska Beitrag anzeigen
    As far as I know you only define inputs and outputs of a Baustein as numerical or alphanumerical.
    That's perfectly correct
    But I was referring to the
    Experte/Stammdaten/Kommunikationsobjekte/Intern
    and there, the "Status byte" is defined as "8-Bit (0..255/EIS 2,6)". Isn't that an integer ?. Also, the title of the line is "Datentyp", sooo

    Zitat von MarcNaroska Beitrag anzeigen
    I'm sorry for my last post where I forgot the INT()
    No problem . Thank you for the kind help, anyway.

    Zitat von MarcNaroska Beitrag anzeigen
    Nevertheless, as long as it works now, don't worry about the why...
    Oh well, I've a strong tendency to worry a bit and I'm willing to gain some experience with this #@$& stuff.
    Someone said:
    Experience is the sum of all errors
    Well, I'm collecting a terrific amount of experience these days

    Einen Kommentar schreiben:


  • MarcNaroska
    antwortet
    Hey Raymond!

    As far as I know you only define inputs and outputs of a Baustein as numerical or alphanumerical. Maybe all numerical variables are internally declared as double...

    I'm sorry for my last post where I forgot the INT(), but I didn't had a look into my Baustein where I used this and wrote it just from memory...

    Nevertheless, as long as it works now, don't worry about the why...

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von Taxus Beitrag anzeigen
    please use

    5012|0|"((int(EN[9]) & 1)==1)"|"EN[1]"|""|1|0|0|0
    Mmm, you are right.
    It works
    Still confused, why casting an integer that is already declared as an integer, 0-255 ?
    I guess this is a lesson from experience ?

    Thank you

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von Taxus Beitrag anzeigen
    you have at least 9 input-pins?
    Yes. Anyway, the Experte would complain if the number of declared inputs doesn't match.
    I want to translate a status byte into the clear text equivalent of each status bit set to 1 (see picture below).
    At input Pin 9, I get the unknown status, Byte, 0-255
    At input Pins 1-8, I fil-in the meaning of each bit, static 14Byte text
    At output Pins 1-8, I collect the clear text, according to the bits set in the status byte. Rather simple, no ?

    Zitat von Taxus Beitrag anzeigen
    5012|0|"((int(EN[9]) & 1)==1)"|"EN[1]"|""|1|0|0|0
    I thought about it for a while, but I'm pretty sure it's an integer. Maybe I should cast it to force the type integer ? But why ? it has been declared as type integer.

    Zitat von makki Beitrag anzeigen
    in the unlikely case you don't do this already:
    Bingo !

    Zitat von makki Beitrag anzeigen
    install python idle shell for testing.
    Sounds very interesting, this tool for chasing the
    Maybe a pointer to it ?
    I was already looking for a tools to easy a bit the Python writing, didn't find any compatible with the situation at hand.

    Thank you.
    Angehängte Dateien

    Einen Kommentar schreiben:


  • makki
    antwortet
    And another thing, in the unlikely case you don't do this already: install python idle shell for testing. I made myself a simple textfile to paste values for EN[x] and EC[x] for testing..

    Makki

    Einen Kommentar schreiben:


  • Taxus
    antwortet
    To your primary question: please use

    5012|0|"((int(EN[9]) & 1)==1)"|"EN[1]"|""|1|0|0|0

    Einen Kommentar schreiben:


  • Taxus
    antwortet
    Sorry for asking that - you have at least 9 input-pins?

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Hi Marc,

    Zitat von MarcNaroska Beitrag anzeigen
    The solution which worked for me is:
    "((EN[9] & 1)==1)" to test if bit 1 is set
    I'm unable to make these lines work
    Code:
    5012|0|"((EN[9] & 1)==1)"|"EN[1]"|""|1|0|0|0
    5012|0|"((EN[9] & 2)==2)"|"EN[2]"|""|2|0|0|0
    Seems to be the same as yours, at least about the condition.
    Again, when I force the condition, like this,
    Code:
    5012|0|""|"EN[1]"|""|1|0|0|0
    it works. So, it has to do with the condition.
    I guess I missed something.
    Any clue ?

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von MatthiasS Beitrag anzeigen
    EC does not contain the value of the input pin! It only says that there was a new telgramm on that input pin.
    Thank you very much.
    By looking at the existing examples, I see that EC is often used in the conditional part of the expression.

    PS:
    Isn't the behaviour of the "AND" in the condition, a bit disturbing ?

    Einen Kommentar schreiben:


  • MatthiasS
    antwortet
    No, it is not.

    Example:

    EC[1]| EN[2] + en[3] | |..|4

    This says:

    If you have a telegramm on pin 1 (maybe a minute trigger), then send the sum of EN 2 and EN 3 to outpu no. 4

    EC does not contain the value of the input pin! It only says that there was a new telgramm on that input pin.

    Einen Kommentar schreiben:


  • Warichet
    antwortet
    Zitat von Taxus Beitrag anzeigen
    EC[m] tells you, that the logic module has been triggered by a telegramm arriving at pin number m, and
    EN[m] tells you the value of the telegramm.
    ûh
    Still confused
    Can you tell me when to use the one or the other ?

    Maybe it's more appropriate to use EC[m] for variable inputs ? as it does 2 things at a time: it says:
    1) a telegramm has arrived at pin number m
    2) the value of that telegramm

    Is that correct ?

    Einen Kommentar schreiben:

Lädt...
X