DataStreamInterface added.

This commit is contained in:
Milan Hanajik 2020-05-01 10:44:28 +02:00
parent 0ea7b9b6d3
commit e7431ce6e2
9 changed files with 347 additions and 1 deletions

3
.gitignore vendored
View File

@ -2,6 +2,8 @@ Common/bin/
Common/obj/ Common/obj/
Config/bin/ Config/bin/
Config/obj/ Config/obj/
DataStreamInterface/bin/
DataStreamInterface/obj/
Decrypt/bin/ Decrypt/bin/
Decrypt/obj/ Decrypt/obj/
DeviceTest/bin/ DeviceTest/bin/
@ -40,7 +42,6 @@ Users/bin/
Users/obj/ Users/obj/
UserManagement/bin/ UserManagement/bin/
UserManagement/obj/ UserManagement/obj/
Doc/
.vs/ .vs/
*.suo *.suo
*.bak *.bak

View File

@ -0,0 +1,23 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
namespace DataStreamInterface
{
public class DataFrame
{
public readonly UInt64 ID; /// Frame ID
public readonly double Time; /// Time stamp in units of time
public readonly double Volume; /// Volume in units of volume
public readonly double[] Quantity; /// An array of optional quantities in their respective units
public DataFrame(UInt64 id, double time, double volume, double[] quantity)
{
ID = id;
Time = time;
Volume = volume;
Quantity = quantity;
}
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataStreamInterface</RootNamespace>
<AssemblyName>DataStreamInterface</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataFrame.cs" />
<Compile Include="Enums.cs" />
<Compile Include="IDataStreamMeter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Doc\Software interface for datastream water meters.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,95 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
namespace DataStreamInterface
{
public enum Unit
{
None,
pulse,
degree,
/// Volume
ml, /// 0.001 l
l, /// * 1 liter = 1 l
dm3, /// 1 dm3 = 1 l
m3, /// 1000 l
gal_UK, /// 1 gal(UK) = 4.54609 l
gal_US, /// 1 gal(US) = 3.78541178 l
/// Flow
lph, /// 1 liter/h
m3ph, /// * 1 m3/h = 1000 l/h
/// Mass
g, /// 0.001 kg
kg, /// * 1 kilogram
t, /// 1000 kg
lb, /// 0.45359237 kg
/// Time
ms, /// 1 ms = 0.001 s
s, /// * 1 second = 1 s
min, /// 1 min = 60 s
hour, /// 1 hour = 60 min = 3600 s
/// Temperature
C, /// * degree Celsius (°C)
F, /// degree Fahrenheit
K, /// degree Kelvin
/// Pressure
Pa, /// 1 Pa = 0.01 hPa
hPa, /// 1 hPa = 100 Pa
mbar, /// 1 mbar = 1 hPa = 100 Pa
kPa, /// 1 kPa = 10 HPa
inHg, /// 1 inHg = 33.864 hPa
bar, /// * 1 Bar = 1000 mbar = 0.1 MPa = 100000 Pa
MPa, /// 1 MPa = 10000 hPa
/// Humidity
RPct, /// * 1 R%
/// Relative error
Promile, /// 1 promile = 0.1 %
Pct, /// * 1 %
/// Length
mm, /// * 1 millimeter
cm, /// 1 cm = 10 mm
inch, /// 1 inch = 25.4 mm
foot, /// 1 foot = 304.8 mm
m, /// 1 m = 1000 mm
/// Density
kgpm3, /// * 1 kg/m3 = 0.001 kg/l
kgpl, /// 1 kg/l = 1000 kg/m3
/// Energy
J, /// * 1 Joul
kJ, /// 1 kJ = 1000 J
MJ, /// 1 MJ = 1000000 J
Wh, /// 1 Wh = 3600 J
kWh, /// 1 kWh = 3600000 J
MWh, /// 1 MWh = 3600000000 J
/// Meter coefficient - volume
ppl, /// * 1 pulse/l
ppdm3, /// * 1 pulse/dm3
degpl, /// * 1 degree/l
degpdm3, /// * 1 degree/dm3
lpp, /// * 1 l/pulse
dm3pp, /// * 1 dm3/pulse
lpdeg, /// * 1 l/degree
dm3pdeg, /// * 1 dm3/degree
/// Meter coefficient - energy
ppkWh, /// * 1 pulse/kWh
kWhpp, /// * 1 kWh/pulse
Count
}
}

View File

@ -0,0 +1,114 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataStreamInterface
{
public interface IDataStreamMeter
{
/// <summary>
/// Get state of the connected data stream meter
/// </summary>
/// <param name="state">Current state of the meter</param>
/// <returns>true when successful</returns>
bool GetState(out int state, out string parameter);
/// <summary>
/// Set state of the connected data stream meter
/// </summary>
/// <param name="state">Required state of the meter</param>
/// <returns>true when successful</returns>
bool SetState(int state, string parameter);
/// <summary>
/// Establish connection with a data stream meter
/// </summary>
/// <param name="connectionParameters">Connection parameters</param>
/// <param name="meterId">Meter ID (e.g. serial number)</param>
/// <returns>true when successful</returns>
bool OpenConnection(string connectionParameters, out string meterId);
/// <summary>
/// Closes connection with the data stream meter
/// </summary>
/// <returns>true when successful</returns>
bool CloseConnection();
/// <summary>
/// Stars saving measurement results into internal data structures of the component.
/// Each data frame obtains a unique ID.
/// The very first data fraim obrains ID = 0.
/// </summary>
/// <returns>true when successful</returns>
bool StartMeasurement();
/// <summary>
/// Stops saving measurement results into internal data structures of the component.
/// Updates ID of the last date frame received from the meter.
/// </summary>
/// <param name="lastFrameID">ID of the last date frame</param>
/// <returns>true when successful</returns>
bool StopMeasurement(out UInt64 lastFrameID);
///------------------------------------------------
/// Units of time, volume and optional quantities
///------------------------------------------------
/// <summary>
/// Returns time units (s, ms, ...)
/// </summary>
Unit GetTimeUnits();
/// <summary>
/// Returns units of volume (ml, l, ...)
/// </summary>
Unit GetVolumeUnits();
///-----------------------------------------------
/// Ooptional quantities: count, units, captions
///-----------------------------------------------
/// <summary>
/// Returns count of optional quantities in each data frame
/// </summary>
/// <returns>Count of optional quantities</returns>
int GetQuantitiesCount();
/// <summary>
/// Returns units of the specified quantity
/// </summary>
/// <param name="quanityNr">Zero based quantity number 0 .. quantites count-1</param>
Unit GetQuantityUnits(int quanityNr);
/// <summary>
/// Returns caption of the specified quantity
/// </summary>
/// <param name="quanityNr">Zero based quantity number 0 .. quantites count-1</param>
string GetQuantityCaption(int quanityNr);
///---------------------------
/// Datastream data exchange
///---------------------------
/// <summary>
/// Retuns 'count' data frames starting with data frame with ID = 'id'
/// </summary>
/// <param name="id">First frame ID</param>
/// <param name="count">Frames count</param>
/// <returns>Selected data frames</returns>
DataFrame[] GetFrames(UInt64 id, int count);
/// <summary>
/// Returns ID of the data frame where time equals or exceeds the specified time.
/// When time of the first frame (ID=0) is larger then specified time, function returns 0.
/// </summary>
/// <param name="time">Time</param>
/// <returns>ID of the data frame at or after the pecified time</returns>
UInt64 GetID(double time);
}
}

View File

@ -0,0 +1,38 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Resources;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DataStreamInterface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DataStreamInterface")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e44458ee-b635-4d7c-a763-20054399e817")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]

12
TBF.sln
View File

@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventViewer", "EventViewer\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{C8939821-BA5C-4988-A3D0-BF53B74865C7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{C8939821-BA5C-4988-A3D0-BF53B74865C7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataStreamInterface", "DataStreamInterface\DataStreamInterface.csproj", "{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -291,6 +293,16 @@ Global
{C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|x86.ActiveCfg = Release|Any CPU {C8939821-BA5C-4988-A3D0-BF53B74865C7}.Release|x86.ActiveCfg = Release|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Release|Any CPU.Build.0 = Release|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -2,6 +2,8 @@ rmdir /s /q Common\bin
rmdir /s /q Common\obj rmdir /s /q Common\obj
rmdir /s /q Config\bin rmdir /s /q Config\bin
rmdir /s /q Config\obj rmdir /s /q Config\obj
rmdir /s /q DataStreamInterface\bin
rmdir /s /q DataStreamInterface\obj
rmdir /s /q Decrypt\bin rmdir /s /q Decrypt\bin
rmdir /s /q Decrypt\obj rmdir /s /q Decrypt\obj
rmdir /s /q DeviceTest\bin rmdir /s /q DeviceTest\bin