Created
September 27, 2016 15:00
-
-
Save mvacha/aec0f25737408c115eb928a5557848fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Gamanet.C4; | |
using Gamanet.C4.DriverFramework; | |
using Gamanet.C4.Logging; | |
using Gamanet.C4.DriverFramework.Communication; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace NetGlade.C4Driver.Devices | |
{ | |
/// <summary> | |
/// The driver top level object. | |
/// </summary> | |
[Driver("NetGlade.Test", "Testing C4 2016 features", DriverCategory.Dvr, Vendor="NetGlade")] | |
[DeviceTypeId("02eab551-61b2-4f6e-a268-9a134f803d85")] | |
[BinaryConnection(BinaryConnectionType.Tcp), OverridePropertyDefaultValue("Port", 10001)] | |
public class BusController : DeviceBase<SimpleDeviceStates, IPacketSender>, IDriver, IStartable, IPacketParser | |
{ | |
public BusController(DeviceHandle id, ILog logger) | |
: base(id, logger) | |
{ | |
} | |
public IEnumerable<IPacket> Parse(IBinaryDataStream dataStream) | |
{ | |
var data = dataStream.GetBytes(); | |
dataStream.Commit(data.Count()); | |
return Enumerable.Empty<IPacket>(); | |
} | |
public bool Start() | |
{ | |
Sender.Send(new TestPacket()); | |
return true; | |
} | |
public bool Stop() => true; | |
public class TestPacket : IOutputPacket | |
{ | |
public IEnumerable<byte> GetRawBytes() | |
{ | |
return new byte[] { 42, 1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 13, 79, 35 }; | |
} | |
public void Processed(bool success) | |
{ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment