File tree Expand file tree Collapse file tree 7 files changed +37
-1
lines changed
Expand file tree Collapse file tree 7 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ nothrow @nogc:
3636
3737 Session session;
3838 Command command;
39- CommandCompletionState state;
4039
4140 this (Session session, Command command)
4241 {
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ nothrow @nogc:
9797 console.registerCommand! uptime(" /system" , this );
9898 console.registerCommand! sysinfo(" /system" , this );
9999 console.registerCommand! show_time(" /system" , this , " time" );
100+ console.registerCommand! sleep(" /system" , this );
100101
101102 console.registerCommand! device_print(" /device" , this , " print" );
102103
Original file line number Diff line number Diff line change @@ -106,6 +106,33 @@ void show_time(Session session)
106106 session.writeLine(getDateTime());
107107}
108108
109+ auto sleep (Session session, Duration duration)
110+ {
111+ import manager.console.command : CommandCompletionState;
112+ import manager.console.function_command : FunctionCommandState;
113+
114+ static class SleepCommandState : FunctionCommandState
115+ {
116+ nothrow @nogc :
117+ MonoTime wake_time;
118+
119+ this (Session session, Duration duration)
120+ {
121+ super (session);
122+ wake_time = getTime() + duration;
123+ }
124+
125+ override CommandCompletionState update ()
126+ {
127+ if (getTime() >= wake_time)
128+ return CommandCompletionState.Finished;
129+ return CommandCompletionState.InProgress;
130+ }
131+ }
132+
133+ return defaultAllocator ().allocT! SleepCommandState(session, duration);
134+ }
135+
109136// Helper function to format bytes with appropriate unit
110137private auto format_bytes (ulong bytes) nothrow @nogc
111138{
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ nothrow @nogc:
5151 {
5252 nothrow @nogc :
5353
54+ CommandCompletionState state = CommandCompletionState.InProgress;
55+
5456 this (Session session)
5557 {
5658 super (session);
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ nothrow @nogc:
6767 static class HTTPRequestState : FunctionCommandState
6868 {
6969 nothrow @nogc :
70+
71+ CommandCompletionState state = CommandCompletionState.InProgress;
72+
7073 HTTPClient client;
7174
7275 this (Session session)
Original file line number Diff line number Diff line change @@ -363,6 +363,8 @@ class RequestState : FunctionCommandState
363363{
364364nothrow @nogc :
365365
366+ CommandCompletionState state = CommandCompletionState.InProgress;
367+
366368 String slave;
367369
368370 this (Session session, const (char )[] slave)
Original file line number Diff line number Diff line change @@ -272,6 +272,8 @@ class RequestState : FunctionCommandState
272272{
273273nothrow @nogc :
274274
275+ CommandCompletionState state = CommandCompletionState.InProgress;
276+
275277 EZSPClient client;
276278 bool finished = false ;
277279
You can’t perform that action at this time.
0 commit comments