fix launch bug

fix msg bug
This commit is contained in:
remilia 2025-04-16 21:24:54 +08:00
parent 7753541fe7
commit 0010fe0cd6
5 changed files with 17 additions and 14 deletions

View File

@ -20,7 +20,7 @@ from flandre.nodes.ImageFFMPEG import ImageFFMPEG
from flandre.nodes.ImageQt import ImageQt
from flandre.nodes.Midi import Midi
from flandre.nodes.Mi import Mi
from flandre.utils.Msg import KillMsg, TickMsg, Msg1
from flandre.utils.Msg import KillMsg, NodeOnlineMsg, Msg1
from flandre.config import CONFIG_FOLDER
@ -56,15 +56,16 @@ def launch(arg: dict[LaunchComponent, dict]):
for p in pps:
p.start()
c = BusClient(KillMsg, TickMsg)
c = BusClient(KillMsg, NodeOnlineMsg)
cnt = 0
while True:
msg = c.recv()
if isinstance(msg, KillMsg):
if msg.name == '':
break
if isinstance(msg, TickMsg):
if isinstance(msg, NodeOnlineMsg):
cnt += 1
logging.info(msg)
if cnt == len(ps):
logging.info(f'launcher stand by ready')
c.send(Msg1())

View File

@ -4,7 +4,7 @@ import zmq
from zmq import ContextTerminated
from flandre.nodes.Node import Node
from flandre.utils.Msg import KillMsg, TickMsg
from flandre.utils.Msg import KillMsg, NodeOnlineMsg
class Broker(Node):
@ -12,7 +12,7 @@ class Broker(Node):
def t():
while True:
msg = self.recv()
if isinstance(msg, TickMsg):
if isinstance(msg, NodeOnlineMsg):
pass
elif isinstance(msg, KillMsg):
if msg.name == '':

View File

@ -202,12 +202,12 @@ class Device(Node):
self.req_driver_socket = self.context.socket(zmq.REQ)
self.req_driver_socket.connect(C.live_rep_socket)
def loop(self):
self.loop2_t = Thread(target=self.loop2)
self.loop2_t.start()
def loop(self):
arr = []
time.sleep(3)
if self.online():
self.get_connection()
self.get_enable()

View File

@ -5,7 +5,7 @@ from abc import abstractmethod
import zmq
from flandre.BusClient import BusClient
from flandre.utils.Msg import Msg, KillMsg, TickMsg, Msg1
from flandre.utils.Msg import Msg, KillMsg, NodeOnlineMsg, Msg1
class Node:
@ -61,7 +61,9 @@ class Node:
self.setup()
if not self.broker:
time.sleep(0.2)
self.send(TickMsg())
self.recv()
self.send(NodeOnlineMsg(self.__class__.__name__))
# input('asdasd')
msg = self.recv()
# logging.info(f'{self.__class__.__name__},{msg}')
self.loop()
print(self.__class__.__name__, 'exiting')

View File

@ -16,7 +16,7 @@ class BG(Enum):
Msg2 = auto()
RefreshDeviceMsg = auto()
BMMsg = auto()
TickMsg = auto()
NodeOnlineMsg = auto()
KillMsg = auto()
StrMsg = auto()
MoveAxisMsg = auto()
@ -137,8 +137,8 @@ class Msg2(Msg):
@dataclasses.dataclass
class TickMsg(Msg):
time: float = 0
class NodeOnlineMsg(Msg):
name: str
@dataclasses.dataclass
@ -322,7 +322,7 @@ class RfFrameMsg(HeaderByteMsg):
sender=sender,
type='RfFrameMemory',
frame_meta=rf_frame.meta.name,
seq_meta=rf_frame.seq_meta,
seq_meta=rf_frame.seq_meta.name,
), rf_frame.data)
@classmethod