Commit 37f1295c authored by rockyl's avatar rockyl

轮询判断过程

parent 9c2e8a8c
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
} }
}, },
"output": [ "output": [
"equal", "true",
"unequal" "false"
], ],
"id": "compare", "id": "compare",
"script": "var leftValue = typeof props.left === 'object' ? args[props.left.path] : props.left;\nvar rightValue = typeof props.right === 'object' ? args[props.right.path] : props.right;\nvar operator = args ? args.operator : props.operator;\nif (operator.length === 2 && operator[operator.length - 1] === '=') {\n operator += '=';\n}\nvar func = new Function('return ' + leftValue + operator + rightValue);\nvar result = func();\nnext(result ? 'equal' : 'unequal');\n", "script": "var operator = (args ? args.operator : props.operator) || '==';\nif (operator === '==' || operator === '!=') {\n operator += '=';\n}\nvar func = new Function('return ' + props.left + operator + props.right);\nvar result = func();\nnext(result ? 'true' : 'false');\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
{
"script": "var count = props.count, field = props.field, successValues = props.successValues;\nvar key = 'counting-' + vm.id;\nvar counting = global[key] || 0;\ncounting++;\nvar successArr = successValues.split(',');\nif (successArr.indexOf(args[field]) >= 0) {\n delete global[key];\n next('success');\n}\nelse if (counting < count) {\n global[key] = counting;\n next('continue');\n}\nelse {\n delete global[key];\n next('timeout');\n}\n",
"props": {
"count": {
"type": "number",
"default": 5,
"alias": "次数"
},
"field": {
"type": "string",
"alias": "字段名",
"default": "status"
},
"successArr": {
"type": "string",
"alias": "成功值"
}
},
"name": "轮询判断",
"output": [
"success",
"continue",
"timeout"
],
"id": "http-polling-judge",
"group": "net",
"type": "builtin"
}
...@@ -3,6 +3,7 @@ declare const args: any; ...@@ -3,6 +3,7 @@ declare const args: any;
declare const props: any; declare const props: any;
declare const target: engine.Container; declare const target: engine.Container;
declare const global: any; declare const global: any;
declare const vm: engine.VM;
declare function next(type: string, payload?: any); declare function next(type: string, payload?: any);
...@@ -2068,17 +2069,20 @@ export class Process { ...@@ -2068,17 +2069,20 @@ export class Process {
}>; }>;
getProcessMeta(id: any): any; getProcessMeta(id: any): any;
getProps(key?: any): any; getProps(key?: any): any;
updateProps(): void; updateProps(args: any): void;
resolveLinkedProp(data: any, key: any): any;
} }
export class VM { export class VM {
_processMetaLibs: any; _processMetaLibs: any;
_globalContext: any; _globalContext: any;
_target: any; _target: any;
_id: any;
setup(context: any): void; setup(context: any): void;
executeProcess(sequence: any, id: any, parentProcess: any, args: any): Promise<any>; executeProcess(sequence: any, pid: any, parentProcess: any, args: any): Promise<any>;
getMeta(id: any): any; getMeta(id: any): any;
getGlobalContext(): any; getGlobalContext(): any;
readonly id: any;
} }
export function fieldChanged(onModify: any): (target: any, key: string) => void; export function fieldChanged(onModify: any): (target: any, key: string) => void;
...@@ -2131,6 +2135,7 @@ export class DataCenter extends EventDispatcher { ...@@ -2131,6 +2135,7 @@ export class DataCenter extends EventDispatcher {
unregisterGroup(name: any): void; unregisterGroup(name: any): void;
getGroup(name: any): any; getGroup(name: any): any;
getDataByPath(path: any, throwException?: any): any; getDataByPath(path: any, throwException?: any): any;
getDataByName(name: any, throwException?: any): any;
formatString(str: any, escapes: any): any; formatString(str: any, escapes: any): any;
mutate(name: any, data?: any, path?: any, dispatch?: boolean): void; mutate(name: any, data?: any, path?: any, dispatch?: boolean): void;
watch(name: any, path: any): void; watch(name: any, path: any): void;
...@@ -2203,7 +2208,8 @@ export class Circle extends ShapeBase { ...@@ -2203,7 +2208,8 @@ export class Circle extends ShapeBase {
export {}; export {};
export class StackContainer extends Container { export class StackContainer extends Container {
constructor(); private _mutex;
constructor(mutex?: boolean);
push(view: DisplayObject, options?: any, dispatch?: boolean): void; push(view: DisplayObject, options?: any, dispatch?: boolean): void;
replace(view: DisplayObject, options?: any): void; replace(view: DisplayObject, options?: any): void;
pop(): boolean; pop(): boolean;
...@@ -2233,4 +2239,6 @@ export function arrayFind(arr: any, callback: any): any; ...@@ -2233,4 +2239,6 @@ export function arrayFind(arr: any, callback: any): any;
export function objClone(obj: any): any; export function objClone(obj: any): any;
export function propertyParse(key: any, node: any, properties: any): void; export function propertyParse(key: any, node: any, properties: any): void;
export function getDataByPath(scope: any, path: any, throwException?: any): any;
} }
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
let leftValue = typeof props.left === 'object' ? args[props.left.path] : props.left; let operator = (args ? args.operator : props.operator) || '==';
let rightValue = typeof props.right === 'object' ? args[props.right.path] : props.right; if(operator === '==' || operator === '!='){
let operator = args ? args.operator : props.operator;
if(operator.length === 2 && operator[operator.length -1] === '='){
operator += '='; operator += '=';
} }
let func = new Function('return ' + leftValue + operator + rightValue); let func = new Function('return ' + props.left + operator + props.right);
let result = func(); let result = func();
next(result ? 'equal' : 'unequal'); next(result ? 'true' : 'false');
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
"default": "=="} "default": "=="}
}, },
"output": [ "output": [
"equal", "unequal" "true", "false"
] ]
} }
\ No newline at end of file
/**
* Created by rockyl on 2019-11-16.
*/
const {count, field, successValues} = props;
const key = 'counting-' + vm.id;
let counting = global[key] || 0;
counting++;
let successArr = successValues.split(',');
if (successArr.indexOf(args[field]) >= 0) {
delete global[key];
next('success');
} else if (counting < count) {
global[key] = counting;
next('continue');
} else {
delete global[key];
next('timeout');
}
{
"script": "",
"props": {
"count": {
"type": "number",
"default": 5,
"alias": "次数"
},
"field": {
"type": "string",
"alias": "字段名",
"default": "status"
},
"successArr": {
"type": "string",
"alias": "成功值"
}
},
"name": "轮询判断",
"output": [
"success",
"continue",
"timeout"
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment