📄 itransportlayer.cs
字号:
////////////////////////////////////////////////////////////////////////////////////////////////
//
// #######
// # ## #### ##### ##### ## ## #####
// ## ## ## ## ## ## ## ## ##
// ## # ###### ## ## #### ## ## ####
// ## ## ## ## ## ## ##### ##
// ####### #### ## ## ##### ## #####
// #####
// Z-Wave, the wireless language.
//
// Copyright Zensys A/S, 2005
//
// All Rights Reserved
//
// Description:
//
// Author: Morten Damsgaard, Linkage A/S
//
// Last Changed By: $Author: jrm $
// Revision: $Revision: 1.4 $
// Last Changed: $Date: 2006/07/24 09:09:56 $
//
//////////////////////////////////////////////////////////////////////////////////////////////
#region Using directives
using System;
#endregion
namespace Zensys.ZWave.Communication
{
/// <summary>
/// Summary description for ITransportLayer.
/// </summary>
public interface ITransportLayer
{
/// <summary>
/// Open(connectionstring) ex Open("ZW_RS232", port=COM1;baudrate=115200)
/// </summary>
/// <param name="connectionString"></param>
void Open(String connectionString);
/// <summary>
/// Close()
/// </summary>
void Close();
/// <summary>
/// Read from buffer
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
int Read(byte[] buffer);
/// <summary>
/// Write to buffer
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
int Write(byte[] buffer);
/// <summary>
/// Is the port already Open ?
/// </summary>
/// <returns></returns>
bool IsOpen();
/// <summary>
/// Statistic of sended / received / duplicated frames etc.
/// </summary>
/// <returns></returns>
TransportStatistics GetStatistics();
}
/// <summary>
/// Exception Class
/// </summary>
public class ITransportLayerException : Exception
{
/// <summary>
/// Exception for ITransportLayer
/// </summary>
public ITransportLayerException()
{ }
/// <summary>
/// Exception for ITransportLayer
/// </summary>
public ITransportLayerException(string describe, Exception innerException)
: base(describe, innerException)
{
// Add any type-specific logic for inner exceptions.
}
/// <summary>
///
/// </summary>
/// <param name="describe"></param>
public ITransportLayerException(string describe) : base(describe) { }
// protected ITransportLayerException(SerializationInfo info, StreamingContext context) : base(info, context) {}
}
/// <summary>
/// Initialize transmitted and received bytes
/// </summary>
public class TransportStatistics
{
/// <summary>
///
/// </summary>
public TransportStatistics()
{
}
/// <summary>
///
/// </summary>
/// <param name="stats"></param>
public TransportStatistics(TransportStatistics stats)
{
if (stats == null)
{
throw new ArgumentNullException("stats");
}
this.TransmittedBytes = stats.transmittedBytes;
this.ReceivedBytes = stats.receivedBytes;
}
private int transmittedBytes;
private int receivedBytes;
/// <summary>
/// Gets or sets the amount of transmitted bytes
/// </summary>
public int TransmittedBytes
{
get { return transmittedBytes; }
set { transmittedBytes = value; }
}
/// <summary>
/// Gets or sets the amount of received bytes
/// </summary>
public int ReceivedBytes
{
get { return receivedBytes; }
set { receivedBytes = value; }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -