mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-14 11:53:55 +00:00
General Housekeeping
This commit is contained in:
@@ -14,6 +14,11 @@ namespace qController
|
||||
|
||||
string Address;
|
||||
int Port;
|
||||
|
||||
|
||||
public delegate void WorkspaceDisconnectHandler(object source, EventArgs args);
|
||||
public event WorkspaceDisconnectHandler WorkspaceDisconnect;
|
||||
|
||||
public QClient(string address, int port)
|
||||
{
|
||||
Address = address;
|
||||
@@ -26,7 +31,6 @@ namespace qController
|
||||
tcpSender.MessageReceived += OnMessageReceived;
|
||||
qReceiver.UpdateMessageReceived += OnMessageReceived;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnMessageReceived(object source, MessageEventArgs args)
|
||||
@@ -73,7 +77,7 @@ namespace qController
|
||||
{
|
||||
if (msg.Address.Contains("disconnect"))
|
||||
{
|
||||
Console.WriteLine("Workspace is disonnecting");
|
||||
OnWorkspaceDisconnect();
|
||||
}
|
||||
else if (msg.Address.Contains("cue_id"))
|
||||
{
|
||||
@@ -87,26 +91,25 @@ namespace qController
|
||||
qParser.ParseMessage(msg);
|
||||
UpdateSelectedCue();
|
||||
}
|
||||
|
||||
}
|
||||
else if (msg.Address.Contains("workspace"))
|
||||
{
|
||||
{
|
||||
UpdateWorkspace("not yet implemented");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSpecificCue(string cue_id)
|
||||
{
|
||||
Console.WriteLine("Updating specific cue: " + cue_id);
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\",\"notes\"]";
|
||||
|
||||
string valuesForKeys = "[\"number\",\"uniqueID\",\"flagged\",\"listName\",\"type\",\"colorName\",\"name\",\"armed\",\"displayName\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"notes\",\"levels\"]";
|
||||
|
||||
string address = "/cue_id/" + cue_id + "/valuesForKeys";
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue()
|
||||
{
|
||||
Console.WriteLine("Updating selected cue");
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\",\"notes\"]";
|
||||
string valuesForKeys = "[\"number\",\"uniqueID\",\"flagged\",\"listName\",\"type\",\"colorName\",\"name\",\"armed\",\"displayName\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"notes\",\"levels\"]";
|
||||
sendAndReceiveStringArgs("/cue/selected/valuesForKeys", valuesForKeys);
|
||||
}
|
||||
|
||||
@@ -115,6 +118,12 @@ namespace qController
|
||||
Console.WriteLine("Workspace needs to be updated: " + ws_id);
|
||||
}
|
||||
|
||||
protected virtual void OnWorkspaceDisconnect()
|
||||
{
|
||||
if (WorkspaceDisconnect != null)
|
||||
WorkspaceDisconnect(this, new EventArgs());
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
udpSender.Close();
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace qController
|
||||
{
|
||||
|
||||
QUpdater qUpdater;
|
||||
QCue selectedCue;
|
||||
public QClient qClient;
|
||||
public QWorkSpace qWorkspace;
|
||||
public string playbackPosition;
|
||||
@@ -20,45 +19,11 @@ namespace qController
|
||||
qClient = new QClient(address, port);
|
||||
qUpdater = new QUpdater(this);
|
||||
qUpdater.Start();
|
||||
qClient.qParser.SelectedCueUpdated += this.OnSelectedCueUpdated;
|
||||
qClient.qParser.WorkspaceUpdated += this.OnWorkspaceUpdated;
|
||||
qClient.qParser.PlaybackPositionUpdated += this.OnPlaybackPositionUpdated;
|
||||
qClient.qParser.CueInfoUpdated += this.OnCueUpdateReceived;
|
||||
qClient.qParser.AudioLevelsUpdated += this.OnAudioLevelsUpdated;
|
||||
qClient.qParser.ChildrenUpdated += this.OnChildrenUpdated;
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
qClient.sendAndReceiveString("/cueLists");
|
||||
|
||||
}
|
||||
|
||||
private void OnChildrenUpdated(object source, ChildrenEventArgs args)
|
||||
{
|
||||
Console.WriteLine("Children Updated in QController: " + args.cue_id);
|
||||
qWorkspace.UpdateChildren(args.cue_id, args.children);
|
||||
|
||||
foreach (var cueList in qWorkspace.data)
|
||||
{
|
||||
foreach (var cue in cueList.cues)
|
||||
{
|
||||
if (cue.type == "Group")
|
||||
{
|
||||
if (cue.cues == null)
|
||||
{
|
||||
Console.WriteLine("Next Group Cue Found");
|
||||
qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAudioLevelsUpdated(object source, AudioLevelArgs args)
|
||||
{
|
||||
if(qWorkspace != null)
|
||||
qWorkspace.UpdateLevels(args.cue_id, args.levels);
|
||||
}
|
||||
public void Connect()
|
||||
{
|
||||
qClient.sendStringUDP("/connect");
|
||||
@@ -74,64 +39,6 @@ namespace qController
|
||||
qClient.sendArgsUDP("/connect", pass);
|
||||
}
|
||||
|
||||
public void updateCueValue(QCue cue, string property, object newValue){
|
||||
//qClient.sendArgs("/cue_id/"+cue.uniqueID+"/"+property, newValue);
|
||||
}
|
||||
|
||||
public void RefreshGroupCues()
|
||||
{
|
||||
if (qWorkspace.ChildrenPopulated())
|
||||
return;
|
||||
foreach (var cueList in qWorkspace.data)
|
||||
{
|
||||
foreach (var cue in cueList.cues)
|
||||
{
|
||||
if (cue.type == "Group")
|
||||
{
|
||||
Console.WriteLine("First Group Cue Found");
|
||||
qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSelectedCueUpdated(object source, CueEventArgs args)
|
||||
{
|
||||
selectedCue = args.Cue;
|
||||
Console.WriteLine("Selected cue updated: " + selectedCue.uniqueID);
|
||||
}
|
||||
|
||||
public void OnWorkspaceUpdated(object source, WorkspaceEventArgs args)
|
||||
{
|
||||
qWorkspace = args.UpdatedWorkspace;
|
||||
Console.WriteLine("Workspace updated in QController: " + qWorkspace.workspace_id);
|
||||
qWorkspace.PrintStats();
|
||||
playbackPosition = null;
|
||||
qClient.UpdateSelectedCue();
|
||||
}
|
||||
|
||||
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
||||
{
|
||||
playbackPosition = args.PlaybackPosition;
|
||||
Console.WriteLine("Playback Position updated in QController: " + playbackPosition);
|
||||
}
|
||||
|
||||
public void OnCueUpdateReceived(object source, CueEventArgs args)
|
||||
{
|
||||
qWorkspace.UpdateCue(args.Cue);
|
||||
Console.WriteLine("Cue updated in QController: " + args.Cue.uniqueID );
|
||||
if (playbackPosition == null)
|
||||
{
|
||||
playbackPosition = args.Cue.uniqueID;
|
||||
}
|
||||
if(args.Cue.type == "Audio" || args.Cue.type == "Mic" || args.Cue.type == "Video")
|
||||
{
|
||||
Console.WriteLine("Cue has audio levels...sending request");
|
||||
qClient.sendStringUDP("/cue_id/" + args.Cue.uniqueID + "/levels");
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill(){
|
||||
qUpdater.Kill();
|
||||
qClient.Close();
|
||||
|
||||
@@ -15,19 +15,8 @@ namespace qController
|
||||
}
|
||||
}
|
||||
|
||||
public class AudioLevelArgs : EventArgs
|
||||
{
|
||||
public string cue_id
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public List<double> levels
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class WorkspaceEventArgs : EventArgs
|
||||
{
|
||||
public QWorkSpace UpdatedWorkspace
|
||||
@@ -36,6 +25,7 @@ namespace qController
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaybackPositionArgs : EventArgs
|
||||
{
|
||||
public string PlaybackPosition
|
||||
@@ -44,6 +34,7 @@ namespace qController
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectEventArgs : EventArgs
|
||||
{
|
||||
public string Status
|
||||
@@ -52,6 +43,7 @@ namespace qController
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class ChildrenEventArgs : EventArgs
|
||||
{
|
||||
public string cue_id
|
||||
@@ -73,7 +65,6 @@ namespace qController
|
||||
}
|
||||
|
||||
public delegate void SelectedCueUpdatedHandler(object source, CueEventArgs args);
|
||||
public delegate void AudioLevelsUpdatedHandler(object source, AudioLevelArgs args);
|
||||
public delegate void WorkspaceUpdatedHandler(object source, WorkspaceEventArgs args);
|
||||
public delegate void CueInfoUpdatedHandler(object source, CueEventArgs args);
|
||||
public delegate void PlaybackPositionUpdatedHandler(object source, PlaybackPositionArgs args);
|
||||
@@ -82,7 +73,6 @@ namespace qController
|
||||
public event ChildrenUpdateHandler ChildrenUpdated;
|
||||
public event ConnectionStatusHandler ConnectionStatusChanged;
|
||||
public event SelectedCueUpdatedHandler SelectedCueUpdated;
|
||||
public event AudioLevelsUpdatedHandler AudioLevelsUpdated;
|
||||
public event WorkspaceUpdatedHandler WorkspaceUpdated;
|
||||
public event CueInfoUpdatedHandler CueInfoUpdated;
|
||||
public event PlaybackPositionUpdatedHandler PlaybackPositionUpdated;
|
||||
@@ -92,15 +82,10 @@ namespace qController
|
||||
{
|
||||
if (msg.Address.Contains("valuesForKeys"))
|
||||
{
|
||||
if (msg.Address.Contains("WithArguments"))
|
||||
ParseLevelInfo(msg);
|
||||
else
|
||||
ParseCueUpdateInfo(msg);
|
||||
ParseCueUpdateInfo(msg);
|
||||
}
|
||||
else if (msg.Address.Contains("notes"))
|
||||
ParseNoteInfo(msg);
|
||||
else if (msg.Address.Contains("levels"))
|
||||
ParseLevelInfo(msg);
|
||||
else if (msg.Address.Contains("cueLists"))
|
||||
ParseWorkspaceInfo(msg);
|
||||
else if (msg.Address.Contains("playbackPosition"))
|
||||
@@ -140,6 +125,7 @@ namespace qController
|
||||
public void ParseCueUpdateInfo(OscMessage msg)
|
||||
{
|
||||
JToken cueUpdate = OSC2JSON(msg);
|
||||
Console.WriteLine(OSC2JSON(msg).ToString());
|
||||
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
||||
OnCueInfoUpdated(cue);
|
||||
}
|
||||
@@ -154,12 +140,6 @@ namespace qController
|
||||
//JToken cueInfo = OSC2JSON(msg);
|
||||
}
|
||||
|
||||
public void ParseLevelInfo(OscMessage msg){
|
||||
var cue_id = msg.Address.Split('/')[3];
|
||||
JToken levels = OSC2JSON(msg)[0];
|
||||
OnAudioLevelsUpdated(cue_id, levels.ToObject<List<double>>());
|
||||
}
|
||||
|
||||
public void ParseWorkspaceInfo(OscMessage msg)
|
||||
{
|
||||
if (msg.Arguments.Count > 0)
|
||||
@@ -196,11 +176,6 @@ namespace qController
|
||||
SelectedCueUpdated(this, new CueEventArgs() { Cue = cue });
|
||||
}
|
||||
|
||||
protected virtual void OnAudioLevelsUpdated(string id, List<double> audioLevels){
|
||||
if (AudioLevelsUpdated != null)
|
||||
AudioLevelsUpdated(this, new AudioLevelArgs { cue_id = id, levels = audioLevels });
|
||||
}
|
||||
|
||||
protected virtual void OnCueInfoUpdated(QCue cue)
|
||||
{
|
||||
if (CueInfoUpdated != null)
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace qController
|
||||
{
|
||||
qController = controller;
|
||||
updateThread = new Thread(new ThreadStart(UpdateLoop));
|
||||
|
||||
qController.qClient.qParser.ChildrenUpdated += OnChildrenUpdated;
|
||||
qController.qClient.qParser.CueInfoUpdated += OnCueUpdateReceived;
|
||||
qController.qClient.qParser.WorkspaceUpdated += OnWorkspaceUpdated;
|
||||
qController.qClient.qParser.PlaybackPositionUpdated += OnPlaybackPositionUpdated;
|
||||
|
||||
}
|
||||
|
||||
public void Start(){
|
||||
@@ -29,6 +35,59 @@ namespace qController
|
||||
});
|
||||
}
|
||||
|
||||
public void OnCueUpdateReceived(object source, CueEventArgs args)
|
||||
{
|
||||
qController.qWorkspace.UpdateCue(args.Cue);
|
||||
if (qController.playbackPosition == null)
|
||||
{
|
||||
qController.playbackPosition = args.Cue.uniqueID;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChildrenUpdated(object source, ChildrenEventArgs args)
|
||||
{
|
||||
qController.qWorkspace.UpdateChildren(args.cue_id, args.children);
|
||||
|
||||
if (!qController.qWorkspace.IsPopulated)
|
||||
{
|
||||
QCue cue = qController.qWorkspace.GetEmptyGroup();
|
||||
if(cue != null)
|
||||
{
|
||||
qController.qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnWorkspaceUpdated(object source, WorkspaceEventArgs args)
|
||||
{
|
||||
qController.qWorkspace = args.UpdatedWorkspace;
|
||||
qController.playbackPosition = null;
|
||||
qController.qClient.UpdateSelectedCue();
|
||||
}
|
||||
|
||||
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
||||
{
|
||||
qController.playbackPosition = args.PlaybackPosition;
|
||||
}
|
||||
|
||||
public void RefreshGroupCues()
|
||||
{
|
||||
if (qController.qWorkspace.ChildrenPopulated())
|
||||
return;
|
||||
foreach (var cueList in qController.qWorkspace.data)
|
||||
{
|
||||
foreach (var cue in cueList.cues)
|
||||
{
|
||||
if (cue.type == "Group")
|
||||
{
|
||||
Console.WriteLine("First Group Cue Found");
|
||||
qController.qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendThump()
|
||||
{
|
||||
qController.qClient.sendStringUDP("/thump");
|
||||
|
||||
Reference in New Issue
Block a user