Logging and file clean up

This commit is contained in:
2020-09-08 14:39:39 -05:00
parent 2cfa495a24
commit 9b46f64aa0
17 changed files with 69 additions and 51 deletions
@@ -1,4 +1,4 @@
namespace QControlKit namespace QControlKit.Constants
{ {
public class QColor public class QColor
{ {
@@ -1,10 +1,11 @@
namespace QControlKit namespace QControlKit.Constants
{ {
static class QBonjour static class QBonjour
{ {
public const string TCPService = "_qlab._tcp.local."; public const string TCPService = "_qlab._tcp.local.";
public const string UDPService = "_qlab._udp.local."; public const string UDPService = "_qlab._udp.local.";
} }
static class QCueType static class QCueType
{ {
public const string Cue = "Cue"; public const string Cue = "Cue";
@@ -121,17 +122,16 @@
} }
//these should really be enums enum QFadeMode
static class QFadeMode
{ {
public const int Absolute = 0; Absolute = 0,
public const int Relative = 1; Relative = 1
} }
static class QContinueMode enum QContinueMode
{ {
public const int NoContinue = 0; NoContinue = 0,
public const int AutoContinue = 1; AutoContinue = 1,
public const int AutoFollow = 2; AutoFollow = 2
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace QControlKit namespace QControlKit.Events
{ {
public class QServerFoundArgs : EventArgs public class QServerFoundArgs : EventArgs
{ {
+1 -1
View File
@@ -1,4 +1,4 @@
namespace QControlKit namespace QControlKit.Events
{ {
public delegate void QServerFoundHandler(object source, QServerFoundArgs args); public delegate void QServerFoundHandler(object source, QServerFoundArgs args);
public delegate void QServerUpdatedHandler(object source, QServerUpdatedArgs args); public delegate void QServerUpdatedHandler(object source, QServerUpdatedArgs args);
+5 -1
View File
@@ -1,7 +1,11 @@
using Zeroconf; //TODO period updating of servers, proper server removing/workspace updating
using Zeroconf;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Serilog; using Serilog;
using QControlKit.Constants;
using QControlKit.Events;
namespace QControlKit namespace QControlKit
{ {
public class QBrowser public class QBrowser
+3 -1
View File
@@ -5,6 +5,9 @@ using Newtonsoft.Json.Linq;
using SharpOSC; using SharpOSC;
using Serilog; using Serilog;
using QControlKit.Events;
using QControlKit.Constants;
namespace QControlKit namespace QControlKit
{ {
public class QClient public class QClient
@@ -107,7 +110,6 @@ namespace QControlKit
} }
else if (message.IsConnect) else if (message.IsConnect)
{ {
//Log.Debug($"[client] Connection message received: {message.response}");
if (message.response.ToString() == "ok") if (message.response.ToString() == "ok")
OnWorkspaceConnected(); OnWorkspaceConnected();
else else
+4 -1
View File
@@ -6,7 +6,7 @@
<Authors>Joel Wetzell</Authors> <Authors>Joel Wetzell</Authors>
<Version>1.0.0-devel</Version> <Version>1.0.0-devel</Version>
<PackOnBuild>true</PackOnBuild> <PackOnBuild>true</PackOnBuild>
<PackageVersion>0.0.3</PackageVersion> <PackageVersion>0.0.4</PackageVersion>
<PackageId>QControlKit</PackageId> <PackageId>QControlKit</PackageId>
</PropertyGroup> </PropertyGroup>
@@ -15,4 +15,7 @@
<PackageReference Include="Zeroconf" Version="3.4.2" /> <PackageReference Include="Zeroconf" Version="3.4.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Constants\" />
</ItemGroup>
</Project> </Project>
+12 -13
View File
@@ -5,6 +5,9 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using QControlKit.Events;
using QControlKit.Constants;
namespace QControlKit namespace QControlKit
{ {
public class QCue public class QCue
@@ -42,7 +45,7 @@ namespace QControlKit
//this breaks things??? //this breaks things???
//it definitely is in the original but somehow the recursion is not working as I expect.. //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]; /*JToken children = dict[QOSCKey.Cues];
if(children != null && children.Type == JTokenType.Array) if(children != null && children.Type == JTokenType.Array)
@@ -102,6 +105,7 @@ namespace QControlKit
//isEqual? //isEqual?
//hash? //hash?
//compare? //compare?
//TODO
public bool isEqualToCue(QCue cue) { throw new NotImplementedException(); } public bool isEqualToCue(QCue cue) { throw new NotImplementedException(); }
public void setWorkspace(QWorkspace workspace) public void setWorkspace(QWorkspace workspace)
{ {
@@ -121,7 +125,7 @@ namespace QControlKit
return; return;
childCues.Add(cue); childCues.Add(cue);
childCuesUIDMap.Add(uid, 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 //reset sorting index
} }
public void removeChildCue(QCue cue) { throw new NotImplementedException(); } public void removeChildCue(QCue cue) { throw new NotImplementedException(); }
@@ -130,13 +134,12 @@ namespace QControlKit
//copied: yes //copied: yes
//implemented: no //implemented: no
//TODO
#region Class Methods #region Class Methods
public string iconForType(string type) { throw new NotImplementedException(); } public string iconForType(string type) { throw new NotImplementedException(); }
public List<string> fadeModeTitles() { throw new NotImplementedException(); } public List<string> fadeModeTitles() { throw new NotImplementedException(); }
#endregion #endregion
//copied: yes
//implemented: not all
#region Convenience Accessors #region Convenience Accessors
public List<QCue> cues public List<QCue> cues
{ {
@@ -482,7 +485,6 @@ namespace QControlKit
} }
//TODO add quaternion property and setter //TODO add quaternion property and setter
public Size surfaceSize() { throw new NotImplementedException(); } public Size surfaceSize() { throw new NotImplementedException(); }
public Size cueSize() { throw new NotImplementedException(); } public Size cueSize() { throw new NotImplementedException(); }
public List<string> availableSurfaceName() { throw new NotImplementedException(); } public List<string> availableSurfaceName() { throw new NotImplementedException(); }
@@ -527,7 +529,8 @@ namespace QControlKit
if (!this.ignoreUpdates) 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; bool cueUpdated = false;
//TODO //TODO: pretty sure this is done
JObject dictObj = (JObject)dict; JObject dictObj = (JObject)dict;
List<string> propertiesUpdated = new List<string>(); List<string> propertiesUpdated = new List<string>();
foreach (var obj in dictObj) foreach (var obj in dictObj)
@@ -570,7 +573,7 @@ namespace QControlKit
return true; return true;
} }
//enqueue updated notification? //enqueue updated notification? //TODO
public bool updateChildCuesWithPropertiesArray(JToken value, bool removeUnused) public bool updateChildCuesWithPropertiesArray(JToken value, bool removeUnused)
{ {
if (!workspace.connected) if (!workspace.connected)
@@ -621,9 +624,6 @@ namespace QControlKit
#endregion #endregion
//Methods Copied: Yes
//Methods Implemented: Not all
#region Children Cues #region Children Cues
public List<string> allChildCueUids() public List<string> allChildCueUids()
{ {
@@ -807,8 +807,6 @@ namespace QControlKit
public void pullDownPropertyForKey(string key) { } public void pullDownPropertyForKey(string key) { }
//Methods Copied: Yes
//Methods Implemented: Yes
#region Actions #region Actions
public void start() { workspace.startCue(this); } public void start() { workspace.startCue(this); }
public void stop() { workspace.stopCue(this); } public void stop() { workspace.stopCue(this); }
@@ -839,6 +837,7 @@ namespace QControlKit
{ {
Print(0); Print(0);
} }
public void Print(int level) public void Print(int level)
{ {
string indent = new string(' ', level*2); string indent = new string(' ', level*2);
+1 -1
View File
@@ -19,7 +19,7 @@ namespace QControlKit
{ {
get 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)}"; return $"address: {address}, arguments: {string.Join(" - ", arguments)}";
} }
} }
+7 -1
View File
@@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using Zeroconf; using Zeroconf;
using QControlKit.Events;
namespace QControlKit namespace QControlKit
{ {
public class QServer public class QServer
@@ -13,6 +15,7 @@ namespace QControlKit
public string host { get; set; } public string host { get; set; }
public int port { get; set; } public int port { get; set; }
public string name { get; set; } public string name { get; set; }
public string version { get; set; }
public IZeroconfHost zeroconfHost; public IZeroconfHost zeroconfHost;
public List<QWorkspace> workspaces = new List<QWorkspace>(); public List<QWorkspace> workspaces = new List<QWorkspace>();
@@ -58,6 +61,9 @@ namespace QControlKit
{ {
QWorkspace workspaceToAdd = new QWorkspace(workspace, this); QWorkspace workspaceToAdd = new QWorkspace(workspace, this);
workspaces.Add(workspaceToAdd); 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); OnServerUpdated(this);
@@ -75,7 +81,7 @@ namespace QControlKit
{ {
if (workspace.connected) 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(); workspace.disconnect();
} }
} }
+11 -13
View File
@@ -6,6 +6,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Timers; using System.Timers;
using QControlKit.Events;
using QControlKit.Constants;
namespace QControlKit namespace QControlKit
{ {
public class QWorkspace public class QWorkspace
@@ -75,7 +78,7 @@ namespace QControlKit
client.CueUpdated += OnCueUpdated; client.CueUpdated += OnCueUpdated;
this.server = server; this.server = server;
Log.Debug($"[workspace] <{name}> initizalied for server: {server.name} "); Log.Debug($"[workspace] <{name}> on {server.name} initialized.");
} }
//updateWithDictionary //updateWithDictionary
@@ -125,7 +128,7 @@ namespace QControlKit
return name.Substring(0, name.Length - 6); return name.Substring(0, name.Length - 6);
return name; return name;
} }
} //TODO }
public string serverName { get { return server.name; } } public string serverName { get { return server.name; } }
@@ -144,7 +147,7 @@ namespace QControlKit
public void connect(string passcode = null) 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) if(hasPasscode && passcode == null)
{ {
@@ -155,13 +158,12 @@ namespace QControlKit
if (!client.connect()) 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; return;
} }
//save password for reuse //save password for reuse
this.passcode = passcode; this.passcode = passcode;
Log.Information("[workspace] connecting...");
if (passcode != null) if (passcode != null)
client.sendMessage($"{workspacePrefix}/connect", passcode); client.sendMessage($"{workspacePrefix}/connect", passcode);
else else
@@ -171,7 +173,6 @@ namespace QControlKit
private void finishConnection() private void finishConnection()
{ {
//TODO //TODO
Log.Information($"[workspace] connected to <{name}> running on QLab version <{version}>");
connected = true; connected = true;
startReceivingUpdates(); startReceivingUpdates();
//fetchQLabVersion(); //fetchQLabVersion();
@@ -193,7 +194,7 @@ namespace QControlKit
public void disconnect() public void disconnect()
{ {
Log.Information($"[workspace] disconnect: {name}"); Log.Information($"[workspace] disconnecting from <{name}>");
if (heartbeatTimer != null) if (heartbeatTimer != null)
stopHeartbeat(); stopHeartbeat();
stopReceivingUpdates(); stopReceivingUpdates();
@@ -232,7 +233,7 @@ namespace QControlKit
public void stopReceivingUpdates() { client.sendMessage($"{workspacePrefix}/updates", 0); } public void stopReceivingUpdates() { client.sendMessage($"{workspacePrefix}/updates", 0); }
public void enableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 1); } public void enableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 1); }
public void disableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 0); } 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 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 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"); } public void go() { client.sendMessage($"{workspacePrefix}/go"); }
@@ -410,7 +411,7 @@ namespace QControlKit
private void OnWorkspaceConnected(object source, QWorkspaceConnectedArgs args) private void OnWorkspaceConnected(object source, QWorkspaceConnectedArgs args)
{ {
Log.Debug($"[workspace] Connection being finished."); Log.Information($"[workspace] Connection to <{name}> successful, finishing things up.");
finishConnection(); finishConnection();
} }
@@ -505,7 +506,7 @@ namespace QControlKit
QCue selectedCue = cueWithID(args.cueID); QCue selectedCue = cueWithID(args.cueID);
if (selectedCue != null) 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 }); CueListChangedPlaybackPosition?.Invoke(this, new QCueListChangedPlaybackPositionArgs { cueListID = cueList.uid, cueID = selectedCue.uid });
} }
@@ -535,9 +536,7 @@ namespace QControlKit
return; return;
if (cue.ignoreUpdates) if (cue.ignoreUpdates)
return; return;
cue.updatePropertiesWithDictionary(args.data); cue.updatePropertiesWithDictionary(args.data);
} }
private void OnWorkspaceUpdated() private void OnWorkspaceUpdated()
@@ -555,7 +554,6 @@ namespace QControlKit
{ {
cueList.Print(); cueList.Print();
} }
Log.Information("[workspace] End of Workspace");
} }
#endregion #endregion
} }
+1 -1
View File
@@ -1,4 +1,4 @@
//General information about a QLab Workspace //General information about a QLab Workspace retrieves by /workspaces
namespace QControlKit namespace QControlKit
{ {
public class QWorkspaceInfo public class QWorkspaceInfo
+1 -1
View File
@@ -54,7 +54,7 @@ namespace SharpOSC
client = new TcpClient(Address, Port); client = new TcpClient(Address, Port);
receivingThread = new Thread(ReceiveLoop); receivingThread = new Thread(ReceiveLoop);
receivingThread.Start(); receivingThread.Start();
Console.WriteLine($"[tcpclient] connected to <{Address}:{Port}>"); Log.Debug($"[tcpclient] connected to <{Address}:{Port}>");
return true; return true;
} }
catch (Exception e) catch (Exception e)
@@ -23,7 +23,7 @@ namespace QControlKitXamDemo.iOS
public override bool FinishedLaunching(UIApplication app, NSDictionary options) public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{ {
global::Xamarin.Forms.Forms.Init(); 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()); LoadApplication(new App());
return base.FinishedLaunching(app, options); return base.FinishedLaunching(app, options);
@@ -5,6 +5,9 @@ using QControlKitXamDemo.ViewModels;
using Xamarin.Essentials; using Xamarin.Essentials;
using Xamarin.Forms; using Xamarin.Forms;
using QControlKit.Events;
using QControlKit.Constants;
namespace QControlKitXamDemo namespace QControlKitXamDemo
{ {
public partial class CueListPage : ContentPage public partial class CueListPage : ContentPage
@@ -5,6 +5,8 @@ using QControlKit;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Generic; using System.Collections.Generic;
using QControlKit.Events;
namespace QControlKitXamDemo namespace QControlKitXamDemo
{ {
// Learn more about making custom code visible in the Xamarin.Forms previewer // Learn more about making custom code visible in the Xamarin.Forms previewer
@@ -28,7 +30,7 @@ namespace QControlKitXamDemo
if(e.SelectedItem != null) if(e.SelectedItem != null)
{ {
QWorkspace selectedWorkspace = e.SelectedItem as QWorkspace; 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) if (selectedWorkspace.hasPasscode)
{ {
string passcode = await DisplayPromptAsync("Workspace has passcode", "Enter Passcode", maxLength: 4, keyboard: Keyboard.Numeric); 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) private void Browser_ServerUpdatedWorkspaces(object source, QServerUpdatedArgs args)
{ {
Console.WriteLine(args.server.name);
ServerGroup serverGroup = new ServerGroup(args.server.name); ServerGroup serverGroup = new ServerGroup(args.server.name);
serverGroup.AddRange(args.server.workspaces); serverGroup.AddRange(args.server.workspaces);
@@ -1,8 +1,11 @@
using QControlKit; using QControlKit;
using Serilog;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Xamarin.Forms; using Xamarin.Forms;
using QControlKit.Events;
using QControlKit.Constants;
namespace QControlKitXamDemo.ViewModels namespace QControlKitXamDemo.ViewModels
{ {
public class QCueViewModel : INotifyPropertyChanged public class QCueViewModel : INotifyPropertyChanged
@@ -23,7 +26,7 @@ namespace QControlKitXamDemo.ViewModels
{ {
foreach(var property in args.properties) 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)) if (property.Equals(QOSCKey.Name))
{ {
OnPropertyChanged("name"); OnPropertyChanged("name");