mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-08 08:53:46 +00:00
Switch to using local workspace for info display
This commit is contained in:
@@ -62,24 +62,38 @@ namespace qController
|
||||
|
||||
public void ProcessUpdate(OscMessage msg)
|
||||
{
|
||||
if (msg.Address.Contains("cue_id"))
|
||||
if (msg.Address.Contains("disconnect"))
|
||||
{
|
||||
Console.WriteLine("Workspace is disonnecting");
|
||||
}
|
||||
else if (msg.Address.Contains("cue_id"))
|
||||
{
|
||||
var updateID = msg.Address.Split('/').Last();
|
||||
Console.WriteLine("Cue needs to be updated: " + updateID);
|
||||
}else if (msg.Address.Contains("playbackPosition"))
|
||||
UpdateSpecificCue(updateID);
|
||||
}
|
||||
else if (msg.Address.Contains("playbackPosition"))
|
||||
{
|
||||
if (msg.Arguments.Count > 0)
|
||||
{
|
||||
Console.WriteLine("Playback position to be updated: " + msg.Arguments[0]);
|
||||
qParser.ParseMessage(msg);
|
||||
UpdateSelectedCue();
|
||||
}
|
||||
|
||||
}
|
||||
else if (msg.Address.Contains("workspace"))
|
||||
{
|
||||
UpdateWorkspace("not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateSpecificCue(string cue_id)
|
||||
{
|
||||
Console.WriteLine(cue_id);
|
||||
Console.WriteLine("Cue needs to be updated: " + 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\"]";
|
||||
string address = "/cue/" + cue_id + "/valuesForKeys";
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue()
|
||||
@@ -88,6 +102,11 @@ namespace qController
|
||||
sendAndReceiveStringArgs("/cue/selected/valuesForKeys", valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateWorkspace(string ws_id)
|
||||
{
|
||||
Console.WriteLine("Workspace needs to be updaeted: " + ws_id);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
udpSender.Close();
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace qController
|
||||
QUpdater qUpdater;
|
||||
QCue selectedCue;
|
||||
public QClient qClient;
|
||||
QWorkSpace qWorkspace;
|
||||
public QWorkSpace qWorkspace;
|
||||
public string playbackPosition;
|
||||
public QController(string address, int port)
|
||||
{
|
||||
qClient = new QClient(address, port);
|
||||
@@ -21,10 +22,11 @@ namespace qController
|
||||
|
||||
qClient.qParser.SelectedCueUpdated += this.OnSelectedCueUpdated;
|
||||
qClient.qParser.WorkspaceUpdated += this.OnWorkspaceUpdated;
|
||||
|
||||
qClient.qParser.PlaybackPositionUpdated += this.OnPlaybackPositionUpdated;
|
||||
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
qClient.sendAndReceiveString("/cueLists");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,25 +40,26 @@ namespace qController
|
||||
|
||||
public void OnSelectedCueUpdated(object source, CueEventArgs args)
|
||||
{
|
||||
selectedCue = args.SelectedCue;
|
||||
selectedCue = args.Cue;
|
||||
Console.WriteLine("Selected cue updated: " + selectedCue.uniqueID);
|
||||
foreach (var cueList in qWorkspace.data)
|
||||
{
|
||||
foreach( var cue in cueList.cues)
|
||||
{
|
||||
if(cue.uniqueID == selectedCue.uniqueID)
|
||||
{
|
||||
Console.WriteLine("Cue found in local workspace");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnWorkspaceUpdated(object source, WorkspaceEventArgs args)
|
||||
{
|
||||
|
||||
qWorkspace = args.UpdatedWorkspace;
|
||||
Console.WriteLine("Workspace updated in QController: " + qWorkspace.workspace_id);
|
||||
}
|
||||
|
||||
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: " + args.Cue.uniqueID );
|
||||
}
|
||||
public void Kill(){
|
||||
qUpdater.Kill();
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace qController
|
||||
{
|
||||
public class CueEventArgs : EventArgs
|
||||
{
|
||||
public QCue SelectedCue
|
||||
public QCue Cue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -30,6 +30,14 @@ namespace qController
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class PlaybackPositionArgs : EventArgs
|
||||
{
|
||||
public string PlaybackPosition
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class QParser
|
||||
{
|
||||
public QParser()
|
||||
@@ -40,22 +48,33 @@ 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);
|
||||
|
||||
public event SelectedCueUpdatedHandler SelectedCueUpdated;
|
||||
public event AudioLevelsUpdatedHandler AudioLevelsUpdated;
|
||||
public event WorkspaceUpdatedHandler WorkspaceUpdated;
|
||||
public event CueInfoUpdatedHandler CueInfoUpdated;
|
||||
public event PlaybackPositionUpdatedHandler PlaybackPositionUpdated;
|
||||
|
||||
public void ParseMessage(OscMessage msg){
|
||||
if (!msg.Address.Contains("null"))
|
||||
{
|
||||
if (msg.Address.Contains("valuesForKeys"))
|
||||
ParseSelectedCueInfo(msg);
|
||||
{
|
||||
if (msg.Address.Contains("selected"))
|
||||
ParseSelectedCueInfo(msg);
|
||||
else
|
||||
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"))
|
||||
ParsePositionUpdateInfo(msg);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Unknown message type");
|
||||
@@ -69,6 +88,23 @@ namespace qController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ParsePositionUpdateInfo(OscMessage msg)
|
||||
{
|
||||
if(msg.Arguments.Count > 0)
|
||||
{
|
||||
OnPlaybackPositionUpdated(msg.Arguments[0].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void ParseCueUpdateInfo(OscMessage msg)
|
||||
{
|
||||
JToken cueUpdate = OSC2JSON(msg);
|
||||
Console.WriteLine("Cue Update Received");
|
||||
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
||||
OnCueInfoUpdated(cue);
|
||||
}
|
||||
|
||||
public void ParseSelectedCueInfo(OscMessage msg){
|
||||
JToken selectedCue = OSC2JSON(msg);
|
||||
Console.WriteLine("Selected Cue Updated");
|
||||
@@ -107,12 +143,24 @@ namespace qController
|
||||
protected virtual void OnSelectedCueUpdated(QCue cue)
|
||||
{
|
||||
if (SelectedCueUpdated != null)
|
||||
SelectedCueUpdated(this, new CueEventArgs() { SelectedCue = cue });
|
||||
SelectedCueUpdated(this, new CueEventArgs() { Cue = cue });
|
||||
}
|
||||
|
||||
protected virtual void OnAudioLevelsUpdated(JToken audioLevels){
|
||||
if (AudioLevelsUpdated != null)
|
||||
AudioLevelsUpdated(this, new AudioLevelArgs { levels = audioLevels });
|
||||
}
|
||||
|
||||
protected virtual void OnCueInfoUpdated(QCue cue)
|
||||
{
|
||||
if (CueInfoUpdated != null)
|
||||
CueInfoUpdated(this, new CueEventArgs() { Cue = cue });
|
||||
}
|
||||
|
||||
protected virtual void OnPlaybackPositionUpdated(string id)
|
||||
{
|
||||
if (PlaybackPositionUpdated != null)
|
||||
PlaybackPositionUpdated(this, new PlaybackPositionArgs() { PlaybackPosition = id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace qController
|
||||
}
|
||||
public void UpdateLevels()
|
||||
{
|
||||
qController.qClient.sendAndReceiveString("/cue/selected/levels");
|
||||
//qController.qClient.sendAndReceiveString("/cue/selected/levels");
|
||||
}
|
||||
|
||||
public void Kill(){
|
||||
|
||||
@@ -9,5 +9,35 @@ namespace qController
|
||||
public List<QCueList> data { get; set; }
|
||||
public string workspace_id { get; set; }
|
||||
public string address { get; set; }
|
||||
|
||||
public QCue GetCue(string cue_id)
|
||||
{
|
||||
QCue returnCue = null;
|
||||
foreach (var cueList in data)
|
||||
{
|
||||
foreach (var cue in cueList.cues)
|
||||
{
|
||||
if(cue.uniqueID == cue_id)
|
||||
{
|
||||
returnCue = cue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnCue;
|
||||
}
|
||||
|
||||
public void UpdateCue(QCue cue)
|
||||
{
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < data[i].cues.Count; j++)
|
||||
{
|
||||
if(data[i].cues[j].uniqueID == cue.uniqueID)
|
||||
{
|
||||
data[i].cues[j] = cue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace qController
|
||||
qController = new QController(address, 53000);
|
||||
qController.qClient.qParser.SelectedCueUpdated += SelectedCueUpdated;
|
||||
qController.qClient.qParser.WorkspaceUpdated += WorkspaceUpdated;
|
||||
|
||||
qController.qClient.qParser.PlaybackPositionUpdated += PlaybackPositionUpdated;
|
||||
qController.qClient.sendAndReceiveString("/cueLists");
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
instanceName.Text = name;
|
||||
@@ -50,7 +50,14 @@ namespace qController
|
||||
|
||||
}
|
||||
|
||||
Hashtable cmds = new Hashtable();
|
||||
List<QButton> buttons = new List<QButton>();
|
||||
|
||||
buttons.Add(new QButton("Previous", "/select/previous"));
|
||||
buttons.Add(new QButton("Panic", "/panic"));
|
||||
buttons.Add(new QButton("Next", "/select/next"));
|
||||
buttons.Add(new QButton("Preview", "/preview"));
|
||||
buttons.Add(new QButton("Pause", "/pause"));
|
||||
buttons.Add(new QButton("Resume", "/resume"));
|
||||
|
||||
var backButtonGesture = new TapGestureRecognizer();
|
||||
|
||||
@@ -58,13 +65,6 @@ namespace qController
|
||||
backButton.GestureRecognizers.Add(backButtonGesture);
|
||||
|
||||
|
||||
cmds.Add("Pause", "/pause");
|
||||
cmds.Add("Resume", "/resume");
|
||||
cmds.Add("Panic", "/panic");
|
||||
cmds.Add("Next", "/select/next");
|
||||
cmds.Add("Previous", "/select/previous");
|
||||
cmds.Add("Preview", "/preview");
|
||||
|
||||
qCell = new QSelectedCueCell();
|
||||
qSelectedCueOptions = new QSelectedCueOptionsCell(qController);
|
||||
|
||||
@@ -89,11 +89,10 @@ namespace qController
|
||||
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
foreach (string cmd in cmds.Keys)
|
||||
foreach (var b in buttons)
|
||||
{
|
||||
QButton b = new QButton(cmd,(string)cmds[cmd]);
|
||||
b.Clicked += sendOSC;
|
||||
if(cmd=="Panic")
|
||||
if(b.Text=="Panic")
|
||||
{
|
||||
b.BackgroundColor = Color.IndianRed;
|
||||
}
|
||||
@@ -134,7 +133,7 @@ namespace qController
|
||||
|
||||
public void SelectedCueUpdated(object sender, CueEventArgs e){
|
||||
Device.BeginInvokeOnMainThread(()=>{
|
||||
if (e.SelectedCue.type.Equals("Audio"))
|
||||
if (e.Cue.type.Equals("Audio"))
|
||||
{
|
||||
//Console.WriteLine("CUE IS AN AUDIO CUE");
|
||||
sLayout.Children.Add(qSelectedCueOptions);
|
||||
@@ -144,7 +143,7 @@ namespace qController
|
||||
//Console.WriteLine("CUE IS NOT AN AUDIO CUE");
|
||||
sLayout.Children.Remove(qSelectedCueOptions);
|
||||
}
|
||||
qCell.UpdateSelectedCue(e.SelectedCue);
|
||||
qCell.UpdateSelectedCue(e.Cue);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,7 +155,31 @@ namespace qController
|
||||
{
|
||||
//
|
||||
});
|
||||
Console.WriteLine("Workspace Updated: " + e.UpdatedWorkspace.workspace_id);
|
||||
qController.qWorkspace = e.UpdatedWorkspace;
|
||||
Console.WriteLine("Workspace updated in ControlPage: " + qController.qWorkspace.workspace_id);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlaybackPositionUpdated(object sender, PlaybackPositionArgs e)
|
||||
{
|
||||
qController.playbackPosition = e.PlaybackPosition;
|
||||
Console.WriteLine("Playback Position updated in ControlPage: " + qController.playbackPosition);
|
||||
QCue cue = qController.qWorkspace.GetCue(qController.playbackPosition);
|
||||
if(cue != null)
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() => {
|
||||
if (cue.type.Equals("Audio"))
|
||||
{
|
||||
//Console.WriteLine("CUE IS AN AUDIO CUE");
|
||||
//sLayout.Children.Add(qSelectedCueOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("CUE IS NOT AN AUDIO CUE");
|
||||
//sLayout.Children.Remove(qSelectedCueOptions);
|
||||
}
|
||||
qCell.UpdateSelectedCue(cue);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user