Fix? Cue initialization...some funky recursion stuff?

This commit is contained in:
Joel Wetzell
2020-06-10 17:19:15 -05:00
parent ce1114e78c
commit 4ecc692fec
3 changed files with 67 additions and 51 deletions
+2 -2
View File
@@ -148,14 +148,14 @@ namespace QSharp
protected virtual void OnCueListsUpdated(JToken response) protected virtual void OnCueListsUpdated(JToken response)
{ {
Console.WriteLine($"[client] Cue Lists Updated Changed"); Console.WriteLine($"[client] Cue Lists Updated");
if (CueListsUpdated != null) if (CueListsUpdated != null)
CueListsUpdated(this, new QCueListsUpdatedArgs { data = response }); CueListsUpdated(this, new QCueListsUpdatedArgs { data = response });
} }
protected virtual void OnCueListChangedPlaybackPosition(string cueID) protected virtual void OnCueListChangedPlaybackPosition(string cueID)
{ {
Console.WriteLine($"[client] Playback Position changed: {cueID}"); Console.WriteLine($"[client] Playback Position Changed: {cueID}");
if (CueListChangedPlaybackPosition != null) if (CueListChangedPlaybackPosition != null)
CueListChangedPlaybackPosition(this, new QCueListChangedPlaybackPositionArgs { cueID = cueID }); CueListChangedPlaybackPosition(this, new QCueListChangedPlaybackPositionArgs { cueID = cueID });
} }
+61 -47
View File
@@ -38,23 +38,29 @@ namespace QSharp
init(); init();
this.workspace = workspace; this.workspace = workspace;
JToken children = dict[QOSCKey.Cues]; //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
/*JToken children = dict[QOSCKey.Cues];
if(children != null && children.Type == JTokenType.Array) if(children != null && children.Type == JTokenType.Array)
{ {
//Console.WriteLine($"[cue] new cue being created with {children.Count()} childCues"); Console.WriteLine($"[cue] new cue being created with {children.Count()} childCues");
foreach (var aChildDict in children) foreach (var aChildDict in children)
{ {
string uid = (string)aChildDict[QOSCKey.UID]; string uid = (string)aChildDict[QOSCKey.UID];
//Console.WriteLine($"[cue] childDict with uid: {uid} being processed"); //Console.WriteLine($"[cue] childDict with uid: {uid} being processed");
if (uid == null) if (uid == null)
continue; continue;
string name = dict[QOSCKey.UID].ToString();
Console.WriteLine($"[cue] calling new cue from {name}");
QCue child = new QCue(aChildDict, workspace); //QCue child = new QCue(aChildDict, workspace);
childCues.Add(child); *//*childCues.Add(child);
childCuesUIDMap.Add(uid, child); childCuesUIDMap.Add(uid, child);*//*
} }
} }*/
updatePropertiesWithDictionary(dict); updatePropertiesWithDictionary(dict);
} }
@@ -63,12 +69,12 @@ namespace QSharp
{ {
cueData = new Dictionary<string, object> { cueData = new Dictionary<string, object> {
{ QOSCKey.Flagged, false }, { QOSCKey.Flagged, false },
{ QOSCKey.Armed, false }, { QOSCKey.Armed, true },
{ QOSCKey.PreWait, false }, { QOSCKey.PreWait, 0.0 },
{ QOSCKey.PercentPreWaitElapsed, false }, { QOSCKey.PercentPreWaitElapsed, 0.0 },
{ QOSCKey.PercentActionElapsed, false }, { QOSCKey.PercentActionElapsed, 0.0 },
{ QOSCKey.PostWait, false }, { QOSCKey.PostWait, 0.0 },
{ QOSCKey.PercentPostWaitElapsed, false }, { QOSCKey.PercentPostWaitElapsed, 0.0 },
{ QOSCKey.IsPanicking, false }, { QOSCKey.IsPanicking, false },
{ QOSCKey.IsTailingOut, false }, { QOSCKey.IsTailingOut, false },
{ QOSCKey.IsRunning, false }, { QOSCKey.IsRunning, false },
@@ -76,9 +82,8 @@ namespace QSharp
{ QOSCKey.IsPaused, false }, { QOSCKey.IsPaused, false },
{ QOSCKey.IsBroken, false }, { QOSCKey.IsBroken, false },
{ QOSCKey.IsOverridden, false }, { QOSCKey.IsOverridden, false },
{ QOSCKey.ContinueMode, false } { QOSCKey.ContinueMode, 0 }
}; };
//TODO init cueData with some keys
childCues = new List<QCue>(); childCues = new List<QCue>();
childCuesUIDMap = new Dictionary<string, QCue>(); childCuesUIDMap = new Dictionary<string, QCue>();
@@ -166,7 +171,11 @@ namespace QSharp
{ {
get get
{ {
return propertyForKey(QOSCKey.Number).ToString(); object num = propertyForKey(QOSCKey.Number);
if (num != null)
return num.ToString();
else
return "";
} }
} }
public string uid public string uid
@@ -209,35 +218,35 @@ namespace QSharp
{ {
get get
{ {
return (bool)propertyForKey("OSCNameKey"); return (bool)propertyForKey(QOSCKey.IsOverridden);
} }
} }
public bool IsBroken public bool IsBroken
{ {
get get
{ {
return (bool)propertyForKey("OSCNameKey"); return (bool)propertyForKey(QOSCKey.IsBroken);
} }
} }
public bool IsRunning public bool IsRunning
{ {
get get
{ {
return (bool)propertyForKey("OSCNameKey"); return (bool)propertyForKey(QOSCKey.IsRunning);
} }
} }
public bool IsTailingOut public bool IsTailingOut
{ {
get get
{ {
return (bool)propertyForKey("OSCNameKey"); return (bool)propertyForKey(QOSCKey.IsTailingOut);
} }
} }
public bool IsPanicking public bool IsPanicking
{ {
get get
{ {
return (bool)propertyForKey("OSCNameKey"); return (bool)propertyForKey(QOSCKey.IsPanicking);
} }
} }
public bool IsGroup public bool IsGroup
@@ -267,8 +276,13 @@ namespace QSharp
get get
{ {
string number = this.number; string number = this.number;
if (number.Length > 0) if(number != null)
return $"{number} \u00b7 {nonEmptyName}"; {
if (number.Length > 0)
return $"{number} \u00b7 {nonEmptyName}";
else
return nonEmptyName;
}
else else
return nonEmptyName; return nonEmptyName;
} }
@@ -292,7 +306,6 @@ namespace QSharp
public string workspaceName{ get { return workspace.name; } } public string workspaceName{ get { return workspace.name; } }
public double currentDuration public double currentDuration
{ {
get get
{ {
//try v4 current duration key first //try v4 current duration key first
@@ -330,14 +343,22 @@ namespace QSharp
get get
{ {
//TODO //TODO
return (string)propertyForKey("patchDecription"); return propertyForKey("patchDecription").ToString();
} }
} }
//TODO: THIS IS WHERE THINGS START TO GET TRICKY! //TODO: THIS IS WHERE THINGS START TO GET TRICKY!
//TODO add object color method //TODO add object color method
public string color { get { return propertyForKey(QOSCKey.ColorName).ToString(); } } public string color {
get {
object col = propertyForKey(QOSCKey.ColorName);
if (col != null)
return col.ToString();
else
return "none";
}
}
//TODO add quaternion property and setter //TODO add quaternion property and setter
@@ -411,10 +432,6 @@ namespace QSharp
//Implemented: Not all //Implemented: Not all
#region Update Methods #region Update Methods
public bool updatePropertiesWithDictionary(JToken dict) public bool updatePropertiesWithDictionary(JToken dict)
{
return updatePropertiesWithDictionary(dict, true);
}
public bool updatePropertiesWithDictionary(JToken dict, bool notify)
{ {
bool cueUpdated = false; bool cueUpdated = false;
@@ -440,18 +457,18 @@ namespace QSharp
if (!cueUpdated) if (!cueUpdated)
return false; return false;
if (notify)
Console.WriteLine("should notify cue updated."); Console.WriteLine($"[cue] {nonEmptyName} has been updated.");
//something about notifying cueUpdated ? OnCueUpdated event handler maybe? //something about notifying cueUpdated ? OnCueUpdated event handler maybe?
return true; return true;
} }
//enqueue updated notification? //enqueue updated notification?
public void updateChildCuesWithPropertiesArray(JToken value, bool removeUnused) public bool updateChildCuesWithPropertiesArray(JToken value, bool removeUnused)
{ {
if (!workspace.connected) if (!workspace.connected)
return; return false;
List<string> previousUids = null; List<string> previousUids = null;
if (removeUnused) if (removeUnused)
@@ -490,12 +507,10 @@ namespace QSharp
child.sortIndex = index; child.sortIndex = index;
addChildCue(child, uid); addChildCue(child, uid);
needsNotifyCueUpdated = true; needsNotifyCueUpdated = true;
} }
index++; index++;
} }
return needsNotifyCueUpdated;
//TODO: TEST?! //TODO: TEST?!
} }
#endregion #endregion
@@ -507,8 +522,9 @@ namespace QSharp
#region Children Cues #region Children Cues
public List<string> allChildCueUids() public List<string> allChildCueUids()
{ {
List<string> uids = new List<string>(childCuesUIDMap.Keys);
//TODO //TODO
return new List<string>(); return uids;
} }
public QCue cueAtIndex(int index) public QCue cueAtIndex(int index)
{ {
@@ -574,7 +590,6 @@ namespace QSharp
{ {
if (existingValue == value || existingValue.Equals(value)) if (existingValue == value || existingValue.Equals(value))
{ {
//Console.WriteLine($"[cue] skipping set property: {key} with type: {value.GetType()} and value: {value}");
return false; return false;
} }
} }
@@ -645,11 +660,12 @@ namespace QSharp
//TODO //TODO
public void sendAllPropertiesToQLab() { } public void sendAllPropertiesToQLab() { }
//TODO //TODO: I don't think I'll do this one
public void pullDownPropertyForKey(string key) { } public void pullDownPropertyForKey(string key) { }
//TODO public void setPlaybackPositionID(string cueID, bool osc) {
public void setPlaybackPositionID(string cueID, bool osc) { } setProperty(cueID, QOSCKey.PlaybackPositionId, osc);
}
//Methods Copied: Yes //Methods Copied: Yes
//Methods Implemented: Yes //Methods Implemented: Yes
@@ -667,24 +683,22 @@ namespace QSharp
public void panic() { workspace.panicCue(this); } public void panic() { workspace.panicCue(this); }
#endregion #endregion
#region Printing #region Printing
//this still needs fixing
public void Print() public void Print()
{ {
Console.WriteLine($"{displayName} : {color}");
if (IsGroup) if (IsGroup)
{ {
Console.WriteLine($"{displayName} : {color}");
if (cues.Count() > 0) if (cues.Count() > 0)
{ {
foreach(var cue in cues) foreach (var cue in cues)
{ {
cue.Print(); cue.Print();
} }
} }
} }
else
{
Console.WriteLine($"{displayName} : {color}");
}
} }
#endregion #endregion
} }
+3 -1
View File
@@ -418,10 +418,12 @@ namespace QSharp
#region Printing #region Printing
public void Print() public void Print()
{ {
foreach(var cueList in root.cues) Console.WriteLine($"[workspace] {name}");
foreach (var cueList in root.cues)
{ {
cueList.Print(); cueList.Print();
} }
Console.WriteLine("[workspace] End of Workspace");
} }
#endregion #endregion
} }