-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
8,324 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from types import DynamicClassAttribute | ||
import bpy | ||
from dmx.zeroconf import ( | ||
IPVersion, | ||
ServiceBrowser, | ||
ServiceStateChange, | ||
Zeroconf, | ||
) | ||
from dmx.logging import DMX_Log | ||
from typing import cast | ||
|
||
|
||
class DMX_Zeroconf: | ||
_instance = None | ||
|
||
def __init__(self): | ||
super(DMX_Zeroconf, self).__init__() | ||
self.data = None | ||
self.zeroconf = None | ||
self.browser = None | ||
self._dmx = bpy.context.scene.dmx | ||
|
||
def callback(zeroconf: Zeroconf, service_type: str, name: str, state_change: ServiceStateChange) -> None: | ||
#print(f"Service {name} of type {service_type} state changed: {state_change}") | ||
|
||
info = zeroconf.get_service_info(service_type, name) | ||
station_name = "" | ||
station_uuid = "" | ||
ip_address = "" | ||
port = 0 | ||
|
||
if info: | ||
addresses = ["%s:%d" % (addr, cast(int, info.port)) for addr in info.parsed_scoped_addresses()] | ||
for address in addresses: | ||
if "::" in address: | ||
continue | ||
ip_a, ip_port = address.split(":") | ||
ip_address = ip_a | ||
port = ip_port | ||
|
||
if info.properties: | ||
if b"StationName" in info.properties: | ||
station_name = info.properties[b"StationName"].decode("utf-8") | ||
if b"StationUUID" in info.properties: | ||
station_uuid = info.properties[b"StationUUID"].decode("utf-") | ||
|
||
if state_change is ServiceStateChange.Added: | ||
DMX_Zeroconf._instance._dmx.createMVR_Client(station_name, station_uuid, ip_address, int(port)) | ||
elif state_change is ServiceStateChange.Updated: | ||
DMX_Zeroconf._instance._dmx.updateMVR_Client(station_name, station_uuid, ip_address, int(port)) | ||
else: # removed | ||
DMX_Zeroconf._instance._dmx.removeMVR_Client(station_name, station_uuid, ip_address, int(port)) | ||
|
||
@staticmethod | ||
def enable(): | ||
if DMX_Zeroconf._instance: | ||
return | ||
DMX_Zeroconf._instance = DMX_Zeroconf() | ||
|
||
services = ["_mvrxchange._tcp.local."] | ||
DMX_Zeroconf._instance.zeroconf = Zeroconf(ip_version=IPVersion.V4Only) | ||
DMX_Zeroconf._instance.browser = ServiceBrowser(DMX_Zeroconf._instance.zeroconf, services, handlers=[DMX_Zeroconf.callback]) | ||
DMX_Log.log.info("Enabling Zeroconf") | ||
print("starting mvrx discovery") | ||
|
||
@staticmethod | ||
def disable(): | ||
if DMX_Zeroconf._instance: | ||
DMX_Zeroconf._instance.zeroconf.close() | ||
DMX_Zeroconf._instance = None | ||
print("closing mvrx discovery") | ||
DMX_Log.log.info("Disabling Zeroconf") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import bpy | ||
from bpy.props import BoolProperty, CollectionProperty, EnumProperty, IntProperty, StringProperty | ||
from bpy.types import PropertyGroup | ||
|
||
|
||
class DMX_MVR_Xchange_Commit(PropertyGroup): | ||
commit_uuid: StringProperty(name="File UUID") | ||
comment: StringProperty(name="Comment") | ||
file_name: StringProperty(name="File Name") | ||
station_uuid: StringProperty(name="Station UUID") | ||
file_size: IntProperty(name="File Size") | ||
timestamp: IntProperty(name="Time of info") | ||
timestamp_saved: IntProperty(name="Time of saving") | ||
subscribed: BoolProperty(name="Subscribed to") | ||
|
||
|
||
class DMX_MVR_Xchange_Client(PropertyGroup): | ||
ip_address: StringProperty(name="IP Address") | ||
port: IntProperty(name="Port") | ||
subscribed: BoolProperty(name="Subscribed to") | ||
last_seen: IntProperty(name="Last Seen Time") | ||
station_name: StringProperty(name="Station Name") | ||
station_uuid: StringProperty(name="Station UUID") | ||
provider: StringProperty(name="Provider") | ||
commits: CollectionProperty(name="Commits", type=DMX_MVR_Xchange_Commit) | ||
|
||
def get_clients(self, context): | ||
#print(self, context) | ||
clients = bpy.context.window_manager.dmx.mvr_xchange.mvr_xchange_clients | ||
data = [] | ||
for client in clients: | ||
data.append((client.station_uuid, client.station_name, client.station_uuid)) | ||
return data | ||
|
||
class DMX_MVR_Xchange(PropertyGroup): | ||
selected_commit: IntProperty(default=0) | ||
mvr_xchange_clients: CollectionProperty( | ||
name = "MVR-xchange Clients", | ||
type=DMX_MVR_Xchange_Client | ||
) | ||
|
||
selected_mvr_client: EnumProperty( | ||
name = "Client", | ||
description="", | ||
items = DMX_MVR_Xchange_Client.get_clients | ||
) |
Oops, something went wrong.