Initizalize version only if there isn't one in workspaceInfo

This commit is contained in:
Joel Wetzell
2020-06-10 13:25:34 -05:00
parent bfe212c0f9
commit ce1114e78c
+41 -12
View File
@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Timers; using System.Timers;
namespace QSharp namespace QSharp
@@ -32,7 +33,7 @@ namespace QSharp
name = ""; name = "";
uniqueID = ""; uniqueID = "";
connected = false; connected = false;
passcode = "";
hasPasscode = false; hasPasscode = false;
defaultSendUpdatesOSC = false; defaultSendUpdatesOSC = false;
@@ -41,21 +42,23 @@ namespace QSharp
root.setProperty("Cue Lists", QOSCKey.Name, false); root.setProperty("Cue Lists", QOSCKey.Name, false);
root.setProperty(QCueType.CueList, QOSCKey.Type, false); root.setProperty(QCueType.CueList, QOSCKey.Type, false);
//TODO: add version if (version == null || version.Length <= 0)
version = "3.0.0"; version = "3.0.0";
} }
public QWorkspace(QWorkspaceInfo workspaceInfo, QServer server) public QWorkspace(QWorkspaceInfo workspaceInfo, QServer server)
{ {
Init();
if(workspaceInfo.uniqueID.Length > 0)
uniqueID = workspaceInfo.uniqueID;
if (workspaceInfo.version.Length > 0) if (workspaceInfo.version.Length > 0)
version = workspaceInfo.version; version = workspaceInfo.version;
Init();
if (workspaceInfo.uniqueID.Length > 0)
uniqueID = workspaceInfo.uniqueID;
updateWithWorkspaceInfo(workspaceInfo); updateWithWorkspaceInfo(workspaceInfo);
client = new QClient(server.host, server.port); client = new QClient(server.host, server.port);
@@ -97,24 +100,24 @@ namespace QSharp
public QCue firstCueList { get { return root.firstCue; } } public QCue firstCueList { get { return root.firstCue; } }
public string fullNameWithCueList(QCue cueList) { return ""; } public string fullNameWithCueList(QCue cueList) { return ""; }
//TODO other convenience methods //TODO other convenience methods
public string[] versionParts { get { return version.Split('.'); } }
public bool connectedToQLab3 { get { return false; } } //TODO implement the version system public bool connectedToQLab3 { get { return versionParts[0] == "3"; } }
#region Connection/reconnection #region Connection/reconnection
public void connectWithPasscode(string passcode) public void connectWithPasscode(string passcode)
{ {
//TODO //TODO
if (!client.connect()) if (!client.connect())
{ {
System.Console.WriteLine($"[workspace] *** Error: couldn't connect to server"); System.Console.WriteLine($"[workspace] *** Error: couldn't connect to server client is not connected");
return; return;
} }
//save password for reuse
this.passcode = passcode;
System.Console.WriteLine("[workspace] connecting..."); System.Console.WriteLine("[workspace] connecting...");
client.sendMessage($"{workspacePrefix}/connect",passcode); client.sendMessage($"{workspacePrefix}/connect",passcode);
} }
private void finishConnection() private void finishConnection()
@@ -244,11 +247,33 @@ namespace QSharp
#endregion #endregion
#region Cue Getters/Setters #region Cue Getters/Setters
public void valueForKey(QCue cue, string key) { client.sendMessage(addressForCue(cue, key)); }
//TODO //TODO
public void valuesForKeys(QCue cue, string[] keys) { }
//TODO
public void updatePropertySend(QCue cue, object value, string key) { }
//TODO
public void updatePropertiesSend(QCue cue, object[] values, string key) { }
//TODO
public void updateAllCueProperties()
{
root.sendAllPropertiesToQLab();
}
public void runningOrPausedCues()
{
client.sendMessage($"{workspacePrefix}/runningOrPausedCues");
}
#endregion #endregion
#region Property Fetching #region Property Fetching
//TODO //TODO
public void fetchPropertiesForCue(QCue cue, string[] keys)
{
}
#endregion #endregion
#region OSC address helpers #region OSC address helpers
@@ -286,7 +311,11 @@ namespace QSharp
private void OnWorkspaceConnectionError(object source, QWorkspaceConnectionErrorArgs args) private void OnWorkspaceConnectionError(object source, QWorkspaceConnectionErrorArgs args)
{ {
if (args.status.Equals("badpass")) if (args.status.Equals("badpass"))
{
//clear passcode if there was one set in the connect() method
this.passcode = "";
Console.WriteLine($"[workspace] *** Error: Password for workspace {name} was incorrect!"); Console.WriteLine($"[workspace] *** Error: Password for workspace {name} was incorrect!");
}
else else
Console.WriteLine($"[workspace] *** Error: Unable to connect to workspace: {name} on server: {server.name}"); Console.WriteLine($"[workspace] *** Error: Unable to connect to workspace: {name} on server: {server.name}");