4545 PortID ,
4646 PortInfoFormatSetupCommand ,
4747 Version ,
48+ VirtualPortSetupCommand ,
4849)
4950
5051
@@ -1314,6 +1315,56 @@ def __repr__(self) -> str:
13141315 return f"{ self .__class__ .__name__ } ({ repr (self .port )} , { repr (self .combo )} , { repr (self .multi_update )} , { repr (self .modes_and_datasets )} )"
13151316
13161317
1318+ ###############################################################################
1319+ # Virtual port messages
1320+ ###############################################################################
1321+
1322+
1323+ class AbstractVirtualPortSetupMessage (AbstractMessage ):
1324+ @abc .abstractmethod
1325+ def __init__ (self , length : int , command : VirtualPortSetupCommand ) -> None :
1326+ super ().__init__ (length , MessageKind .VIRTUAL_PORT_SETUP )
1327+
1328+ self ._data [3 ] = command
1329+
1330+ @property
1331+ def command (self ) -> VirtualPortSetupCommand :
1332+ return VirtualPortSetupCommand (self ._data [3 ])
1333+
1334+
1335+ class VirtualPortSetupDisconnectMessage (AbstractVirtualPortSetupMessage ):
1336+ def __init__ (self , port : PortID ) -> None :
1337+ super ().__init__ (5 , VirtualPortSetupCommand .DISCONNECT )
1338+
1339+ self ._data [4 ] = port
1340+
1341+ @property
1342+ def port (self ) -> PortID :
1343+ return PortID (self ._data [4 ])
1344+
1345+ def __repr__ (self ) -> str :
1346+ return f"{ self .__class__ .__name__ } ({ repr (self .port )} )"
1347+
1348+
1349+ class VirtualPortSetupConnectMessage (AbstractVirtualPortSetupMessage ):
1350+ def __init__ (self , port_a : PortID , port_b : PortID ) -> None :
1351+ super ().__init__ (6 , VirtualPortSetupCommand .CONNECT )
1352+
1353+ self ._data [4 ] = port_a
1354+ self ._data [5 ] = port_b
1355+
1356+ @property
1357+ def port_a (self ) -> PortID :
1358+ return PortID (self ._data [4 ])
1359+
1360+ @property
1361+ def port_b (self ) -> PortID :
1362+ return PortID (self ._data [5 ])
1363+
1364+ def __repr__ (self ) -> str :
1365+ return f"{ self .__class__ .__name__ } ({ repr (self .port_a )} , { repr (self .port_b )} )"
1366+
1367+
13171368###############################################################################
13181369# Message parsing
13191370###############################################################################
@@ -1399,6 +1450,11 @@ class _Lookup(NamedTuple):
13991450 ModeInfoKind .FORMAT : PortModeInfoFormatMessage ,
14001451}
14011452
1453+ _VIRTUAL_PORT_SETUP_CLASS_MAP = {
1454+ VirtualPortSetupCommand .DISCONNECT : VirtualPortSetupDisconnectMessage ,
1455+ VirtualPortSetupCommand .CONNECT : VirtualPortSetupConnectMessage ,
1456+ }
1457+
14021458# base type descriminator for messages
14031459_MESSAGE_CLASS_MAP = {
14041460 MessageKind .HUB_PROPERTY : _Lookup (4 , _HUB_PROPERTY_OP_CLASS_MAP ),
@@ -1420,6 +1476,7 @@ class _Lookup(NamedTuple):
14201476 MessageKind .PORT_VALUE_COMBO : PortValueComboMessage ,
14211477 MessageKind .PORT_INPUT_FMT : PortInputFormatMessage ,
14221478 MessageKind .PORT_INPUT_FMT_COMBO : PortInputFormatComboMessage ,
1479+ MessageKind .VIRTUAL_PORT_SETUP : _Lookup (3 , _VIRTUAL_PORT_SETUP_CLASS_MAP ),
14231480}
14241481
14251482
0 commit comments