• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

state.time what Meta Command object model property type is it?

Scheduled Pinned Locked Moved
Tuning and tweaking
3
6
413
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    JD
    last edited by JD 26 Aug 2020, 09:04

    I'm experimenting with the object model and meta commands in a gcode file.

    When performing the following object model property (date/time) request from a terminal...

    M409 K"state.time"

    the response is

    {"key":"state.time","flags":"","result":"2020-08-26T18:08:25"}

    However, if i have a Gcode file with:

    if state.time == "2020-08-26T17:29:39"
    M117 state.time processed

    an error is returned: meta command: cannot convert operands to same type

    I don't think i've muffed up the formatting assuming state.time is a string. Other meta command string comparisons in the object model work ok.

    state.time won't compare to any string which makes me suspect that for meta commands, state.time is not actually a string? is it perhaps a variable type that meta commands are not able to compare against?

    other idle thoughts......
    I understand reasons to keep the date and time together in one property but it would also be nice to have the option to obtain just the time or just the date.

    If state.time were a string (not behaving like one though?) it would be nice for the meta commands to include some string modifier/parser to be able to specify a character in the string or compare from some offset.

    JD

    1 Reply Last reply Reply Quote 0
    • undefined
      dc42 administrators
      last edited by 26 Aug 2020, 15:49

      This has come up on the forum before. state.time has a special type Date, which like other types can be converted to string. You can force the conversion by concatenating it with an empty string:

      if state.time ^ "" == "2020-08-26T17:29:39"

      Duet WiFi hardware designer and firmware engineer
      Please do not ask me for Duet support via PM or email, use the forum
      http://www.escher3d.com, https://miscsolutions.wordpress.com

      1 Reply Last reply Reply Quote 0
      • undefined
        JD
        last edited by JD 27 Aug 2020, 07:31

        Thanks for the prompt reply.
        I had to surround the concatenated expression with braces otherwise i got an error regarding non boolean expressions.

        The following works ok:

        M117 Start						;message indicating gcode begin
        while {state.time ^ ""} != "2020-08-27T15:21:00"   	;while the current machine time is not equal to a "future time" execute the next indented lines then loop back to this line
         G4 P50                         		        ;dwell for 50 milliseconds 
        M117 The time is now 2020-08-27T15:21:00		 ;if we reach this line it means the machine time and "future time" strings were equal
        G4 S4							 ;dwell for 4 seconds
        

        If i think of it later I'll join the dozuki wiki and add some notes
        JD

        1 Reply Last reply Reply Quote 0
        • undefined
          dc42 administrators
          last edited by 27 Aug 2020, 12:13

          I guess I need to support adding/subtracting integers to/from times, and subtracting one time from another too.

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          undefined 1 Reply Last reply 30 Mar 2022, 12:47 Reply Quote 0
          • undefined
            hareshPrajapati @dc42
            last edited by 30 Mar 2022, 12:47

            @dc42 said in state.time what Meta Command object model property type is it?:

            I guess I need to support adding/subtracting integers to/from times, and subtracting one time from another too.

            Is that any support for adding/subtracting integers to/from times
            or any method to do it?

            undefined 1 Reply Last reply 30 Mar 2022, 12:54 Reply Quote 0
            • undefined
              dc42 administrators @hareshPrajapati
              last edited by 30 Mar 2022, 12:54

              @hareshprajapati yes it should work in RRF 3.4.0.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA