driver astrium_chopper = { debug_threshold = 2; vendor = astrium; device = chopper; protocol = std; class = NXdisk_chopper; simulation_group = chopper_simulation; group blade_1 = { var state = { type = text; mutable = true; priv = user; readable = 1; read_command = '1'; fetch_function = fetchState; read_function = readState; property 'my_state' = 'idle'; } var master = { type = text; } var rspeed = { type = float; } var aspeed = { type = float; mutable = true; } var rphase = { type = float; } var aphase = { type = float; mutable = true; } } group blade_2 = { var state = { type = text; mutable = true; priv = user; readable = 1; read_command = '2'; fetch_function = fetchState; read_function = readState; property 'my_state' = 'idle'; } var master = { type = text; } var rspeed = { type = float; } var aspeed = { type = float; mutable = true; } var rphase = { type = float; } var aphase = { type = float; mutable = true; } } group blade_3 = { var state = { type = text; mutable = true; priv = user; readable = 1; read_command = '3'; fetch_function = fetchState; read_function = readState; property 'my_state' = 'idle'; } var master = { type = text; } var rspeed = { type = float; } var aspeed = { type = float; mutable = true; } var rphase = { type = float; } var aphase = { type = float; mutable = true; } } group blade_4 = { var state = { type = text; mutable = true; priv = user; readable = 1; read_command = '4'; fetch_function = fetchState; read_function = readState; property 'my_state' = 'idle'; } var master = { type = text; } var rspeed = { type = float; } var aspeed = { type = float; mutable = true; } var rphase = { type = float; } var aphase = { type = float; mutable = true; } } code fetch_function fetchState = {%% set my_state [sct my_state] if { ${my_state} == "user" } { set cmd "user:Bilby" } elseif { ${my_state} == "password" } { set cmd "password:RwN" } else { set cmd "#SOS#STATE ${cmd_str}" } %%} code read_function readState = {%% if { [string equal -length 22 ${data} "#SES#Fill in your user"] } { sct my_state "user" set nextState "read" } elseif { [string equal -length 22 ${data} "#SES#Fill in your pass"] } { sct my_state "password" set nextState "read" } elseif { [string equal -length 22 ${data} "#SES#You are not a val"] } { sct my_state "user" set nextState "read" } else { sct my_state "idle" set nextState "idle" if { [string equal -length 12 ${data} "#SOS#ACCEPT "] } { set my_status [split [string range ${data} 12 end] "#"] foreach field ${my_status} { set lst [split ${field} "="] if { [llength ${lst}] > 1 } { set lhs "[string trim [lindex ${lst} 0]]" set rhs "[string trim [lindex ${lst} 1]]" sct "attr_${lhs}" "${rhs}" set base [pathname [sct]] foreach node [list ASPEED RSPEED APHASE RPHASE MASTER] { if { [string equal -nocase "${lhs}" "${node}"] } { if { "[hval ${base}/${node}]" != "${rhs}" } { hset ${base}/${node} "${rhs}" } } } if { [string equal -nocase ${lhs} "STATE"] } { set data "${rhs}" } } } } else { sct geterror "${data}" } } %%} code mkDriver = {%% hsetprop ${scobj_hpath} debug_threshold 1 %%} }