Ankündigung

Einklappen

(KI-) Softwarelösungen

Um die Flut an (primär KI-erzeugter) Software zu kanalisieren, sind solche Lösungen ab sofort im Unterforum "Codeschnipsel" einzustellen. Bereits gepostete Themen werden sukzessive dorthin verschoben.
Mehr anzeigen
Weniger anzeigen

X1 Logic Node: Scripting - One block. Endless possibilities.

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

    #16
    Zitat von willisurf Beitrag anzeigen
    Is there a small copy&paste error in the string examples?
    Code:
    OUT1 = IN1.toString().substring(0, 5); // Take the first 5 characters (start at character 0)
    
    OUT1 = IN1.toString().substring(0, 5); // Trim spaces​

    you are right! The last one should be:
    PHP-Code:
    OUT1 = IN1.toString().trim(); 
    
    ​I will correct the examples. Thanks!

    Kommentar


      #17
      Thx for the great work i really like your Logic Node, but i am facing the problem with syntax error while using python.

      I'm using your script converter from multli-line to single-line and paste it into GPA.

      Here is my example:
      Input:
      import time

      now = time.time()​​
      if 'running' not in STATE:
      STATE['running'] = 0​
      Output:
      import time now = time.time() if 'running' not in STATE: STATE['running'] = 0
      GPA Error:
      Script error: SyntaxErrorException: unexpected token 'now'


      Is it only me or is it a common issue?
      Thanks!

      Kommentar


        #18
        Zitat von shindig632 Beitrag anzeigen
        Thx for the great work i really like your Logic Node, but i am facing the problem with syntax error while using python.

        I'm using your script converter from multli-line to single-line and paste it into GPA....

        Thanks!

        Thanks for the example, shindig632. The old converter joined the import, assignment and if statement with spaces. My original workaround also contained a syntax error: Python 2.7 does not allow a compound if statement after a semicolon.

        Here is a one-line version you can paste straight into the Python Script field on X1. For this test, configure one output. OUT1 shows 0 on the first trigger and keeps the stored value on later triggers.
        Code:
        exec("import time\nnow = time.time()\nif 'running' not in STATE:\n    STATE['running'] = 0\nOUT1 = STATE['running']")
        The \n sequences recreate the line breaks. The four spaces keep the assignment inside the if block. For longer scripts, keep the multiline original and use the Scripting editor to generate the line for GPA.
        Zuletzt geändert von Roeller; Gestern, 14:03.

        Kommentar


          #19
          Very impressive.

          Kommentar


            #20
            Roeller

            Hey, I had a problem on the X1 where other modules stopped working (using your v.0.2.000000)​. For example, the Fritzbox check (HostCheck) stopped working, but no error message was displayed.

            Kommentar


              #21
              Zitat von Sweeny Beitrag anzeigen
              Roeller

              Hey, I had a problem on the X1 where other modules stopped working…
              any news here Roeller ?

              Kommentar


                #22
                Hi Roel,
                First of all, thank you for your great Scripting Logic Node! We are currently using v0.2.000000 in GPA 6.1 on a Gira X1 running Firmware 4.0.350 and trying to send simple ASCII strings via UDP (172.18.227.118:6553) to control a ChamSys MagicQ lighting controller.
                Unfortunately, we hit a roadblock with all three scripting languages on X1 FW 4.0.350:
                1. Python 2.7 (import socket):
                  • The project check and upload succeed without errors.
                  • When triggered on the X1, the node fails immediately and outputs to Error Text:
                    Error running script: python.exe, PID=2180
                  • It seems X1 Firmware 4.0.350 blocks or fails to start/communicate with the external Python worker process.
                2. Lua 5.4 (require("socket")):
                  • Fails already during the GPA project check with:
                    LuaScriptException: [string "script"]:1: module 'socket' not found (missing socket.lua / socket.dll / socket54.dll in the node package).
                3. JavaScript (System.Net.Sockets.UdpClient):
                  • Runs natively and fast on the X1, but direct access to .NET socket classes is blocked in the Jint sandbox (Script error: System is not defined).
                Question:
                Is there a known workaround to run Python on X1 Firmware 4.0.350, or is there a built-in helper function in JavaScript/Lua within your node to send raw UDP packets?
                Thanks in advance for your help!
                Best regards,
                Christoph
                ​

                Kommentar


                  #23
                  Hi Roeller this is awesome. But I am failing at the very beginning: I am unable to copy-paste a multi-line code into the "Script" field in GPA 6.1. It only keeps the first line of the copied block. Also if i copy the example code already in the block, it only keeps the first line when i paste it.
                  The work-around is to convert it to one-liner Base64
                  Code:
                  import zlib,base64;exec(zlib.decompress(base64.b64decode("eN.....
                  . but that is a lot of extra effort and complication.

                  What am I doing wrong?

                  Kommentar


                    #24
                    Good morning, Roeller ,

                    Your scripting logic is truly a sensational approach to generating logical content with “a single” block. Kudos for that—and you're also showing just what's possible with the “little machine.”

                    It would certainly be more than helpful if you could also describe what the “development environment” should look like for the user..... :-)
                    I hardly think that the average X1 user writes their “working” code block in a text editor and simply pastes it in. So, for most people, using Visual Studio Code—with the appropriate environment configuration (C# Dev Kit, etc.)—will be a helpful workaround.

                    Perhaps you could add a description of what the minimal test/development environment should look like?


                    Best regards and thanks to you for your dedication to the X1, André

                    Kommentar


                      #25
                      Hi Roeller ,

                      The topic of “triggers” has already been discussed elsewhere here, and you solved it with a simple “double” link.
                      However, this doesn't work in my case...

                      I want to convert a total of 38 data points into JSON and then send them to an API endpoint. Since the script logic is only triggered when the trigger is activated, I’d have to add all 38 data points to the trigger input as well.

                      I don’t think that’s a great solution, and maybe in one of the next versions you could add the option to set the inputs to “listen” mode.

                      Best regards, André




                      Hallo Roeller,

                      An anderer Stelle hier wurde ja schon das Theme "Trigger" angesprochen und Du hast es mit einem einfachen "doppelten" Verknüpfen gelöst.
                      In meinem Versuch funktioniert dies allerdings nicht.....

                      Ich möchte insgesamt 38 Datenpunkte in ein JSON wandeln und dann an einen API-Endpunkt senden. Die Script Logik wird ja nur beim Trigger ausgelöst; somit müsste ich alle 38 Datenpunkte zusätzlich auf den Trigger-Eingang legen.

                      Ich halte das für keine schöne Lösung und vielleicht hast Du für eine der nächsten Versionen die Möglichkeit die Eingänge optional "hörend" zu stellen.

                      Grüsse André

                      Kommentar

                      Lädt...
                      X