mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-09 01:13:50 +00:00
Implement notes, and work on updating cue info
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.1</string>
|
||||
<string>2.0.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace qController
|
||||
name.Text = cue.name;
|
||||
number.Text = cue.number;
|
||||
type.Text = cue.type;
|
||||
//notes.Text = cue.notes;
|
||||
notes.Text = cue.notes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using SharpOSC;
|
||||
using Newtonsoft.Json;
|
||||
namespace qController
|
||||
@@ -49,14 +50,14 @@ namespace qController
|
||||
{
|
||||
udpSender.Send(new OscMessage(address, args));
|
||||
}
|
||||
public OscMessage sendAndReceiveString(string address)
|
||||
public void sendAndReceiveString(string address)
|
||||
{
|
||||
return tcpSender.SendAndReceive(new OscMessage(address));
|
||||
tcpSender.SendAndReceive(new OscMessage(address));
|
||||
}
|
||||
|
||||
public OscMessage sendAndReceiveStringArgs(string address, params object[] args)
|
||||
public void sendAndReceiveStringArgs(string address, params object[] args)
|
||||
{
|
||||
return tcpSender.SendAndReceive(new OscMessage(address, args));
|
||||
tcpSender.SendAndReceive(new OscMessage(address,args));
|
||||
}
|
||||
|
||||
|
||||
@@ -91,14 +92,15 @@ namespace qController
|
||||
public void UpdateSpecificCue(string 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";
|
||||
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 address = "/cue_id/" + cue_id + "/valuesForKeys";
|
||||
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue()
|
||||
{
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\"]";
|
||||
string valuesForKeys = "[\"displayName\",\"number\",\"type\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"uniqueID\",\"flagged\",\"listName\",\"colorName\",\"name\",\"armed\",\"notes\"]";
|
||||
sendAndReceiveStringArgs("/cue/selected/valuesForKeys", valuesForKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,9 @@ namespace qController
|
||||
qClient.qParser.SelectedCueUpdated += this.OnSelectedCueUpdated;
|
||||
qClient.qParser.WorkspaceUpdated += this.OnWorkspaceUpdated;
|
||||
qClient.qParser.PlaybackPositionUpdated += this.OnPlaybackPositionUpdated;
|
||||
|
||||
qClient.qParser.CueInfoUpdated += this.OnCueUpdateReceived;
|
||||
qClient.sendArgsUDP("/updates", 1);
|
||||
qClient.sendAndReceiveString("/cueLists");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +47,7 @@ namespace qController
|
||||
{
|
||||
qWorkspace = args.UpdatedWorkspace;
|
||||
Console.WriteLine("Workspace updated in QController: " + qWorkspace.workspace_id);
|
||||
qWorkspace.PrintStats();
|
||||
}
|
||||
|
||||
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
||||
@@ -59,7 +59,7 @@ namespace qController
|
||||
public void OnCueUpdateReceived(object source, CueEventArgs args)
|
||||
{
|
||||
qWorkspace.UpdateCue(args.Cue);
|
||||
Console.WriteLine("Cue updated: " + args.Cue.uniqueID );
|
||||
Console.WriteLine("Cue updated in QController: " + args.Cue.uniqueID );
|
||||
}
|
||||
public void Kill(){
|
||||
qUpdater.Kill();
|
||||
|
||||
@@ -100,7 +100,6 @@ namespace qController
|
||||
public void ParseCueUpdateInfo(OscMessage msg)
|
||||
{
|
||||
JToken cueUpdate = OSC2JSON(msg);
|
||||
Console.WriteLine("Cue Update Received");
|
||||
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
||||
OnCueInfoUpdated(cue);
|
||||
}
|
||||
@@ -152,7 +151,7 @@ namespace qController
|
||||
}
|
||||
|
||||
protected virtual void OnCueInfoUpdated(QCue cue)
|
||||
{
|
||||
{
|
||||
if (CueInfoUpdated != null)
|
||||
CueInfoUpdated(this, new CueEventArgs() { Cue = cue });
|
||||
}
|
||||
|
||||
@@ -15,40 +15,33 @@ namespace qController
|
||||
|
||||
static Thread thread;
|
||||
static UDPListener udpListener;
|
||||
|
||||
static int Port;
|
||||
public QReceiver(int port)
|
||||
{
|
||||
HandleOscPacket callback = delegate (OscPacket packet)
|
||||
{
|
||||
var messageReceived = (OscMessage)packet;
|
||||
if(messageReceived != null)
|
||||
OnUpdateMessageReceived(messageReceived);
|
||||
else
|
||||
Console.WriteLine("Message came back null");
|
||||
};
|
||||
|
||||
udpListener = new UDPListener(port, callback);
|
||||
Port = port;
|
||||
thread = new Thread(new ThreadStart(ListenLoop));
|
||||
thread.Start();
|
||||
|
||||
}
|
||||
|
||||
public void ListenLoop()
|
||||
{
|
||||
/*while (true)
|
||||
HandleOscPacket callback = delegate (OscPacket packet)
|
||||
{
|
||||
OscMessage messageReceived = null;
|
||||
while(messageReceived == null)
|
||||
{
|
||||
messageReceived = (OscMessage)udpListener.Receive();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
OnUpdateMessageReceived(messageReceived);
|
||||
var messageReceived = (OscMessage)packet;
|
||||
if (messageReceived != null)
|
||||
OnUpdateMessageReceived(messageReceived);
|
||||
else
|
||||
Console.WriteLine("Message came back null");
|
||||
};
|
||||
|
||||
}*/
|
||||
udpListener = new UDPListener(Port, callback);
|
||||
|
||||
}
|
||||
|
||||
public void Close(){
|
||||
udpListener.Close();
|
||||
thread.Abort();
|
||||
}
|
||||
|
||||
protected virtual void OnUpdateMessageReceived(OscMessage msg)
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace SharpOSC
|
||||
private static OscMessage parseMessage(byte[] msg)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
string address = null;
|
||||
//Console.WriteLine("Raw OSC DATA: " + System.Text.Encoding.ASCII.GetString(msg));
|
||||
string address = null;
|
||||
char[] types = new char[0];
|
||||
List<object> arguments = new List<object>();
|
||||
List<object> mainArray = arguments; // used as a reference when we are parsing arrays to get the main array back
|
||||
@@ -287,8 +287,12 @@ namespace SharpOSC
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= msg.Length && output == null)
|
||||
if (output == null)
|
||||
{
|
||||
byte[] term = { 0 };
|
||||
output = Encoding.ASCII.GetString(term);
|
||||
}
|
||||
if (i >= msg.Length && output == null)
|
||||
throw new Exception("No null terminator after type string");
|
||||
|
||||
return output.Replace("\0", "");
|
||||
|
||||
@@ -56,12 +56,15 @@ namespace SharpOSC
|
||||
client.Close();
|
||||
}
|
||||
|
||||
public OscMessage Receive()
|
||||
public async void Receive()
|
||||
{
|
||||
Random random = new Random();
|
||||
int num = random.Next(1000);
|
||||
|
||||
OscMessage response = new OscMessage("/null");
|
||||
NetworkStream netStream = client.GetStream();
|
||||
try
|
||||
{
|
||||
NetworkStream netStream = client.GetStream();
|
||||
netStream.ReadTimeout = 250;
|
||||
List<byte> responseData = new List<byte>();
|
||||
if (netStream.CanRead)
|
||||
@@ -71,36 +74,37 @@ namespace SharpOSC
|
||||
int bytesRead = 0;
|
||||
do
|
||||
{
|
||||
bytesRead = netStream.Read(buffer, 0, buffer.Length);
|
||||
bytesRead = await netStream.ReadAsync(buffer, 0, buffer.Length);
|
||||
responseData.AddRange(buffer);
|
||||
Thread.Sleep(1);
|
||||
//Console.WriteLine( "Thread " + num + ": Bytes read: " + bytesRead + " - " + Encoding.ASCII.GetString(buffer));
|
||||
} while (netStream.DataAvailable);
|
||||
|
||||
Console.WriteLine("Raw TCP In: " + System.Text.Encoding.ASCII.GetString(responseData.ToArray()));
|
||||
response = (OscMessage)OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
||||
netStream.Close();
|
||||
client.Close();
|
||||
}
|
||||
} catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
return response;
|
||||
netStream.Close();
|
||||
client.Close();
|
||||
OnMessageReceived(response);
|
||||
}
|
||||
|
||||
public OscMessage SendAndReceive(byte[] message)
|
||||
public void SendAndReceive(byte[] message)
|
||||
{
|
||||
client = new TcpClient(Address, Port);
|
||||
byte[] slipData = SlipEncode(message);
|
||||
NetworkStream netStream = client.GetStream();
|
||||
netStream.Write(slipData.ToArray(), 0, slipData.ToArray().Length);
|
||||
OscMessage response = Receive();
|
||||
return response;
|
||||
Receive();
|
||||
}
|
||||
|
||||
public OscMessage SendAndReceive(OscPacket packet)
|
||||
public void SendAndReceive(OscPacket packet)
|
||||
{
|
||||
byte[] data = packet.GetBytes();
|
||||
OscMessage response = SendAndReceive(data);
|
||||
OnMessageReceived(response);
|
||||
return response;
|
||||
SendAndReceive(data);
|
||||
}
|
||||
|
||||
public void Send(OscPacket packet)
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace SharpOSC
|
||||
Console.WriteLine(e.ToString());
|
||||
// If there is an error reading the packet, null is sent to the callback
|
||||
}
|
||||
Console.WriteLine("Raw UDP In: " + System.Text.Encoding.ASCII.GetString(bytes));
|
||||
OscPacketCallback(packet);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -25,5 +25,6 @@ namespace qController
|
||||
public bool isBroken { get; set; }
|
||||
public string displayName { get; set; }
|
||||
public bool isLoaded { get; set; }
|
||||
public string notes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,5 +39,13 @@ namespace qController
|
||||
}
|
||||
}
|
||||
}
|
||||
public void PrintStats()
|
||||
{
|
||||
foreach (var cueList in data)
|
||||
{
|
||||
Console.WriteLine(cueList.listName + "("+ cueList.cues.Count + " cues)");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace qController
|
||||
qController.qClient.qParser.SelectedCueUpdated += SelectedCueUpdated;
|
||||
qController.qClient.qParser.WorkspaceUpdated += WorkspaceUpdated;
|
||||
qController.qClient.qParser.PlaybackPositionUpdated += PlaybackPositionUpdated;
|
||||
qController.qClient.sendAndReceiveString("/cueLists");
|
||||
qController.qClient.qParser.CueInfoUpdated += OnCueUpdateReceived;
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
instanceName.Text = name;
|
||||
|
||||
@@ -183,6 +183,20 @@ namespace qController
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCueUpdateReceived(object sender, CueEventArgs args)
|
||||
{
|
||||
qController.qWorkspace.UpdateCue(args.Cue);
|
||||
Console.WriteLine("Cue updated in ControlPage: " + args.Cue.uniqueID);
|
||||
if (args.Cue.uniqueID == qController.playbackPosition)
|
||||
{
|
||||
Console.WriteLine("Cue that was updated is equal to the playback position.");
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
qCell.UpdateSelectedCue(args.Cue);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
Reference in New Issue
Block a user