Skip to content

Commit

Permalink
SDK release to match 2.0 app (#3)
Browse files Browse the repository at this point in the history
Release 0.2.0
Rename Connection to SdkConnection
  • Loading branch information
Mark Wesley authored Sep 13, 2017
1 parent a80d0ba commit 367d443
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Binary file modified clad_library/CladCSharp.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions csharp_interface/cozmoApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SampleApp
public const string kTargetIP = "127.0.0.1";
public const int kTargetPort = 5106;

private Anki.Cozmo.Connection _connection;
private Anki.Cozmo.SdkConnection _connection;
private List<string> _supportedAnimations = new List<string>();

private void OnAnimationAvailable(Anki.Cozmo.ExternalInterface.AnimationAvailable message)
Expand All @@ -44,10 +44,10 @@ private void RequestSupportedAnimations()
_supportedAnimations.Clear();
bool finished = false;
_connection.AddCallback<Anki.Cozmo.ExternalInterface.AnimationAvailable>(this, OnAnimationAvailable);
_connection.AddCallback<Anki.Cozmo.ExternalInterface.EndOfMessage>(this, msg => finished = true );
_connection.AddCallback<Anki.Cozmo.ExternalInterface.EndOfMessage>(this, msg => finished = true);

Anki.Cozmo.ExternalInterface.RequestAvailableAnimations message = new Anki.Cozmo.ExternalInterface.RequestAvailableAnimations();
_connection.SendMessage( message );
_connection.SendMessage(message);

while (!finished)
{
Expand All @@ -71,7 +71,7 @@ private Anki.Cozmo.Action SetLiftHeight(float percent)

public void Execute()
{
_connection = new Anki.Cozmo.Connection(kTargetIP, kTargetPort);
_connection = new Anki.Cozmo.SdkConnection(kTargetIP, kTargetPort);

RequestSupportedAnimations();
System.Console.WriteLine("Cozmo can perform " + _supportedAnimations.Count.ToString() + " animations");
Expand Down
4 changes: 2 additions & 2 deletions csharp_interface/cozmoInterface/action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Cozmo
{
public class Action
{
private Connection _connection = null;
private SdkConnection _connection = null;
private ExternalInterface.QueueSingleAction _message = null;
private byte _robotId = 0;
private uint _id = 0;
Expand All @@ -31,7 +31,7 @@ public class Action
public uint ID { get { return _id; } }
public ExternalInterface.QueueSingleAction Message { get { return _message; } }

public Action(Connection connection, byte robotId)
public Action(SdkConnection connection, byte robotId)
{
_connection = connection;
_robotId = robotId;
Expand Down
16 changes: 8 additions & 8 deletions csharp_interface/cozmoInterface/connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ namespace Anki
{
namespace Cozmo
{
public class Connection
public class SdkConnection
{
public UiConnectionType SDKConnectionType = UiConnectionType.SdkOverTcp;

private const int _MaxBufferSize = 8192;

private IPEndPoint _endPoint = null;
private Socket _socket = null;
private bool _verboseLogging = false;
private bool _verboseLogging = false;
private Thread _listenThread = null;
private bool _shutdownSignal = false;
private Dictionary<System.Type, Dictionary<object, iCallback>> _callbacks = new Dictionary<System.Type, Dictionary<object, iCallback>>();
Expand All @@ -42,7 +42,7 @@ public class Connection

public byte CurrentRobotId { get { return _currentRobotId; } }

public Connection(string ip, int socket, bool verboseLogging = false)
public SdkConnection(string ip, int socket, bool verboseLogging = false)
{
_verboseLogging = verboseLogging;

Expand Down Expand Up @@ -85,7 +85,7 @@ public void Close()

public Action SendAction<T>(T state, int numRetries = 0, bool inParallel = false)
{
Action result = new Action( this, _currentRobotId );
Action result = new Action(this, _currentRobotId);
result.Initialize(state, numRetries, inParallel);

_inFlightActions.Add(result);
Expand Down Expand Up @@ -156,7 +156,7 @@ private void ReceiveMessage(SDKMessageIn messageIn)

// does this give us a robot id?
string robotIDPropertyName = "robotID";
if (_currentRobotId == byte.MaxValue && messageData.GetType().GetProperty(robotIDPropertyName) != null )
if (_currentRobotId == byte.MaxValue && messageData.GetType().GetProperty(robotIDPropertyName) != null)
{
uint robotId = (uint)messageData.GetType().GetProperty(robotIDPropertyName).GetValue(messageData, null);
_currentRobotId = (byte)robotId;
Expand Down Expand Up @@ -301,15 +301,15 @@ private void HandleUiDeviceConnected(Anki.Cozmo.ExternalInterface.UiDeviceConnec
System.BitConverter.ToString(MessageGameToEngineHash._Data) + ")");
}

SendMessage(new ExternalInterface.UiDeviceConnectionSuccess(connectionType: message.connectionType,
deviceID: message.deviceID,
SendMessage(new ExternalInterface.UiDeviceConnectionSuccess(connectionType: message.connectionType,
deviceID: message.deviceID,
buildVersion: Anki.Cozmo.CladVersion._Data,
sdkModuleVersion: Anki.Cozmo.SDKVersion._Data,
pythonVersion: "CSharp",
pythonImplementation: "CSharp",
osVersion: "?",
cpuVersion: "?"));

System.Console.WriteLine("Connected to Cozmo App");
}

Expand Down

0 comments on commit 367d443

Please sign in to comment.