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
{
@@ -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
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
namespace QControlKit
namespace QControlKit.Events
{
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 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 Serilog;
using QControlKit.Constants;
using QControlKit.Events;
namespace QControlKit
{
public class QBrowser
+3 -1
View File
@@ -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
+4 -1
View File
@@ -6,7 +6,7 @@
<Authors>Joel Wetzell</Authors>
<Version>1.0.0-devel</Version>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>0.0.3</PackageVersion>
<PackageVersion>0.0.4</PackageVersion>
<PackageId>QControlKit</PackageId>
</PropertyGroup>
@@ -15,4 +15,7 @@
<PackageReference Include="Zeroconf" Version="3.4.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Constants\" />
</ItemGroup>
</Project>
+12 -13
View File
@@ -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<string> fadeModeTitles() { throw new NotImplementedException(); }
#endregion
//copied: yes
//implemented: not all
#region Convenience Accessors
public List<QCue> 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<string> 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<string> propertiesUpdated = new List<string>();
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<string> 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);
+1 -1
View File
@@ -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)}";
}
}
+7 -1
View File
@@ -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<QWorkspace> workspaces = new List<QWorkspace>();
@@ -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();
}
}
+11 -13
View File
@@ -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
}
+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
{
public class QWorkspaceInfo
+1 -1
View File
@@ -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)
@@ -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);
@@ -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
@@ -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);
@@ -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");