Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
cfry committed Feb 6, 2021
1 parent fdf3bb4 commit 8d34445
Show file tree
Hide file tree
Showing 26 changed files with 857 additions and 138 deletions.
25 changes: 12 additions & 13 deletions core/dextersim.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ DexterSim = class DexterSim{
MaxSpeed: 30, //todo what are the units on dde side and on sim/dex side?
StartSpeed: 0
}
this.ready_to_start_new_instruction = true //true at beginning and when we've just completed an instruction but not started another
this.sent_instructions_count = 0
this.status = "before_first_send"
this.status_mode = 0 //can also be 1, set by "g" command.
Expand All @@ -55,7 +54,8 @@ DexterSim = class DexterSim{
this.pid_angles_arcseconds = [0,0,0,0,0,0,0]
this.velocity_arcseconds_per_second = [0,0,0,0,0,0,0]

this.now_processing_instruction = null // a Dexter can only be doing at most 1 instruction at a time. This is it.
this.ready_to_start_new_instruction = true //true at beginning and when we've just completed an instruction but not started another
this.now_processing_instruction = null // a Dexter can only be doing a move at most 1 instruction at a time. This is it.
}

static stop_all_sims(){
Expand Down Expand Up @@ -267,31 +267,32 @@ DexterSim = class DexterSim{
sim_inst.now_processing_instruction &&
(sim_inst.ending_time_of_cur_instruction <= the_now)) { //end the cur instruction and move to the next
const oplet = sim_inst.now_processing_instruction[Dexter.INSTRUCTION_TYPE]
if ((sim_inst.sim_actual === true) && [/*"F" , "G", "g"*/].includes(oplet)) { //dont do when sim == "both"
//if ((sim_inst.sim_actual === true) && [/*"F" , "G", "g"*/].includes(oplet)) { //dont do when sim == "both"
//let rs_copy = sim_inst.robot_status_in_arcseconds.slice() //make a copy to return as some subseqent call to this meth will modify the one "model of dexter" that we're saving in the instance
//rs_copy[Dexter.STOP_TIME] = Date.now() //in milliseconds
///Socket.on_receive(rs_copy, sim_inst.robot.name)
sim_inst.ack_reply(sim_inst.now_processing_instruction)
}
// sim_inst.ack_reply(sim_inst.now_processing_instruction)
//}
sim_inst.completed_instructions.push(sim_inst.now_processing_instruction)
sim_inst.now_processing_instruction = null //Done with cur ins,
sim_inst.ready_to_start_new_instruction = true
}
//hits when there's more on the queue to do
if(sim_inst.ready_to_start_new_instruction &&
(sim_inst.instruction_queue.length > 0) &&
(sim_inst.status != "closed")) {
(sim_inst.status !== "closed")) {
sim_inst.ready_to_start_new_instruction = false
sim_inst.process_next_instruction()
}
if((sim_inst.instruction_queue.length == 0) && //nothing in the queue,
(sim_inst.status == "closing")) { //and no more coming from DDE.
else if((sim_inst.instruction_queue.length == 0) && //nothing in the queue,
!sim_inst.now_processing_instruction && //we're not currently in the middle of an instruction
(sim_inst.status === "closing")) { //and no more coming from DDE.
sim_inst.ready_to_start_new_instruction = false
DexterSim.close(sim_inst.robot_name) //cleaner to set "closed" in one place.
}
if(sim_inst.status != "closed") { keep_alive = true }
if(sim_inst.status !== "closed") { keep_alive = true }
}
if ((keep_alive == false) && (window.platform == "node")) {
if ((keep_alive == false) && (window.platform === "node")) {
clearInterval(DexterSim.set_interval_id) //so that nodejs will quit
}
}
Expand Down Expand Up @@ -557,9 +558,7 @@ DexterSim = class DexterSim{
(sim_inst.now_processing_instruction == null)){
sim_inst.stop_sim() //also set near bottom of process_next_instruction
}
else { //note: now that I automatically put a "g" instruction as the automatic last instruction
//of a job's do_list, we shouldn't be getting this "closing" state because
//the "g" naturally empties the instruction_queue.
else {
sim_inst.status = "closing"
//setTimeout(function(){DexterSim.close(socket_id)}, 1000) //shouldn't be necessary.
//as process_next_instruction will handle final close in this case.
Expand Down
6 changes: 4 additions & 2 deletions core/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
global.dde_version = "3.7.2"
global.dde_release_date = "Jan 13, 2021"
global.dde_version = "3.7.3"
global.dde_release_date = "Feb 5, 2021"

console.log("dde_version: " + global.dde_version + " dde_release_date: " + global.dde_release_date +
"\nRead electron_dde/core/job_engine_doc.txt for how to use the Job Engine.\n")
Expand Down Expand Up @@ -157,6 +157,7 @@ var {html_db, is_dom_elt, make_dom_elt, make_html} = require("./html_db.js")

var {Messaging, MessStat} = require("./messaging.js")

var {Py} = require("./py.js")

// see also je_and_browser_code.js for global vars.
global.keep_alive_value = false
Expand Down Expand Up @@ -237,6 +238,7 @@ global.html_db = html_db
global.is_dom_elt = is_dom_elt
global.make_html = make_html
global.make_dom_elt = make_dom_elt
global.Py = Py


run_node_command(process.argv)
Expand Down
16 changes: 13 additions & 3 deletions core/instruction.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,27 @@ Instruction.w_address_names = [
"DIFFERENTIAL_FORCE_TIMEBASE", //"80"
"PID_TIMEBASE" //"81"
]
Instruction.w_address_number_to_name = function(num){
/*Instruction.w_address_number_to_name = function(num){
if(!Instruction.is_valid_w_address(num)) { return "unknown" }
let w_address_names = Series.id_to_series("series_w_oplet_address_id").array
if (num >= w_address_names.length) { return "unknown" }
else { return w_address_names[num] }
}*/

//returns undefined for invalid nums
Instruction.w_address_number_to_name = function(num){
return Instruction.w_address_names[num]
}

//beware: will return -1 if name is invalid
Instruction.w_address_name_to_number = function(name){
/*Instruction.w_address_name_to_number = function(name){
let w_address_names = Series.id_to_series("series_w_oplet_address_id").array
return w_address_names.indexOf(name)
}*/

//beware: will return -1 if name is invalid
Instruction.w_address_name_to_number = function(name){
return Instruction.w_address_names.indexOf(name)
}

//user might call this at top level in a do_list so make it's name short.
Expand All @@ -551,7 +561,7 @@ function make_ins(instruction_type, ...args){
warning("make_ins called with an invalid instruction_type: " + instruction_type +
"<br/>make_ins still returning an array using: " + instruction_type)
}*/
let first_arg = args[0]
//let first_arg = args[0]
/*if((instruction_type == "w") && !Instruction.is_valid_w_address(first_arg)){
dde_error('make_ins("w" ...) does not support an address of ' + first_arg +
'.<br/>Valid addresses are non-negative integers. ' +
Expand Down
16 changes: 9 additions & 7 deletions core/je_and_browser_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,15 @@ static render_show_window(properties){
//let title_id = "sw_title_" + properties.window_index + "_id"
let title_elt = show_window_elt.querySelector(".show_window_title") //window[title_id]
//onsole.log("render_show_window got title_elt: " + title_elt)
let draggable_value = (properties.draggable? "true": "false")
//onsole.log("render_show_window got draggable_value: " + draggable_value)
title_elt.onmousedown = function(event) {
event.target.parentNode.setAttribute('draggable', draggable_value) //set the whole sw window to now be draggable.
}
title_elt.onmouseup = function(event) {
event.target.parentNode.setAttribute('draggable', 'false') //set the whole sw window to now be draggable.
if(title_elt) { // won't hit if title === "" because that means no title
let draggable_value = (properties.draggable? "true": "false")
//onsole.log("render_show_window got draggable_value: " + draggable_value)
title_elt.onmousedown = function(event) {
event.target.parentNode.setAttribute('draggable', draggable_value) //set the whole sw window to now be draggable.
}
title_elt.onmouseup = function(event) {
event.target.parentNode.setAttribute('draggable', 'false') //set the whole sw window to now be draggable.
}
}
show_window_elt.ondragstart = function(event) {
let show_win_elt = event.target
Expand Down
55 changes: 55 additions & 0 deletions core/main_eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import sys
import traceback
import json

def main():
print("Python eval process started.\n", flush=True)
while True:
#src = sys.stdin.readlines() #hangs until gets some stdin with a newline
src = sys.stdin.readline()
src = src.replace("{nL}", "\n")
index_of_space = src.index(" ")
callback_id = int(src[0:index_of_space])
src = src[index_of_space + 1:len(src) - 1] #the -1 takes off the newline on the end of src
#src = src.replace('"', '\\"')
#print("grabbed input: ", src, flush=True)
is_error = False
result = None
is_py_evalable = None
try:
compile(src, "main_eval compile", "eval") #works only for single expressions that return one value
except: #compile for eval errored, so maybe src is not an expression.
is_py_evalable = False
else:
is_py_evalable = True
if is_py_evalable :
try:
result = eval(src)
except Exception as err:
is_error = True
result = traceback.format_exc()
#result = result.replace(", line ", ", <br/>line ")
else: #the normal, working, return a value, eval case
is_error = False
else:
try:
exec(src)
except Exception as err:
is_error = True
result = traceback.format_exc()
#result = result.replace(", line ", ", <br/>line ")
else:
is_error = False
result = None
json_obj = {"from": "Py.eval", "is_error": is_error, "source": src, "callback_id": callback_id, "result": result}
print(json.dumps(json_obj), sep="", flush=True)

print("Python: main_eval.py file loaded.", "\n", flush=True)
main()

#if __name__ == "__main__":
# print("just under if", flush=True)
# 2 + 3
# 5 / 0


6 changes: 3 additions & 3 deletions core/out.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function out_eval_result(text, color="#000000", src, src_label="The result of ev
src_formatted = " <code title='" + src + "'>&nbsp;" + src_formatted + src_formatted_suffix + "&nbsp;</code>"
}
//if (src_formatted == "") { console.log("_____out_eval_result passed src: " + src + " with empty string for src_formatted and text: " + text)}
text = "<fieldset><legend><i>" + src_label + " </i>" + src_formatted + " <i>is...</i></legend>" + text + "</fieldset>"
append_to_output(text)
let the_html = "<fieldset><legend><i>" + src_label + " </i>" + src_formatted + " <i>is...</i></legend>" + text + "</fieldset>"
append_to_output(the_html)
}
//$('#js_textarea_id').focus() fails silently
if(window["document"]){
Expand Down Expand Up @@ -235,7 +235,7 @@ function show_window({content = `<input type="submit" value="Done"/>`,
if (fn_name && (fn_name != "")) {
if(fn_name == "callback") { //careful, might be just JS being clever and not the actual name in the fn def
fn_name = function_name(callback.toString()) //extracts real name if any
if (fn_name == "") { //nope, no actual name in fn
if ((fn_name == "") || (fn_name == null)) { //nope, no actual name in fn
callback = callback.toString() //get the src of the anonymous fn
}
else { callback = fn_name }
Expand Down
Loading

0 comments on commit 8d34445

Please sign in to comment.