You not getting back anything because there is a small bug in the driver. Martin fixed it about 2 years ago but I think fixed driver is not uploaded to the library. Below is working one!
using System;
using Stardraw;
using Stardraw.Project;
using Stardraw.Control;
public class MyClass : BaseInPortInstance {
public MyClass(ProductInstance productInstance, Port port) : base(productInstance, port) {
}
private int instanceId = 0;
[PromoteProperty]
public int InstanceId {
get { return instanceId; }
set { instanceId = value; }
}
private int faderNumber = 0;
[PromoteProperty]
public int FaderNumber {
get { return faderNumber; }
set { faderNumber = value; }
}
ScriptHelper sh = new ScriptHelper();
private void SendSetCmd(string cmd) {
if (ConnectedPort != null)
sh.ExecutePortMethod(ConnectedPort.ProductInstance.Name, ConnectedPort.Name, "SendSetCmd", cmd);
}
private void SendIncCmd(string cmd) {
if (ConnectedPort != null)
sh.ExecutePortMethod(ConnectedPort.ProductInstance.Name, ConnectedPort.Name, "SendIncCmd", cmd);
}
private void SendDecCmd(string cmd) {
if (ConnectedPort != null)
sh.ExecutePortMethod(ConnectedPort.ProductInstance.Name, ConnectedPort.Name, "SendDecCmd", cmd);
}
private void SendGetCmd(string cmd) {
if (ConnectedPort != null)
sh.ExecutePortMethod(ConnectedPort.ProductInstance.Name, ConnectedPort.Name, "SendGetCmd", cmd);
}
[Controllable]
public event EventHandler OnFaderLevelChanged;
public void ChangeFaderLevel(double level) {
if (faderLevel != level) {
faderLevel = level;
if (OnFaderLevelChanged != null)
OnFaderLevelChanged(this, EventArgs.Empty);
}
}
double faderLevel = 0;
[Controllable]
public double FaderLevel {
get { return faderLevel; }
set { SendSetCmd(string.Format("FDRLVL {0} {1} {2}", InstanceId, faderNumber, value)); }
}
[Controllable]
public void FaderLevel_Increment(int value) {
SendIncCmd(string.Format("FDRLVL {0} {1} {2}", InstanceId, faderNumber, value));
}
[Controllable]
public void FaderLevel_Decrement(int value) {
SendDecCmd(string.Format("FDRLVL {0} {1} {2}", InstanceId, faderNumber, value));
}
[Controllable]
public void RequestFaderLevel() {
SendGetCmd(string.Format("FDRLVL {0} {1}", InstanceId, faderNumber));
}
[Controllable]
public void RequestFaderMute() {
SendGetCmd(string.Format("FDRMUTE {0} {1}", InstanceId, faderNumber));
}
[Controllable]
public event EventHandler OnMuteChanged;
public void ChangeMute(bool _mute) {
if (mute != _mute) {
mute = _mute;
if (OnMuteChanged != null)
OnMuteChanged(this, EventArgs.Empty);
}
}
private bool mute;
[Controllable]
public bool Mute {
get { return mute; }
set { SendSetCmd(string.Format("FDRMUTE {0} {1} {2}", InstanceId, faderNumber, value ? 1 : 0)); }
}
public void OnLineIn(string line) {
if (line.StartsWith("#GETD")) {
string[] strings = line.Split(' ');
if (strings.Length > 4) {
int number = int.Parse(strings[4]);
if (number == faderNumber) {
switch (strings[2]) {
case "FDRLVL":
ChangeFaderLevel(double.Parse(strings[5], System.Globalization.CultureInfo.CreateSpecificCulture("en-us")));
break;
case "FDRMUTE":
ChangeMute(strings[5] == "1");
break;
}
}
}
}
}
}