mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 08:19:51 +00:00
added semaphore node
This commit is contained in:
@@ -6927,6 +6927,12 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
14,
|
||||
10
|
||||
);
|
||||
ctx.rect(
|
||||
this.graph_mouse[0] - 6 + 0.5,
|
||||
this.graph_mouse[1] - 5 + 0.5,
|
||||
14,
|
||||
10
|
||||
);
|
||||
} else if (this.connecting_output.shape === LiteGraph.ARROW_SHAPE) {
|
||||
ctx.moveTo(this.connecting_pos[0] + 8, this.connecting_pos[1] + 0.5);
|
||||
ctx.lineTo(this.connecting_pos[0] - 4, this.connecting_pos[1] + 6 + 0.5);
|
||||
@@ -6941,6 +6947,13 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
0,
|
||||
Math.PI * 2
|
||||
);
|
||||
ctx.arc(
|
||||
this.graph_mouse[0],
|
||||
this.graph_mouse[1],
|
||||
4,
|
||||
0,
|
||||
Math.PI * 2
|
||||
);
|
||||
}
|
||||
ctx.fill();
|
||||
|
||||
|
||||
@@ -320,6 +320,45 @@
|
||||
|
||||
LiteGraph.registerNodeType("events/timer", TimerEvent);
|
||||
|
||||
|
||||
|
||||
function SemaphoreEvent() {
|
||||
this.addInput("go", LiteGraph.ACTION );
|
||||
this.addInput("green", LiteGraph.ACTION );
|
||||
this.addInput("red", LiteGraph.ACTION );
|
||||
this.addOutput("continue", LiteGraph.EVENT );
|
||||
this.addOutput("blocked", LiteGraph.EVENT );
|
||||
this.addOutput("is_green", "boolean" );
|
||||
this._ready = false;
|
||||
this.properties = {};
|
||||
var that = this;
|
||||
this.addWidget("button","reset","",function(){
|
||||
that._ready = false;
|
||||
});
|
||||
}
|
||||
|
||||
SemaphoreEvent.title = "Semaphore Event";
|
||||
SemaphoreEvent.desc = "Until both events are not triggered, it doesnt continue.";
|
||||
|
||||
SemaphoreEvent.prototype.onExecute = function()
|
||||
{
|
||||
this.setOutputData(1,this._ready);
|
||||
this.boxcolor = this._ready ? "#9F9" : "#FA5";
|
||||
}
|
||||
|
||||
SemaphoreEvent.prototype.onAction = function(action, param) {
|
||||
if( action == "go" )
|
||||
this.triggerSlot( this._ready ? 0 : 1 );
|
||||
else if( action == "green" )
|
||||
this._ready = true;
|
||||
else if( action == "red" )
|
||||
this._ready = false;
|
||||
};
|
||||
|
||||
LiteGraph.registerNodeType("events/semaphore", SemaphoreEvent);
|
||||
|
||||
|
||||
|
||||
function DataStore() {
|
||||
this.addInput("data", "");
|
||||
this.addInput("assign", LiteGraph.ACTION);
|
||||
@@ -354,4 +393,7 @@
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("basic/data_store", DataStore);
|
||||
|
||||
|
||||
|
||||
})(this);
|
||||
|
||||
Reference in New Issue
Block a user