From a6bdd458c72cf9074fa323f7d4624baa8d1817b5 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Thu, 23 Nov 2023 21:38:53 +0900 Subject: [PATCH] feat: Queue Trigger (Countdown), Sleep --- README.md | 2 ++ __init__.py | 4 ++++ modules/impact/config.py | 2 +- modules/impact/logics.py | 49 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66a5020..5c887cb 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,8 @@ This takes latent as input and outputs latent as the result. * ImpactCompare, ImpactConditionalBranch, ImpactInt, ImpactValueSender, ImpactValueReceiver, ImpactImageInfo, ImpactMinMax, ImpactNeg, ImpactConditionalStopIteration * ImpactIsNotEmptySEGS - This node returns `true` only if the input SEGS is not empty. * Queue Trigger - When this node is executed, it adds a new queue to assist with repetitive tasks. It will only execute if the signal's status changes. + * Queue Trigger (Countdown) - Like the Queue Trigger, it adds a queue, but only adds it if it's greater than 1, and decrements the count by one each time it runs. + * Sleep - Waits for the specified time (in seconds). * Set Widget Value - This node sets one of the optional inputs to the specified node's widget. An error may occur if the types do not match. * Set Mute State - This node changes the mute state of a specific node. * Control Bridge - Depending on whether the mode is set to `block` or `pass`, it changes the mute status of connected nodes. If there are nodes that require a change, the current execution is paused, the mute status is updated, and a new prompt queue is inserted. diff --git a/__init__.py b/__init__.py index 2d54b01..ab21103 100644 --- a/__init__.py +++ b/__init__.py @@ -269,10 +269,12 @@ NODE_CLASS_MAPPINGS = { "ImpactDummyInput": ImpactDummyInput, "ImpactQueueTrigger": ImpactQueueTrigger, + "ImpactQueueTriggerCountdown": ImpactQueueTriggerCountdown, "ImpactSetWidgetValue": ImpactSetWidgetValue, "ImpactNodeSetMuteState": ImpactNodeSetMuteState, "ImpactControlBridge": ImpactControlBridge, "ImpactIsNotEmptySEGS": ImpactNotEmptySEGS, + "ImpactSleep": ImpactSleep, "ImpactHFTransformersClassifierProvider": HF_TransformersClassifierProvider, "ImpactSEGSClassify": SEGS_Classify @@ -369,9 +371,11 @@ NODE_DISPLAY_NAME_MAPPINGS = { "ImpactCombineConditionings": "Combine Conditionings", "ImpactQueueTrigger": "Queue Trigger", + "ImpactQueueTriggerCountdown": "Queue Trigger (Countdown)", "ImpactSetWidgetValue": "Set Widget Value", "ImpactNodeSetMuteState": "Set Mute State", "ImpactControlBridge": "Control Bridge", + "ImpactSleep": "Sleep", "ImpactHFTransformersClassifierProvider": "HF Transformers Classifier Provider", "ImpactSEGSClassify": "SEGS Classify", diff --git a/modules/impact/config.py b/modules/impact/config.py index 1a24316..4b2cb6d 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version = "V4.32.1" +version = "V4.33" dependency_version = 19 diff --git a/modules/impact/logics.py b/modules/impact/logics.py index 48967dd..328951b 100644 --- a/modules/impact/logics.py +++ b/modules/impact/logics.py @@ -1,4 +1,5 @@ import sys +import time import execution import folder_paths @@ -293,6 +294,32 @@ class ImpactQueueTrigger: return (signal,) +class ImpactQueueTriggerCountdown: + @classmethod + def INPUT_TYPES(cls): + return {"required": { + "signal": (any_typ,), + "count": ("INT", {"default": 10, "min": 0, "max": 0xffffffffffffffff}) + }, + "hidden": {"unique_id": "UNIQUE_ID"} + } + + FUNCTION = "doit" + + CATEGORY = "ImpactPack/Logic/_for_test" + RETURN_TYPES = (any_typ, "INT") + RETURN_NAMES = ("signal_opt", "count") + OUTPUT_NODE = True + + def doit(self, signal, count, unique_id): + if count > 0: + PromptServer.instance.send_sync("impact-node-feedback", + {"id": unique_id, "widget_name": "count", "type": "int", "value": count-1}) + PromptServer.instance.send_sync("impact-add-queue", {}) + + return (signal, count) + + class ImpactSetWidgetValue: @classmethod def INPUT_TYPES(cls): @@ -362,6 +389,27 @@ class ImpactNodeSetMuteState: return (signal,) +class ImpactSleep: + @classmethod + def INPUT_TYPES(cls): + return {"required": { + "signal": (any_typ,), + "seconds": ("FLOAT", {"default": 0.5, "min": 0, "max": 3600}), + } + } + + FUNCTION = "doit" + + CATEGORY = "ImpactPack/Logic/_for_test" + RETURN_TYPES = (any_typ,) + RETURN_NAMES = ("signal_opt",) + OUTPUT_NODE = True + + def doit(self, signal, seconds): + time.sleep(seconds) + return (signal,) + + error_skip_flag = False try: import sys @@ -393,6 +441,7 @@ def workflow_to_map(workflow): return nodes, links + class ImpactControlBridge: @classmethod def INPUT_TYPES(cls):