101 lines
1.4 KiB
Plaintext
101 lines
1.4 KiB
Plaintext
function table_print(t) {
|
|
if(t==nil)
|
|
log("Table do not exist!")
|
|
else {
|
|
foreach(t, function(key, value) {
|
|
log(key, " -> ", value)
|
|
})
|
|
}
|
|
}
|
|
|
|
function table_copy(t) {
|
|
var t2 = {}
|
|
foreach(t, function(key, value) {
|
|
t2[key] = value
|
|
})
|
|
return t2
|
|
}
|
|
|
|
#
|
|
#return the number of value in table
|
|
#
|
|
function count(table,value){
|
|
number=0
|
|
i=0
|
|
while(i<size(table)){
|
|
if(table[i]==value){
|
|
number=number+1
|
|
}
|
|
i=i+1
|
|
}
|
|
return number
|
|
}
|
|
#
|
|
# map from int to state - vstig serialization limits to 9....
|
|
#
|
|
function i2s(value){
|
|
if(value==1){
|
|
return "IDLE"
|
|
}
|
|
else if(value==2){
|
|
return "DEPLOY"
|
|
}
|
|
else if(value==3){
|
|
return "STOP"
|
|
}
|
|
else if(value==4){
|
|
return "TURNEDOFF"
|
|
}
|
|
else if(value==5){
|
|
return "BARRIERWAIT"
|
|
}
|
|
else if(value==6){
|
|
return "INDIWP"
|
|
}
|
|
else if(value==7){
|
|
return "TASK_ALLOCATE"
|
|
}
|
|
else if(value==8){
|
|
return "LAUNCH"
|
|
}
|
|
else if(value==9){
|
|
return "FORMATION"
|
|
}
|
|
else {
|
|
return "UNDETERMINED"
|
|
}
|
|
}
|
|
#
|
|
# map from state to int - vstig serialization limits to 9....
|
|
#
|
|
function s2i(value){
|
|
if(value=="IDLE"){
|
|
return 1
|
|
}
|
|
else if(value=="DEPLOY"){
|
|
return 2
|
|
}
|
|
else if(value=="STOP"){
|
|
return 3
|
|
}
|
|
else if(value=="TURNEDOFF"){
|
|
return 4
|
|
}
|
|
else if(value=="BARRIERWAIT"){
|
|
return 5
|
|
}
|
|
else if(value=="WAYPOINT"){
|
|
return 6
|
|
}
|
|
else if(value=="TASK_ALLOCATE"){
|
|
return 7
|
|
}
|
|
else if(value=="LAUNCH"){
|
|
return 8
|
|
}
|
|
else if(value=="POTENTIAL"){
|
|
return 9
|
|
}
|
|
else
|
|
return 0
|
|
} |