diff --git a/.gitignore b/.gitignore index 96b6c986f..e4e7016bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ Common/bin/ Common/obj/ Config/bin/ Config/obj/ +DataStreamInterface/bin/ +DataStreamInterface/obj/ Decrypt/bin/ Decrypt/obj/ DeviceTest/bin/ @@ -40,7 +42,6 @@ Users/bin/ Users/obj/ UserManagement/bin/ UserManagement/obj/ -Doc/ .vs/ *.suo *.bak diff --git a/DataStreamInterface/DataFrame.cs b/DataStreamInterface/DataFrame.cs new file mode 100644 index 000000000..6338df650 --- /dev/null +++ b/DataStreamInterface/DataFrame.cs @@ -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; + } + } +} diff --git a/DataStreamInterface/DataStreamInterface.csproj b/DataStreamInterface/DataStreamInterface.csproj new file mode 100644 index 000000000..49ae9f254 --- /dev/null +++ b/DataStreamInterface/DataStreamInterface.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28} + Library + Properties + DataStreamInterface + DataStreamInterface + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/DataStreamInterface/Doc/Software interface for datastream water meters.docx b/DataStreamInterface/Doc/Software interface for datastream water meters.docx new file mode 100644 index 000000000..09770fbc1 Binary files /dev/null and b/DataStreamInterface/Doc/Software interface for datastream water meters.docx differ diff --git a/DataStreamInterface/Enums.cs b/DataStreamInterface/Enums.cs new file mode 100644 index 000000000..f913fc73c --- /dev/null +++ b/DataStreamInterface/Enums.cs @@ -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 + } +} diff --git a/DataStreamInterface/IDataStreamMeter.cs b/DataStreamInterface/IDataStreamMeter.cs new file mode 100644 index 000000000..6255b1b0a --- /dev/null +++ b/DataStreamInterface/IDataStreamMeter.cs @@ -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 + { + /// + /// Get state of the connected data stream meter + /// + /// Current state of the meter + /// true when successful + bool GetState(out int state, out string parameter); + + /// + /// Set state of the connected data stream meter + /// + /// Required state of the meter + /// true when successful + bool SetState(int state, string parameter); + + /// + /// Establish connection with a data stream meter + /// + /// Connection parameters + /// Meter ID (e.g. serial number) + /// true when successful + bool OpenConnection(string connectionParameters, out string meterId); + + /// + /// Closes connection with the data stream meter + /// + /// true when successful + bool CloseConnection(); + + /// + /// 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. + /// + /// true when successful + bool StartMeasurement(); + + /// + /// Stops saving measurement results into internal data structures of the component. + /// Updates ID of the last date frame received from the meter. + /// + /// ID of the last date frame + /// true when successful + bool StopMeasurement(out UInt64 lastFrameID); + + ///------------------------------------------------ + /// Units of time, volume and optional quantities + ///------------------------------------------------ + + /// + /// Returns time units (s, ms, ...) + /// + Unit GetTimeUnits(); + + /// + /// Returns units of volume (ml, l, ...) + /// + Unit GetVolumeUnits(); + + ///----------------------------------------------- + /// Ooptional quantities: count, units, captions + ///----------------------------------------------- + + /// + /// Returns count of optional quantities in each data frame + /// + /// Count of optional quantities + int GetQuantitiesCount(); + + /// + /// Returns units of the specified quantity + /// + /// Zero based quantity number 0 .. quantites count-1 + Unit GetQuantityUnits(int quanityNr); + + /// + /// Returns caption of the specified quantity + /// + /// Zero based quantity number 0 .. quantites count-1 + string GetQuantityCaption(int quanityNr); + + ///--------------------------- + /// Datastream data exchange + ///--------------------------- + + /// + /// Retuns 'count' data frames starting with data frame with ID = 'id' + /// + /// First frame ID + /// Frames count + /// Selected data frames + DataFrame[] GetFrames(UInt64 id, int count); + + /// + /// 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. + /// + /// Time + /// ID of the data frame at or after the pecified time + UInt64 GetID(double time); + } +} diff --git a/DataStreamInterface/Properties/AssemblyInfo.cs b/DataStreamInterface/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7e172011f --- /dev/null +++ b/DataStreamInterface/Properties/AssemblyInfo.cs @@ -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")] diff --git a/TBF.sln b/TBF.sln index 777120a0e..8d202f8ac 100644 --- a/TBF.sln +++ b/TBF.sln @@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventViewer", "EventViewer\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{C8939821-BA5C-4988-A3D0-BF53B74865C7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataStreamInterface", "DataStreamInterface\DataStreamInterface.csproj", "{7EBEEA14-91C4-48D7-AF0A-7A4BC3FF9A28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 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.Build.0 = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/clean.bat b/clean.bat index bc5931579..1e408ae9a 100644 --- a/clean.bat +++ b/clean.bat @@ -2,6 +2,8 @@ rmdir /s /q Common\bin rmdir /s /q Common\obj rmdir /s /q Config\bin rmdir /s /q Config\obj +rmdir /s /q DataStreamInterface\bin +rmdir /s /q DataStreamInterface\obj rmdir /s /q Decrypt\bin rmdir /s /q Decrypt\obj rmdir /s /q DeviceTest\bin