42,6 → 42,9 |
RoboBoardForm _rbForm; |
RoboBoardEvents _eventsPort = new RoboBoardEvents(); |
|
bool subs = false; |
bool isloaded = false; |
|
private Roboboard.SerialCom sc = new Robotics.Serial.SerialCom(); |
/// <summary> |
/// _state |
142,6 → 145,15 |
|
//--------------------------------------------------------------------- |
[ServiceHandler(ServiceHandlerBehavior.Exclusive)] |
public IEnumerator<ITask> InitComplete(InitComplete initComplete) |
{ |
LogInfo("Init"); |
LogInfo("Command:" + initComplete.Body.Command); |
yield break; |
} |
|
//--------------------------------------------------------------------- |
[ServiceHandler(ServiceHandlerBehavior.Exclusive)] |
public IEnumerator<ITask> SetComPortHandler(SetComPort setComPort) |
{ |
LogInfo("Set Port Name ("+setComPort.Body.PortName+")"); |
163,17 → 175,22 |
if (sc.InitPort() == 0) |
{ |
LogInfo("Init Port succseeded"); |
WinFormsServicePort.FormInvoke(delegate() |
{_rbForm.UpdateStatus("Port Open (" + sc.ComPort + ")");}); |
WinFormsServicePort.FormInvoke(delegate() |
{ _rbForm.UpdateStatus("Port Open (" + sc.ComPort + ")"); }); |
} |
else |
{ |
LogInfo("Init Port failed"); |
WinFormsServicePort.FormInvoke(delegate() |
{_rbForm.UpdateStatus("Can't open communication port (" + sc.ComPort + ")");}); |
{ _rbForm.UpdateStatus("Can't open communication port (" + sc.ComPort + ")"); }); |
} |
} |
else |
{ |
LogInfo("Board communication not ready! Setport Ignored"); |
} |
} |
LogInfo("Exit Set Comport"); |
yield break; |
} |
|
256,9 → 273,11 |
_rbForm.Control_gier = igier; |
} |
|
MK_latest_gier = igier; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
|
if (MK_latest_gier != igier) |
{ |
MK_latest_gier = igier; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
} |
base.SendNotification(_submgrPort, setgier); |
setgier.ResponsePort.Post(DefaultUpdateResponseType.Instance); |
yield break; |
276,8 → 295,11 |
_rbForm.Control_gas = igas; |
} |
|
MK_latest_gas = igas; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
if (MK_latest_gas != igas) |
{ |
MK_latest_gas = igas; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
} |
|
base.SendNotification(_submgrPort, setgas); |
setgas.ResponsePort.Post(DefaultUpdateResponseType.Instance); |
301,9 → 323,12 |
_rbForm.Control_roll = iroll; |
} |
|
MK_latest_nick = inick; |
MK_latest_roll = iroll; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
if ((MK_latest_roll != iroll) || (MK_latest_nick != inick)) |
{ |
MK_latest_nick = inick; |
MK_latest_roll = iroll; |
MKRequestControl(MK_latest_nick, MK_latest_roll, MK_latest_gier, MK_latest_gas); |
} |
|
base.SendNotification(_submgrPort, control); |
control.ResponsePort.Post(DefaultUpdateResponseType.Instance); |
328,7 → 353,11 |
LogError(null, "Subscribe failed", e); |
} |
); |
|
if (isloaded) |
{ |
base.SendNotification(_submgrPort, new InitComplete("OK")); |
} |
subs = true; |
yield break; |
} |
|
337,23 → 366,29 |
{ |
_rbForm = onLoad.RoboBoardForm; |
LogInfo("Loaded Form"); |
sc.ComPort = "COM6"; |
sc.ComPort = "COM7"; |
if (_rbForm != null) |
{ |
if (sc.InitPort() == 0) |
{ |
LogInfo("Port Open"); |
WinFormsServicePort.FormInvoke(delegate() |
{_rbForm.UpdateStatus("Port Open (" + sc.ComPort + ")");}); |
} |
else |
{ |
LogInfo("Port failed to Open"); |
WinFormsServicePort.FormInvoke(delegate() |
{_rbForm.UpdateStatus("Can't open communication port (" + sc.ComPort + ")");}); |
} |
} |
|
//request version |
MKRequestVersion(); |
if (subs) |
{ |
base.SendNotification(_submgrPort, new InitComplete("OK")); |
} |
isloaded = true; |
yield break; |
} |
|
417,9 → 452,14 |
//--------------------------------------------------------------------- |
void MKRequestVersion() |
{ |
LogInfo("MK RequestVersion"); |
string message = ""; |
message=sc.CreateMessage((char)'v', (char)0, message); |
sc.SerialWrite(message); |
if (sc.isOpen) |
{ |
LogInfo("Version Send"); |
sc.SerialWrite(message); |
} |
} |
|
string MKDecodeVersion(string message) |