diff --git a/QControlKit/QColor.cs b/QControlKit/Constants/QColor.cs similarity index 98% rename from QControlKit/QColor.cs rename to QControlKit/Constants/QColor.cs index 7ab6c36..53f4ef3 100644 --- a/QControlKit/QColor.cs +++ b/QControlKit/Constants/QColor.cs @@ -1,4 +1,4 @@ -namespace QControlKit +namespace QControlKit.Constants { public class QColor { diff --git a/QControlKit/QDefines.cs b/QControlKit/Constants/QDefines.cs similarity index 94% rename from QControlKit/QDefines.cs rename to QControlKit/Constants/QDefines.cs index 2e2aae1..8def692 100644 --- a/QControlKit/QDefines.cs +++ b/QControlKit/Constants/QDefines.cs @@ -1,10 +1,11 @@ -namespace QControlKit +namespace QControlKit.Constants { static class QBonjour { public const string TCPService = "_qlab._tcp.local."; public const string UDPService = "_qlab._udp.local."; } + static class QCueType { public const string Cue = "Cue"; @@ -121,17 +122,16 @@ } - //these should really be enums - static class QFadeMode + enum QFadeMode { - public const int Absolute = 0; - public const int Relative = 1; + Absolute = 0, + Relative = 1 } - static class QContinueMode + enum QContinueMode { - public const int NoContinue = 0; - public const int AutoContinue = 1; - public const int AutoFollow = 2; + NoContinue = 0, + AutoContinue = 1, + AutoFollow = 2 } } diff --git a/QControlKit/Events/QEventArgs.cs b/QControlKit/Events/QEventArgs.cs index e31209e..8c07890 100644 --- a/QControlKit/Events/QEventArgs.cs +++ b/QControlKit/Events/QEventArgs.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace QControlKit +namespace QControlKit.Events { public class QServerFoundArgs : EventArgs { diff --git a/QControlKit/Events/QEventHandlers.cs b/QControlKit/Events/QEventHandlers.cs index 4ebeca8..5547688 100644 --- a/QControlKit/Events/QEventHandlers.cs +++ b/QControlKit/Events/QEventHandlers.cs @@ -1,4 +1,4 @@ -namespace QControlKit +namespace QControlKit.Events { public delegate void QServerFoundHandler(object source, QServerFoundArgs args); public delegate void QServerUpdatedHandler(object source, QServerUpdatedArgs args); diff --git a/QControlKit/QBrowser.cs b/QControlKit/QBrowser.cs index cb74de6..769592c 100644 --- a/QControlKit/QBrowser.cs +++ b/QControlKit/QBrowser.cs @@ -1,7 +1,11 @@ -using Zeroconf; +//TODO period updating of servers, proper server removing/workspace updating +using Zeroconf; using System.Collections.ObjectModel; using Serilog; +using QControlKit.Constants; +using QControlKit.Events; + namespace QControlKit { public class QBrowser diff --git a/QControlKit/QClient.cs b/QControlKit/QClient.cs index be2a7e6..67a90aa 100644 --- a/QControlKit/QClient.cs +++ b/QControlKit/QClient.cs @@ -5,6 +5,9 @@ using Newtonsoft.Json.Linq; using SharpOSC; using Serilog; +using QControlKit.Events; +using QControlKit.Constants; + namespace QControlKit { public class QClient @@ -107,7 +110,6 @@ namespace QControlKit } else if (message.IsConnect) { - //Log.Debug($"[client] Connection message received: {message.response}"); if (message.response.ToString() == "ok") OnWorkspaceConnected(); else diff --git a/QControlKit/QControlKit.csproj b/QControlKit/QControlKit.csproj index 07418be..7c17cac 100644 --- a/QControlKit/QControlKit.csproj +++ b/QControlKit/QControlKit.csproj @@ -6,7 +6,7 @@ Joel Wetzell 1.0.0-devel true - 0.0.3 + 0.0.4 QControlKit @@ -15,4 +15,7 @@ + + + diff --git a/QControlKit/QCue.cs b/QControlKit/QCue.cs index cff23ca..73ced36 100644 --- a/QControlKit/QCue.cs +++ b/QControlKit/QCue.cs @@ -5,6 +5,9 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; +using QControlKit.Events; +using QControlKit.Constants; + namespace QControlKit { public class QCue @@ -42,7 +45,7 @@ namespace QControlKit //this breaks things??? //it definitely is in the original but somehow the recursion is not working as I expect.. - //but cue population still works without this as child cues are populated in a later + //but cue population still works without this as child cues are populated later /*JToken children = dict[QOSCKey.Cues]; if(children != null && children.Type == JTokenType.Array) @@ -102,6 +105,7 @@ namespace QControlKit //isEqual? //hash? //compare? + //TODO public bool isEqualToCue(QCue cue) { throw new NotImplementedException(); } public void setWorkspace(QWorkspace workspace) { @@ -121,7 +125,7 @@ namespace QControlKit return; childCues.Add(cue); childCuesUIDMap.Add(uid, cue); - //some sorting of the childCues needs to be done? + //some sorting of the childCues needs to be done? //TODO //reset sorting index } public void removeChildCue(QCue cue) { throw new NotImplementedException(); } @@ -130,13 +134,12 @@ namespace QControlKit //copied: yes //implemented: no + //TODO #region Class Methods public string iconForType(string type) { throw new NotImplementedException(); } public List fadeModeTitles() { throw new NotImplementedException(); } #endregion - //copied: yes - //implemented: not all #region Convenience Accessors public List cues { @@ -482,7 +485,6 @@ namespace QControlKit } //TODO add quaternion property and setter - public Size surfaceSize() { throw new NotImplementedException(); } public Size cueSize() { throw new NotImplementedException(); } public List availableSurfaceName() { throw new NotImplementedException(); } @@ -527,7 +529,8 @@ namespace QControlKit if (!this.ignoreUpdates) { - //TODO: Send Cue Needs Updated + //TODO: This should be enough? + workspace.fetchBasicPropertiesForCue(this); } } } @@ -540,7 +543,7 @@ namespace QControlKit { bool cueUpdated = false; - //TODO + //TODO: pretty sure this is done JObject dictObj = (JObject)dict; List propertiesUpdated = new List(); foreach (var obj in dictObj) @@ -570,7 +573,7 @@ namespace QControlKit return true; } - //enqueue updated notification? + //enqueue updated notification? //TODO public bool updateChildCuesWithPropertiesArray(JToken value, bool removeUnused) { if (!workspace.connected) @@ -621,9 +624,6 @@ namespace QControlKit #endregion - - //Methods Copied: Yes - //Methods Implemented: Not all #region Children Cues public List allChildCueUids() { @@ -807,8 +807,6 @@ namespace QControlKit public void pullDownPropertyForKey(string key) { } - //Methods Copied: Yes - //Methods Implemented: Yes #region Actions public void start() { workspace.startCue(this); } public void stop() { workspace.stopCue(this); } @@ -839,6 +837,7 @@ namespace QControlKit { Print(0); } + public void Print(int level) { string indent = new string(' ', level*2); diff --git a/QControlKit/QMessage.cs b/QControlKit/QMessage.cs index 22ad8be..dff95eb 100644 --- a/QControlKit/QMessage.cs +++ b/QControlKit/QMessage.cs @@ -19,7 +19,7 @@ namespace QControlKit { get { - //string join probably won't work might need to cast argument objects to strings first + //string join probably won't work might need to cast argument objects to strings first? return $"address: {address}, arguments: {string.Join(" - ", arguments)}"; } } diff --git a/QControlKit/QServer.cs b/QControlKit/QServer.cs index f7c6a9e..1445766 100644 --- a/QControlKit/QServer.cs +++ b/QControlKit/QServer.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using Zeroconf; +using QControlKit.Events; + namespace QControlKit { public class QServer @@ -13,6 +15,7 @@ namespace QControlKit public string host { get; set; } public int port { get; set; } public string name { get; set; } + public string version { get; set; } public IZeroconfHost zeroconfHost; public List workspaces = new List(); @@ -58,6 +61,9 @@ namespace QControlKit { QWorkspace workspaceToAdd = new QWorkspace(workspace, this); workspaces.Add(workspaceToAdd); + //set server version to the version of first workspace found...kind of hacky but eh + if (version == null) + version = workspaceToAdd.version; } } OnServerUpdated(this); @@ -75,7 +81,7 @@ namespace QControlKit { if (workspace.connected) { - Log.Debug($"[server] Close Called For workspace: {workspace.name}"); + Log.Debug($"[server] Closing workspace <{workspace.name}> still connected to {name}"); workspace.disconnect(); } } diff --git a/QControlKit/QWorkspace.cs b/QControlKit/QWorkspace.cs index f3515e4..687b170 100644 --- a/QControlKit/QWorkspace.cs +++ b/QControlKit/QWorkspace.cs @@ -6,6 +6,9 @@ using System.Collections.Generic; using System.Linq; using System.Timers; +using QControlKit.Events; +using QControlKit.Constants; + namespace QControlKit { public class QWorkspace @@ -75,7 +78,7 @@ namespace QControlKit client.CueUpdated += OnCueUpdated; this.server = server; - Log.Debug($"[workspace] <{name}> initizalied for server: {server.name} "); + Log.Debug($"[workspace] <{name}> on {server.name} initialized."); } //updateWithDictionary @@ -125,7 +128,7 @@ namespace QControlKit return name.Substring(0, name.Length - 6); return name; } - } //TODO + } public string serverName { get { return server.name; } } @@ -144,7 +147,7 @@ namespace QControlKit public void connect(string passcode = null) { - Log.Debug($"[workspace] connecting to {this.server.host} with passcode: {passcode}"); + Log.Information($"[workspace] connecting to <{name}> @ {this.server.host}:{this.server.port}"); if(hasPasscode && passcode == null) { @@ -155,13 +158,12 @@ namespace QControlKit if (!client.connect()) { - Log.Error($"[workspace] *** couldn't connect to server client is not connected"); + Log.Error($"[workspace] *** couldn't connect to server client is not connected."); return; } //save password for reuse this.passcode = passcode; - Log.Information("[workspace] connecting..."); if (passcode != null) client.sendMessage($"{workspacePrefix}/connect", passcode); else @@ -171,7 +173,6 @@ namespace QControlKit private void finishConnection() { //TODO - Log.Information($"[workspace] connected to <{name}> running on QLab version <{version}>"); connected = true; startReceivingUpdates(); //fetchQLabVersion(); @@ -193,7 +194,7 @@ namespace QControlKit public void disconnect() { - Log.Information($"[workspace] disconnect: {name}"); + Log.Information($"[workspace] disconnecting from <{name}>"); if (heartbeatTimer != null) stopHeartbeat(); stopReceivingUpdates(); @@ -232,7 +233,7 @@ namespace QControlKit public void stopReceivingUpdates() { client.sendMessage($"{workspacePrefix}/updates", 0); } public void enableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 1); } public void disableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 0); } - public void fetchQLabVersion() { client.sendMessage($"{workspacePrefix}/version"); } //TODO: EventHandler for this + public void fetchQLabVersion() { client.sendMessage($"{workspacePrefix}/version"); } //TODO: EventHandler for this? Is this still needed? public void fetchCueLists() { client.sendMessage($"{workspacePrefix}/cueLists"); } //TODO: EventHandler for CueListUpdated public void fetchPlaybackPositionForCue(QCue cue) { client.sendMessage(addressForCue(cue, QOSCKey.PlaybackPositionId)); } //EventHandler for this? can I use the CueListPlaybackPosition one? public void go() { client.sendMessage($"{workspacePrefix}/go"); } @@ -410,7 +411,7 @@ namespace QControlKit private void OnWorkspaceConnected(object source, QWorkspaceConnectedArgs args) { - Log.Debug($"[workspace] Connection being finished."); + Log.Information($"[workspace] Connection to <{name}> successful, finishing things up."); finishConnection(); } @@ -505,7 +506,7 @@ namespace QControlKit QCue selectedCue = cueWithID(args.cueID); if (selectedCue != null) { - Log.Information($"[workspace] cue list <{cueList.displayName}> playback position changed to <{selectedCue.displayName}>"); + Log.Debug($"[workspace] cue list <{cueList.displayName}> playback position changed to <{selectedCue.displayName}>"); CueListChangedPlaybackPosition?.Invoke(this, new QCueListChangedPlaybackPositionArgs { cueListID = cueList.uid, cueID = selectedCue.uid }); } @@ -535,9 +536,7 @@ namespace QControlKit return; if (cue.ignoreUpdates) return; - cue.updatePropertiesWithDictionary(args.data); - } private void OnWorkspaceUpdated() @@ -555,7 +554,6 @@ namespace QControlKit { cueList.Print(); } - Log.Information("[workspace] End of Workspace"); } #endregion } diff --git a/QControlKit/QWorkspaceInfo.cs b/QControlKit/QWorkspaceInfo.cs index 36eb295..9df3fc2 100644 --- a/QControlKit/QWorkspaceInfo.cs +++ b/QControlKit/QWorkspaceInfo.cs @@ -1,4 +1,4 @@ -//General information about a QLab Workspace +//General information about a QLab Workspace retrieves by /workspaces namespace QControlKit { public class QWorkspaceInfo diff --git a/QControlKit/SharpOSC/TCPClient.cs b/QControlKit/SharpOSC/TCPClient.cs index 77acc65..b59634c 100644 --- a/QControlKit/SharpOSC/TCPClient.cs +++ b/QControlKit/SharpOSC/TCPClient.cs @@ -54,7 +54,7 @@ namespace SharpOSC client = new TcpClient(Address, Port); receivingThread = new Thread(ReceiveLoop); receivingThread.Start(); - Console.WriteLine($"[tcpclient] connected to <{Address}:{Port}>"); + Log.Debug($"[tcpclient] connected to <{Address}:{Port}>"); return true; } catch (Exception e) diff --git a/QControlKitXamDemo/QControlKitXamDemo.iOS/AppDelegate.cs b/QControlKitXamDemo/QControlKitXamDemo.iOS/AppDelegate.cs index fc3ccfd..7b9b1e7 100644 --- a/QControlKitXamDemo/QControlKitXamDemo.iOS/AppDelegate.cs +++ b/QControlKitXamDemo/QControlKitXamDemo.iOS/AppDelegate.cs @@ -23,7 +23,7 @@ namespace QControlKitXamDemo.iOS public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); - Log.Logger = new LoggerConfiguration().WriteTo.NSLog().MinimumLevel.Debug().CreateLogger(); + Log.Logger = new LoggerConfiguration().WriteTo.NSLog().MinimumLevel.Information().CreateLogger(); LoadApplication(new App()); return base.FinishedLaunching(app, options); diff --git a/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs b/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs index bb18835..b5e95e8 100644 --- a/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs +++ b/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs @@ -5,6 +5,9 @@ using QControlKitXamDemo.ViewModels; using Xamarin.Essentials; using Xamarin.Forms; +using QControlKit.Events; +using QControlKit.Constants; + namespace QControlKitXamDemo { public partial class CueListPage : ContentPage diff --git a/QControlKitXamDemo/QControlKitXamDemo/MainPage.xaml.cs b/QControlKitXamDemo/QControlKitXamDemo/MainPage.xaml.cs index f67befc..03db4a2 100644 --- a/QControlKitXamDemo/QControlKitXamDemo/MainPage.xaml.cs +++ b/QControlKitXamDemo/QControlKitXamDemo/MainPage.xaml.cs @@ -5,6 +5,8 @@ using QControlKit; using System.Collections.ObjectModel; using System.Collections.Generic; +using QControlKit.Events; + namespace QControlKitXamDemo { // Learn more about making custom code visible in the Xamarin.Forms previewer @@ -28,7 +30,7 @@ namespace QControlKitXamDemo if(e.SelectedItem != null) { QWorkspace selectedWorkspace = e.SelectedItem as QWorkspace; - Console.WriteLine($"[demo] workspace: {selectedWorkspace.nameWithoutPathExtension} has been selected"); + Console.WriteLine($"[demo] Workspace <{selectedWorkspace.nameWithoutPathExtension}> has been selected"); if (selectedWorkspace.hasPasscode) { string passcode = await DisplayPromptAsync("Workspace has passcode", "Enter Passcode", maxLength: 4, keyboard: Keyboard.Numeric); @@ -49,8 +51,6 @@ namespace QControlKitXamDemo private void Browser_ServerUpdatedWorkspaces(object source, QServerUpdatedArgs args) { - Console.WriteLine(args.server.name); - ServerGroup serverGroup = new ServerGroup(args.server.name); serverGroup.AddRange(args.server.workspaces); diff --git a/QControlKitXamDemo/QControlKitXamDemo/ViewModels/QCueViewModel.cs b/QControlKitXamDemo/QControlKitXamDemo/ViewModels/QCueViewModel.cs index 9540baf..73018a2 100644 --- a/QControlKitXamDemo/QControlKitXamDemo/ViewModels/QCueViewModel.cs +++ b/QControlKitXamDemo/QControlKitXamDemo/ViewModels/QCueViewModel.cs @@ -1,8 +1,11 @@ using QControlKit; -using Serilog; using System.ComponentModel; using System.Runtime.CompilerServices; using Xamarin.Forms; + +using QControlKit.Events; +using QControlKit.Constants; + namespace QControlKitXamDemo.ViewModels { public class QCueViewModel : INotifyPropertyChanged @@ -23,7 +26,7 @@ namespace QControlKitXamDemo.ViewModels { foreach(var property in args.properties) { - Log.Debug($"[cueviewmodel] property <{property}> has been updated."); + //Log.Debug($"[cueviewmodel] property <{property}> has been updated."); if (property.Equals(QOSCKey.Name)) { OnPropertyChanged("name");