Skip to content

Instantly share code, notes, and snippets.

@mvacha
Created September 27, 2016 15:00
Show Gist options
  • Save mvacha/aec0f25737408c115eb928a5557848fd to your computer and use it in GitHub Desktop.
Save mvacha/aec0f25737408c115eb928a5557848fd to your computer and use it in GitHub Desktop.
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