-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basics of data comparaison nodes
- Loading branch information
Showing
5 changed files
with
239 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/js/modules/common_evaluators/templates/data_read_attribute.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { settingsNodeColors as nodeColors } from "./settings_node_colors.js" | ||
import createAttributeManagement from "../../common_project_management/attributes_management.js"; | ||
|
||
export var readAttribute = { | ||
templateName : "read_attribute", | ||
name : "Read Attribute", | ||
category:"data", | ||
props :[ | ||
{id:"output", label:"output", type:"hidden", editable:false, socket:"output", value:"output"}, | ||
// {id:"id", label:"prop id", type:"hidden", editable:false, socket:"output", value:false}, | ||
// {id:"method", label:"A", type:"text", editable:true, socket:"input", value:"0"}, | ||
{id:"method", label:"Attribute", type:"select", options:[ | ||
{id:"None", value:"..."}, | ||
],editable:true, socket:"none", value:"....."}, | ||
// {id:"a", label:"Field", type:"text", editable:true, socket:"input", value:"0"}, | ||
], | ||
methods:{ | ||
}, | ||
event:{ | ||
onEvaluate:(props) =>{ | ||
// var entityRepo = createEntityManagement() | ||
// console.log(entityRepo.getAll()); | ||
|
||
// props.method.setOptions(props.a.get().map(function (e) { | ||
// var currentKey = e.parameters.keys | ||
// return {id:e.uuid, value:e.name} | ||
// })) | ||
|
||
// if (props.a.get()[0] && props.a.get()[0].properties) { | ||
// props.method.setOptions(Object.keys(props.a.get()[0].properties).map(function (e) { | ||
// return {id:e, value:e} | ||
// })) | ||
// // props.output.set("undefined") | ||
// if (props.method.get()) { | ||
// props.output.set(props.a.get().map(function (e) { | ||
// console.log(e.properties); | ||
// return {[props.method.get()]:e.properties[props.method.get()]} | ||
// })) | ||
// props.id.set(props.method.getOptionId()) | ||
// } | ||
// }else{ | ||
// props.output.set("undefined") | ||
// } | ||
|
||
|
||
var func = (data)=>{ | ||
var value = props.method.get() | ||
if (value != ".....") { | ||
if (value == "name") { | ||
return data.name | ||
}else{ | ||
return data.properties[value] | ||
} | ||
}else{ | ||
return "undefined" | ||
} | ||
} | ||
|
||
props.output.set(func) | ||
|
||
|
||
}, | ||
onInit:(props) =>{ | ||
var attributeRepo = createAttributeManagement() | ||
console.log(attributeRepo.getAll()); | ||
var options=attributeRepo.getAll().map(function (e) { | ||
return {id:e.uuid, value:e.name} | ||
}) | ||
options.push({id:"name2", value:"name"}) | ||
props.method.setOptions(options) | ||
|
||
}, | ||
}, | ||
} |
118 changes: 118 additions & 0 deletions
118
src/js/modules/common_evaluators/templates/math_data_compare.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { settingsNodeColors as nodeColors } from "./settings_node_colors.js" | ||
|
||
|
||
function containsOnlyNumbers(str) { | ||
return /^[+-]?[0-9]+$/.test(str); | ||
} | ||
function containsOnlyFloat(str) { | ||
return /^[+-]?[0-9]+\.[0-9]+$/.test(str); | ||
} | ||
|
||
function checkForNumbers(str){ | ||
if (containsOnlyNumbers(str)) { | ||
return parseInt(str) | ||
}else if(containsOnlyFloat(str)){ | ||
return parseFloat(str) | ||
}else{ | ||
return str | ||
} | ||
} | ||
|
||
|
||
export var mathDataCompare = { | ||
templateName : "math_data_compare", | ||
name : "Data Compare", | ||
category:"Mathematics", | ||
props :[ | ||
{id:"output", label:"output", type:"hidden", editable:false, socket:"output", value:"output"}, | ||
// {id:"method", label:"A", type:"text", editable:true, socket:"input", value:"0"}, | ||
{id:"method", label:"", type:"select", options:[ | ||
{id:"Greater_Than", value:"Greater Than"}, | ||
{id:"Greater_Than_Or_Equal", value:"Greater Than or Equal"}, | ||
{id:"Less_Than", value:"Less Than"}, | ||
{id:"Less_Than_Or_Equal", value:"Less Than or Equal"}, | ||
{id:"Equal", value:"Equal"}, | ||
{id:"Not Equal", value:"Not Equal"}, | ||
],editable:true, socket:"none", value:"Greater Than"}, | ||
{id:"a", label:"A", type:"text", editable:true, socket:"input", value:"0"}, | ||
{id:"b", label:"B", type:"text", editable:true, socket:"input", value:"0"}, | ||
], | ||
methods:{ | ||
}, | ||
event:{ | ||
onEvaluate:(props) =>{ | ||
var condition = undefined | ||
|
||
if (props.method.get() == "Greater Than") { | ||
condition=(A,B)=> A > B | ||
}else if (props.method.get() == "Greater Than or Equal") { | ||
condition=(A,B)=> A >= B | ||
}else if (props.method.get() == "Less Than") { | ||
condition=(A,B)=> A < B | ||
}else if (props.method.get() == "Less Than or Equal") { | ||
condition=(A,B)=> A <= B | ||
}else if (props.method.get() == "Equal") { | ||
condition=(A,B)=> A == B | ||
}else if (props.method.get() == "Not Equal") { | ||
condition=(A,B)=> A != B | ||
} | ||
|
||
// if (props.method.get() == "Greater Than") { | ||
var func = function(data){ | ||
var A = props.a.get(data) | ||
var B = props.b.get(data) | ||
console.log(A, B); | ||
console.log(condition(A,B)); | ||
if (condition(A,B)) { | ||
return 1 | ||
} else { | ||
return 0 | ||
} | ||
} | ||
props.output.set(func) | ||
// } | ||
|
||
// if (props.method.get() == "Equal") { | ||
// var func = function(data){ | ||
// var A = props.a.get(data) | ||
// var B = props.b.get(data) | ||
// console.log(A, B); | ||
// console.log(A == B); | ||
// if (A == B) { | ||
// return 1 | ||
// } else { | ||
// return 0 | ||
// } | ||
// } | ||
// props.output.set(func) | ||
// } | ||
|
||
// else if (props.method.get() == "Less Than"){ | ||
// if (parseInt(props.a.get()) < parseInt(props.b.get())) { | ||
// props.output.set(1) | ||
// } else { | ||
// props.output.set(0) | ||
// } | ||
// }else if (props.method.get() == "Equal"){ | ||
// if (parseInt(props.a.get()) == parseInt(props.b.get())) { | ||
// props.output.set(1) | ||
// } else { | ||
// props.output.set(0) | ||
// } | ||
// }else if (props.method.get() == "Greater Than or Equal"){ | ||
// if (parseInt(props.a.get()) >= parseInt(props.b.get())) { | ||
// props.output.set(1) | ||
// } else { | ||
// props.output.set(0) | ||
// } | ||
// }else if (props.method.get() == "Less Than or Equal"){ | ||
// if (parseInt(props.a.get()) <= parseInt(props.b.get())) { | ||
// props.output.set(1) | ||
// } else { | ||
// props.output.set(0) | ||
// } | ||
// } | ||
|
||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters