kopia lustrzana https://github.com/jbruce12000/kiln-controller
- add startat parameter to profile runs to allow for restarting at any point in a run. handle power outages, accidently hitting stop button etc.
rodzic
c32b6970ca
commit
5e5abe5b32
7
api.md
7
api.md
|
@ -1,2 +1,9 @@
|
|||
# start a run
|
||||
|
||||
curl -d '{"cmd":"run", "profile":"cone-05-lo"}' -H "Content-Type: application/json" -X POST http://0.0.0.0:8081/api
|
||||
|
||||
# skip the first part of a run
|
||||
# restart the kiln on a specific profile and start at minute 60
|
||||
|
||||
curl -d '{"cmd":"run", "profile":"cone-05-lo","startat":60}' -H "Content-Type: application/json" -X POST http://0.0.0.0:8081/api
|
||||
|
||||
|
|
|
@ -51,6 +51,12 @@ def handle_api():
|
|||
wanted = bottle.request.json['profile']
|
||||
log.info('api requested run of profile = %s' % wanted)
|
||||
|
||||
# start at a specific minute in the schedule
|
||||
# for restarting and skipping over early parts of a schedule
|
||||
startat = 0;
|
||||
if 'startat' in bottle.request.json:
|
||||
startat = bottle.request.json['startat']
|
||||
|
||||
# get the wanted profile/kiln schedule
|
||||
profile = find_profile(wanted)
|
||||
if profile is None:
|
||||
|
@ -59,7 +65,7 @@ def handle_api():
|
|||
# FIXME juggling of json should happen in the Profile class
|
||||
profile_json = json.dumps(profile)
|
||||
profile = Profile(profile_json)
|
||||
oven.run_profile(profile)
|
||||
oven.run_profile(profile,startat=startat)
|
||||
ovenWatcher.record(profile)
|
||||
return { "success" : True }
|
||||
|
||||
|
|
|
@ -86,12 +86,13 @@ class Oven (threading.Thread):
|
|||
self.set_heat(False)
|
||||
self.pid = PID(ki=config.pid_ki, kd=config.pid_kd, kp=config.pid_kp)
|
||||
|
||||
def run_profile(self, profile):
|
||||
def run_profile(self, profile, startat=0):
|
||||
log.info("Running schedule %s" % profile.name)
|
||||
self.profile = profile
|
||||
self.totaltime = profile.get_duration()
|
||||
self.state = Oven.STATE_RUNNING
|
||||
self.start_time = datetime.datetime.now()
|
||||
self.startat = startat * 60
|
||||
log.info("Starting")
|
||||
|
||||
def abort_run(self):
|
||||
|
@ -108,7 +109,10 @@ class Oven (threading.Thread):
|
|||
self.runtime += 0.5
|
||||
else:
|
||||
runtime_delta = datetime.datetime.now() - self.start_time
|
||||
self.runtime = runtime_delta.total_seconds()
|
||||
if self.startat > 0:
|
||||
self.runtime = self.startat + runtime_delta.total_seconds();
|
||||
else:
|
||||
self.runtime = runtime_delta.total_seconds()
|
||||
|
||||
self.target = self.profile.get_target_temperature(self.runtime)
|
||||
pid = self.pid.compute(self.target, self.temp_sensor.temperature)
|
||||
|
|
Ładowanie…
Reference in New Issue