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

  • 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


    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.


  • administrators

    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"

  • 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

  • administrators

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

Log in to reply