Compare commits
475 Commits
feature/Ka
...
MilwaukeeT
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bff6f33de | ||
|
|
e0d10bed71 | ||
|
|
a1df68b888 | ||
|
|
a625e2dfdb | ||
|
|
0181294872 | ||
|
|
401828d4c6 | ||
|
|
2c6e5d3367 | ||
|
|
38983990c2 | ||
|
|
e02411d180 | ||
|
|
69f729b713 | ||
|
|
f773e26fa3 | ||
|
|
9fed5148b6 | ||
|
|
ab3a16bdc5 | ||
|
|
6e3f0dad0e | ||
|
|
ed066a005f | ||
|
|
d3126bd9ea | ||
|
|
1c638b3f87 | ||
|
|
f0afcd57a2 | ||
|
|
769cb230e3 | ||
|
|
3c52e54e02 | ||
|
|
068b7fb3a2 | ||
|
|
2ba6586a0e | ||
|
|
fa403a322a | ||
|
|
30627abc6a | ||
|
|
78772df3a0 | ||
|
|
426bb0cce9 | ||
|
|
3da6fcfe73 | ||
|
|
8f27d1a448 | ||
|
|
c5752f21a9 | ||
|
|
8c30cb21e2 | ||
|
|
5181f75217 | ||
|
|
7ee41afba2 | ||
|
|
5bb99bbf86 | ||
|
|
6fd67cdf08 | ||
|
|
e1bfa71310 | ||
|
|
2476ed7681 | ||
|
|
e413b55c6a | ||
|
|
7d2da63071 | ||
|
|
9aad4a60ab | ||
|
|
6ffbda6e96 | ||
|
|
72a8f1dac6 | ||
|
|
d2631c8c88 | ||
|
|
66b463c468 | ||
|
|
af38dbe81b | ||
|
|
42010a6c26 | ||
|
|
21d3f5e835 | ||
|
|
e93aa6a21e | ||
|
|
812ac96284 | ||
|
|
363f42e75b | ||
|
|
2232c31451 | ||
|
|
1c6e3c17fa | ||
|
|
4d0c34b544 | ||
|
|
93c2338d6c | ||
|
|
a455d62e9e | ||
|
|
aed42818b5 | ||
|
|
281aa93b4b | ||
|
|
3fee487c5d | ||
|
|
e50c636a34 | ||
|
|
1cbab1acd7 | ||
|
|
3bc8b55429 | ||
|
|
e6fc3c25d6 | ||
|
|
b965541b1c | ||
|
|
02fae9b11e | ||
|
|
1eda22a391 | ||
|
|
15c916ae66 | ||
|
|
03fb87e6ed | ||
|
|
bf67b4a4ec | ||
|
|
78d05fb1b9 | ||
|
|
0d47578441 | ||
|
|
07d75b7d00 | ||
|
|
cc88308513 | ||
|
|
bdf3d155f4 | ||
|
|
fe4531ad4c | ||
|
|
23f9331460 | ||
|
|
0d6875065c | ||
|
|
b56f712c71 | ||
|
|
7cc20771fe | ||
|
|
3efb042d18 | ||
|
|
fba8c52dfb | ||
|
|
aa10ea5c04 | ||
|
|
f457278342 | ||
|
|
a0c45d2b39 | ||
|
|
799e5be919 | ||
|
|
08c4541914 | ||
|
|
7b95f5f436 | ||
|
|
f0e57554f2 | ||
|
|
c8a5640ddc | ||
|
|
1a7a5661c4 | ||
|
|
94e83ad63a | ||
|
|
5d2008a6dd | ||
|
|
c315c8a42b | ||
|
|
aaa78d60db | ||
|
|
4b42b5ba7a | ||
|
|
6e04933eeb | ||
|
|
f47e7670a3 | ||
|
|
78575e4f6f | ||
|
|
b38ee92fe4 | ||
|
|
4ac72c6bbf | ||
|
|
c0e7eab3b2 | ||
|
|
5081969fdc | ||
|
|
df386a14f8 | ||
|
|
2b0ee55901 | ||
|
|
5b893d69b4 | ||
|
|
a50c867b7e | ||
|
|
ebcbd47f91 | ||
|
|
310ed6158a | ||
|
|
c64e8e773f | ||
|
|
56275063f7 | ||
|
|
d7401cfec4 | ||
|
|
0849467857 | ||
|
|
d83762ddec | ||
|
|
4640018e78 | ||
|
|
67ebe0718a | ||
|
|
b1bebbff50 | ||
|
|
26126d380b | ||
|
|
c6a2965faf | ||
|
|
77c713425a | ||
|
|
604120e2b8 | ||
|
|
d29d8be81a | ||
|
|
6a374c5af0 | ||
|
|
a14e21eb57 | ||
|
|
100a357fc1 | ||
|
|
75fcffc9c3 | ||
|
|
8d6d0c011b | ||
|
|
be8f6814c8 | ||
|
|
75766938be | ||
|
|
08b3ab45ba | ||
|
|
0539844d85 | ||
|
|
da7ac83c75 | ||
|
|
01f0c03f62 | ||
|
|
9ac1b0b6fa | ||
|
|
685d57db8b | ||
|
|
7de5551c24 | ||
|
|
36c52e5d7e | ||
|
|
9f6bfc6410 | ||
|
|
81498a6db4 | ||
|
|
a595b6cd8d | ||
|
|
668d68a80c | ||
|
|
61ea3ef86b | ||
|
|
a7118935ca | ||
|
|
b044b00571 | ||
|
|
0e77a31a0f | ||
|
|
2183d1c452 | ||
|
|
be97777159 | ||
|
|
4781acf3e2 | ||
|
|
207d4be3d6 | ||
|
|
92b2f55871 | ||
|
|
0fd0c44c18 | ||
|
|
5629b94e47 | ||
|
|
3bff80f64b | ||
|
|
b3df3307a0 | ||
|
|
1f12464218 | ||
|
|
b17282f826 | ||
|
|
ae348d13fd | ||
|
|
e7ab26669e | ||
|
|
c44202b0ce | ||
|
|
db0939ec0d | ||
|
|
3dc6f291bb | ||
|
|
38b8184dfb | ||
|
|
e12a3eecba | ||
|
|
a7a7fbd403 | ||
|
|
0fa621bd6a | ||
|
|
1b14954a6d | ||
|
|
a70491d236 | ||
|
|
071abc015b | ||
|
|
03e0120121 | ||
|
|
87a60be61f | ||
|
|
420efb1ae0 | ||
|
|
23793d20da | ||
|
|
0983270730 | ||
|
|
d8a6404e83 | ||
|
|
4197328be9 | ||
|
|
7f3cc27138 | ||
|
|
80d347ef54 | ||
|
|
6d3ed2799b | ||
|
|
72bf9135b5 | ||
|
|
aa1d9e4b3b | ||
|
|
dab575dc49 | ||
|
|
2c91ded0db | ||
|
|
8d640bb52a | ||
|
|
1b4ac3451f | ||
|
|
ef13de9874 | ||
|
|
c2d5719d31 | ||
|
|
96a86a04da | ||
|
|
2a26da6337 | ||
|
|
8ef21b3831 | ||
|
|
75c97d99e8 | ||
|
|
d7fd270cd5 | ||
|
|
f6886a8fdc | ||
|
|
947d0198c1 | ||
|
|
a4a583c41a | ||
|
|
61add6be07 | ||
|
|
5a5f8493f2 | ||
|
|
cfaf8e6a59 | ||
|
|
5854a6e620 | ||
|
|
5623f27959 | ||
|
|
15e5d65ee9 | ||
|
|
8e0417de9c | ||
|
|
ffb6401555 | ||
|
|
7216ac321d | ||
|
|
5fea1834bb | ||
|
|
5c53929efe | ||
|
|
3812438e97 | ||
|
|
3cb64b2684 | ||
|
|
7ea057dab4 | ||
|
|
0493f8fae5 | ||
|
|
ed606701c0 | ||
|
|
1d152afd6c | ||
|
|
71517b6cdb | ||
|
|
284feb73dc | ||
|
|
ce74b0a3bb | ||
|
|
4de15b9a7c | ||
|
|
6fd7845d63 | ||
|
|
30c8433cb0 | ||
|
|
7cf862410b | ||
|
|
766b52865a | ||
|
|
b9aebd8903 | ||
|
|
50494fccc9 | ||
|
|
e0c2004f52 | ||
|
|
d86daefc81 | ||
|
|
dd52b9d139 | ||
|
|
eec84351ac | ||
|
|
7b7b515154 | ||
|
|
6c57f8c76a | ||
|
|
3312dc40f8 | ||
|
|
54cb6e4303 | ||
|
|
4f2fb85372 | ||
|
|
a3f8902266 | ||
|
|
2e8b962d57 | ||
|
|
ebad16b439 | ||
|
|
5b599c2ecd | ||
|
|
f3a889eed8 | ||
|
|
9aa41338ed | ||
|
|
5797e97e0f | ||
|
|
352f2c1e28 | ||
|
|
df63f4300a | ||
|
|
171aee4f1d | ||
|
|
e00e7556d6 | ||
|
|
3f94318570 | ||
|
|
7356f45b93 | ||
|
|
f725c2d2d8 | ||
|
|
4021ed1a7b | ||
|
|
4a820af389 | ||
|
|
0b8d51daba | ||
|
|
21408a962e | ||
|
|
f854bf2277 | ||
|
|
e6d35e5178 | ||
|
|
a203885c16 | ||
|
|
698e2dd6c4 | ||
|
|
5c55b2540a | ||
|
|
3d7ead8464 | ||
|
|
30845f4ca3 | ||
|
|
f72457404b | ||
|
|
7ab2930bf7 | ||
|
|
0cf2c442ec | ||
|
|
756fa12456 | ||
|
|
bb0361319d | ||
|
|
2cc92f3980 | ||
|
|
abb2375500 | ||
|
|
64a5f7ceb8 | ||
|
|
adfb9ae8d5 | ||
|
|
9e139279c7 | ||
|
|
adf7a44a54 | ||
|
|
c1860ab31c | ||
|
|
ba9d06ac3f | ||
|
|
8115ec4ac5 | ||
|
|
f5e5d1fd0c | ||
|
|
9ecba98b4c | ||
|
|
11ca2b7272 | ||
|
|
df232cf508 | ||
|
|
8c9643a8de | ||
|
|
8a85458865 | ||
|
|
848f9dff9d | ||
|
|
5905d0850b | ||
|
|
5d144dfc24 | ||
|
|
dcf746dc6b | ||
|
|
4e216c42de | ||
|
|
4f52093af6 | ||
|
|
c2826cbd27 | ||
|
|
d3c62e353c | ||
|
|
1349c39d2d | ||
|
|
7d1d9b1051 | ||
|
|
c4ca299ce2 | ||
|
|
96a17b2d16 | ||
|
|
5b4ffd9327 | ||
|
|
96abee384b | ||
|
|
1e93a1e9ae | ||
|
|
dfd6399d6c | ||
|
|
7bdf6efd9d | ||
|
|
0e78f40cca | ||
|
|
56fc3b6380 | ||
|
|
a1e73be9cb | ||
|
|
bb4b1a1998 | ||
|
|
c4afaf739a | ||
|
|
2e8c5fa6f6 | ||
|
|
e46b64bd29 | ||
|
|
61ecb23294 | ||
|
|
674dde8d74 | ||
|
|
186bbdcc25 | ||
|
|
2a82fbf2ca | ||
|
|
678fefb725 | ||
|
|
58a57ba215 | ||
|
|
4d77926a9e | ||
|
|
a7e2947de7 | ||
|
|
4a33339c63 | ||
|
|
7b780d72a0 | ||
|
|
7a60055413 | ||
|
|
c6f3751746 | ||
|
|
300dabc800 | ||
|
|
d51ff414ca | ||
|
|
6f65f0085e | ||
|
|
319cf0b8d4 | ||
|
|
c1daf13411 | ||
|
|
4fd107678d | ||
|
|
e1d3be7e56 | ||
|
|
4f9b07ba20 | ||
|
|
8e25fa6232 | ||
|
|
760ec598ca | ||
|
|
fd77380315 | ||
|
|
bf91dc0aa6 | ||
|
|
14a3d63f1f | ||
|
|
0a60f9c64d | ||
|
|
258fd2579f | ||
|
|
4ec2dee3a2 | ||
|
|
723bf3fdeb | ||
|
|
315cccf74c | ||
|
|
1b68ea8ab9 | ||
|
|
9111bd7346 | ||
|
|
cfdd59abce | ||
|
|
4972347605 | ||
|
|
3459a5eac5 | ||
|
|
0553caac89 | ||
|
|
4464a2025b | ||
|
|
03197dc8f3 | ||
|
|
e74c8692ce | ||
|
|
cda8359623 | ||
|
|
508315a43f | ||
|
|
9a8c9205d3 | ||
|
|
d7728d304a | ||
|
|
fd0d7dcf7b | ||
|
|
997e0d2a6b | ||
|
|
51e1e5721c | ||
|
|
34c3fa26c9 | ||
|
|
5e3e70f43a | ||
|
|
18880dc04d | ||
|
|
2673584113 | ||
|
|
e90967b6ed | ||
|
|
46489224cf | ||
|
|
d8fc4a4c36 | ||
|
|
ae18e15fba | ||
|
|
352ed581c2 | ||
|
|
b5572c20e3 | ||
|
|
1d50b7206d | ||
|
|
331803e51d | ||
|
|
ed25f1a360 | ||
|
|
111fd8d96c | ||
|
|
c86bafd779 | ||
|
|
c472bfc99d | ||
|
|
b8eaaeb64c | ||
|
|
b09a057b02 | ||
|
|
9f19df7f3f | ||
|
|
db9506290a | ||
|
|
4505759115 | ||
|
|
d15497f2b0 | ||
|
|
ec9edbf04c | ||
|
|
31b167cd62 | ||
|
|
1d33b9651b | ||
|
|
3bf8b4fe54 | ||
|
|
2e75d91adc | ||
|
|
55d9d58978 | ||
|
|
241bb3aff1 | ||
|
|
0fa8057324 | ||
|
|
4609abe6ea | ||
|
|
cb6d9538c8 | ||
|
|
8ec062b165 | ||
|
|
b2df02dd1b | ||
|
|
c403f9345f | ||
|
|
b97b795c93 | ||
|
|
4a1c6ef031 | ||
|
|
40f3aacd32 | ||
|
|
8e9344cc47 | ||
|
|
b3160799c8 | ||
|
|
66852682bf | ||
|
|
3399b07fc0 | ||
|
|
844f5573dc | ||
|
|
e9cc77a2d5 | ||
|
|
2981ab2a5f | ||
|
|
a3227f356f | ||
|
|
0d8210614d | ||
|
|
97df1250dc | ||
|
|
11eff5c962 | ||
|
|
f95f961a5d | ||
|
|
4db2f475cd | ||
|
|
9dbbf03acd | ||
|
|
d8ed144dee | ||
|
|
99cd84fb2a | ||
|
|
de0b84076f | ||
|
|
18506390fa | ||
|
|
fd9a08406f | ||
|
|
6226fbedfc | ||
|
|
86fb107e73 | ||
|
|
b32329cdf7 | ||
|
|
38c7d43a8a | ||
|
|
c72fb29f36 | ||
|
|
0dd5c469f5 | ||
|
|
df1b4527ba | ||
|
|
6da5bd92ec | ||
|
|
d4ac2453b8 | ||
|
|
59c1cb76f0 | ||
|
|
89b47860a5 | ||
|
|
646cebe877 | ||
|
|
f8b8c3bfec | ||
|
|
723c077c64 | ||
|
|
7e64c9299c | ||
|
|
ea9c0615ee | ||
|
|
428d100f6c | ||
|
|
8846f16546 | ||
|
|
37ec839807 | ||
|
|
5f44fd4bdb | ||
|
|
5f5063663c | ||
|
|
75f0cb2930 | ||
|
|
1f581a72c1 | ||
|
|
705f4de0b0 | ||
|
|
6ec3b7b287 | ||
|
|
9758411519 | ||
|
|
e1a185efdf | ||
|
|
a2556bec35 | ||
|
|
483e2b4eb7 | ||
|
|
f1d46782d3 | ||
|
|
d1adde9b63 | ||
|
|
95c7257d6f | ||
|
|
91392f9452 | ||
|
|
b145c71ee3 | ||
|
|
1cf2eb8e06 | ||
|
|
037a5be3b3 | ||
|
|
0fc7d831b0 | ||
|
|
abf54f765f | ||
|
|
0e7ba933d8 | ||
|
|
fa03c09f09 | ||
|
|
3ac90ee622 | ||
|
|
774f561fcf | ||
|
|
3a626740c7 | ||
|
|
97ce601d31 | ||
|
|
49d4cf1ac0 | ||
|
|
dcb0ee680c | ||
|
|
e94eb83c1d | ||
|
|
ff3de55593 | ||
|
|
1e50cc6fb7 | ||
|
|
7b31c6b2b6 | ||
|
|
38ee1cc067 | ||
|
|
e27dfe570d | ||
|
|
b2f2f595e5 | ||
|
|
67f4683026 | ||
|
|
42f8d02a68 | ||
|
|
14717d5d46 | ||
|
|
450530a707 | ||
|
|
adf30d615b | ||
|
|
610387e071 | ||
|
|
114e628305 | ||
|
|
68d01aab14 | ||
|
|
eaf0e2cf22 | ||
|
|
02ec8d8124 | ||
|
|
1dc328746d | ||
|
|
5bb94666a4 | ||
|
|
c1f23b8481 | ||
|
|
70c11ad6d9 | ||
|
|
3a8c6b4d3e | ||
|
|
b8f1b9293a | ||
|
|
6558951857 | ||
|
|
54e964ffde | ||
|
|
a5b270eec8 | ||
|
|
6f9c6596d5 | ||
|
|
d99c53bc8e | ||
|
|
3496fcbbba | ||
|
|
77a29dadfc |
12
.gitignore
vendored
12
.gitignore
vendored
@ -4,6 +4,10 @@ Config/bin/
|
||||
Config/obj/
|
||||
DataStreamInterface/bin/
|
||||
DataStreamInterface/obj/
|
||||
DataStreamInterfaceTest/bin/
|
||||
DataStreamInterfaceTest/obj/
|
||||
DataStreamMeter/bin/
|
||||
DataStreamMeter/obj/
|
||||
Decrypt/bin/
|
||||
Decrypt/obj/
|
||||
DeviceTest/bin/
|
||||
@ -16,20 +20,28 @@ EventViewer/bin/
|
||||
EventViewer/obj/
|
||||
Events/bin/
|
||||
Events/obj/
|
||||
FeatureVectorCalculator/bin/
|
||||
FeatureVectorCalculator/obj/
|
||||
GemCard/bin
|
||||
GemCard/obj
|
||||
GenCode128/bin
|
||||
GenCode128/obj
|
||||
GraphLib/bin
|
||||
GraphLib/obj
|
||||
MergeResultsDBs/bin
|
||||
MergeResultsDBs/obj
|
||||
TracingDB/bin
|
||||
TracingDB/obj
|
||||
ResetBatchNr/bin
|
||||
ResetBatchNr/obj
|
||||
RestClient/bin
|
||||
RestClient/obj
|
||||
Results/bin/
|
||||
Results/obj/
|
||||
ResultsBrowser/bin/
|
||||
ResultsBrowser/obj/
|
||||
ResultsParser/bin/
|
||||
ResultsParser/obj/
|
||||
Statistics/bin/
|
||||
Statistics/obj/
|
||||
TBF/bin/
|
||||
|
||||
37
Common/BackgroundBeep.cs
Normal file
37
Common/BackgroundBeep.cs
Normal file
@ -0,0 +1,37 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public class BackgroundBeep
|
||||
{
|
||||
static Thread beepThread;
|
||||
static AutoResetEvent signalBeep;
|
||||
|
||||
static BackgroundBeep()
|
||||
{
|
||||
signalBeep = new AutoResetEvent(false);
|
||||
beepThread = new Thread(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
signalBeep.WaitOne(); /// waits for an event
|
||||
Console.Beep(500, 400); /// frequency (Hz), duration (ms)
|
||||
}
|
||||
}, 1);
|
||||
beepThread.IsBackground = true;
|
||||
beepThread.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes one beep in a separate thread (non-blocking function)
|
||||
/// </summary>
|
||||
public static void Beep()
|
||||
{
|
||||
signalBeep.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,23 +41,57 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BackgroundBeep.cs" />
|
||||
<Compile Include="Const.cs" />
|
||||
<Compile Include="DatabaseSettings.cs" />
|
||||
<Compile Include="DBSettings.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Forms\ListViewEx.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ListViewExtensions.cs" />
|
||||
<Compile Include="Forms\LviDateTimeColumnComparer.cs" />
|
||||
<Compile Include="Forms\LviIntColumnComparer.cs" />
|
||||
<Compile Include="Forms\LviNameSurnameColumnComparer.cs" />
|
||||
<Compile Include="Forms\LviTextColumnComparer.cs" />
|
||||
<Compile Include="Forms\MessageEventArgs.cs" />
|
||||
<Compile Include="Forms\ModelessForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ModelessForm.designer.cs">
|
||||
<DependentUpon>ModelessForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IMeasurementCorrection.cs" />
|
||||
<Compile Include="IOrderInfo.cs" />
|
||||
<Compile Include="IParamsProvider.cs" />
|
||||
<Compile Include="IUncertainty.cs" />
|
||||
<Compile Include="IUser.cs" />
|
||||
<Compile Include="Printers\PrintersCommon.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="QuitAppException.cs" />
|
||||
<Compile Include="StatisticalMetrics.cs" />
|
||||
<Compile Include="Iperl\OptoTelegramRaw.cs" />
|
||||
<Compile Include="SerializableDictionary.cs" />
|
||||
<Compile Include="Telegram.cs" />
|
||||
<Compile Include="UIControls\CoolButtonCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIControls\CoolButtonCtrl.Designer.cs">
|
||||
<DependentUpon>CoolButtonCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UIControls\LviDateTimeColumnComparer.cs" />
|
||||
<Compile Include="UIControls\RoundedRectangle.cs" />
|
||||
<Compile Include="Units.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UIControls\ListViewEx.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIControls\ListViewExtensions.cs" />
|
||||
<Compile Include="UIControls\LviIntColumnComparer.cs" />
|
||||
<Compile Include="UIControls\LviTextColumnComparer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Forms\ListViewEx.resx">
|
||||
<DependentUpon>ListViewEx.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\ModelessForm.resx">
|
||||
<DependentUpon>ModelessForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
12
Common/Const.cs
Normal file
12
Common/Const.cs
Normal file
@ -0,0 +1,12 @@
|
||||
///
|
||||
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public static class Const
|
||||
{
|
||||
public const string MySqlConnectTimeoutSec = "120";
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,24 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Users
|
||||
namespace Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Database settings required to make a connection
|
||||
/// </summary>
|
||||
public class DBSettings : ICloneable
|
||||
{
|
||||
public Users.Entities.DBType DbType;
|
||||
public DBType DbType;
|
||||
public string ConnectionString;
|
||||
public bool IsValid { get { return (DbType != DBType.None) && !string.IsNullOrEmpty(ConnectionString); } }
|
||||
|
||||
public DBSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public DBSettings(Users.Entities.DBType dbType, string connectionString)
|
||||
public DBSettings(DBType dbType, string connectionString)
|
||||
{
|
||||
this.DbType = dbType;
|
||||
this.ConnectionString = connectionString;
|
||||
121
Common/DatabaseSettings.cs
Normal file
121
Common/DatabaseSettings.cs
Normal file
@ -0,0 +1,121 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Test bench database settings, contains bench name and settings od several databases
|
||||
/// </summary>
|
||||
public class DatabaseSettings : ICloneable, IComparable
|
||||
{
|
||||
// Public fields
|
||||
public string BenchName;
|
||||
public bool IsRealBench;
|
||||
public DBSettings ProceduresDBSettings; /// Configuration database settings
|
||||
public DBSettings WaterMetersDBSettings; /// Results database settings
|
||||
public DBSettings EventsDBSettings; /// Events database settings
|
||||
public DBSettings UsersDBSettings; /// Shared configuration database settings
|
||||
|
||||
// Constructor
|
||||
public DatabaseSettings()
|
||||
{
|
||||
BenchName = String.Empty; /// Empty string (avoid null)
|
||||
IsRealBench = false;
|
||||
ProceduresDBSettings = new DBSettings(DBType.MySql, string.Empty);
|
||||
WaterMetersDBSettings = new DBSettings(DBType.MySql, string.Empty);
|
||||
EventsDBSettings = new DBSettings(DBType.MySql, string.Empty);
|
||||
UsersDBSettings = new DBSettings(DBType.MySql, string.Empty);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
DatabaseSettings result = new DatabaseSettings();
|
||||
|
||||
result.BenchName = BenchName;
|
||||
result.IsRealBench = IsRealBench;
|
||||
result.ProceduresDBSettings = (DBSettings)ProceduresDBSettings.Clone();
|
||||
result.WaterMetersDBSettings = (DBSettings)WaterMetersDBSettings.Clone();
|
||||
result.EventsDBSettings = (DBSettings)EventsDBSettings.Clone();
|
||||
result.UsersDBSettings = (DBSettings)UsersDBSettings.Clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int CompareTo(object dbs2)
|
||||
{
|
||||
if (!(dbs2 is DatabaseSettings)) return 0;
|
||||
return String.Compare(BenchName, (dbs2 as DatabaseSettings).BenchName);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a DB server from a MySQL connection string.
|
||||
/// </summary>
|
||||
public static string GetDBServer(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "SERVER=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a DB name from a MySQL connection string.
|
||||
/// </summary>
|
||||
public static string GetDBName(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "DATABASE=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a username from a MySQL connection string
|
||||
/// </summary>
|
||||
public static string GetDBUser(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "USER=", "UID=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a password from a MySQL connection string
|
||||
/// </summary>
|
||||
public static string GetDBPassword(string connectionString)
|
||||
{
|
||||
return GetFromConnectionString(connectionString, new string[] { "PASSWORD=", "PWD=" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return an element of a MySQL connection string
|
||||
/// (a host, a database, a user name or a password).
|
||||
/// Return an empty string on any error.
|
||||
/// </summary>
|
||||
public static string GetFromConnectionString(string connectionString, string[] patterns)
|
||||
{
|
||||
foreach (var pattern in patterns)
|
||||
{
|
||||
int startIx = connectionString.IndexOf(pattern);
|
||||
if (startIx >= 0)
|
||||
{
|
||||
/// pattern found, extract the subsequent element
|
||||
startIx += pattern.Length;
|
||||
int endIx = connectionString.IndexOf(';', startIx);
|
||||
return (endIx > 0) ? connectionString.Substring(startIx, endIx - startIx) : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// pattern NOT found
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} config={1} results={2} events={3} users={4}",
|
||||
BenchName,
|
||||
ProceduresDBSettings.ConnectionString,
|
||||
WaterMetersDBSettings.ConnectionString,
|
||||
EventsDBSettings.ConnectionString,
|
||||
UsersDBSettings.ConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Config.Entities
|
||||
namespace Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class to assign descriptions to enum values
|
||||
@ -39,19 +39,37 @@ namespace Config.Entities
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flags returned by each device configuration control Verify(...) function.
|
||||
/// Identifies the type of a database
|
||||
/// </summary>
|
||||
public enum CfgUpdateFlags
|
||||
public enum DBType
|
||||
{
|
||||
None = 0,
|
||||
Error = 0x1, /// Some settings in the user control are invalid and cannot be set
|
||||
Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation
|
||||
RestartRqrd = 0x04, /// TBF program restart is required to apply all changed parameters
|
||||
AnyChange = 0x08, /// At least one parameter have changed
|
||||
VolatileChange = 0x10,
|
||||
InvokeCfgChange = 0x20, /// Invoke CfgChange handler of the component
|
||||
None, /// Database disabled
|
||||
MySql, /// MySQL database
|
||||
SQLite, /// SQLite
|
||||
Count
|
||||
}
|
||||
|
||||
public enum ProcedureSelection
|
||||
{
|
||||
#if LANG_CS
|
||||
[Description("Žádné")] None,
|
||||
[Description("Lokální postupy")] FromLocalDB,
|
||||
[Description("Postupy ze sdílené databázy")] FromSharedDB,
|
||||
[Description("Zakázky z Oracle databázy")] OrderNrFromOracleDB,
|
||||
[Description("Zakázky ze sledovací databázy")] OrderNrFromTracingDB,
|
||||
#else
|
||||
[Description("None")] None,
|
||||
[Description("Local procedures")] FromLocalDB,
|
||||
[Description("Shared procedures")] FromSharedDB,
|
||||
[Description("Orders from Oracle DB")] OrderFromOracleDB,
|
||||
[Description("Orders from Tracing DB")] OrderFromTracingDB,
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obsolete - replaced by enum ProcedureSelection (above) in 3.1 and newer
|
||||
/// </summary>
|
||||
public enum RemoteDBUse
|
||||
{
|
||||
[Description("Local DB only")] LocalDBOnly,
|
||||
@ -62,7 +80,7 @@ namespace Config.Entities
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains a procedure name and a database specification (local/remote).
|
||||
/// Obsolete - Contains a procedure name and a database specification (local/remote).
|
||||
/// </summary>
|
||||
public class ProcedureInfo
|
||||
{
|
||||
@ -76,6 +94,119 @@ namespace Config.Entities
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test designation mode for IperlLogger and IperlHead opto data files
|
||||
/// </summary>
|
||||
public enum DesigMode
|
||||
{
|
||||
Auto,
|
||||
Based_on_procedure,
|
||||
As_specified,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum LoginMethod
|
||||
{
|
||||
UserName, /// = alias, abbreviation
|
||||
FullName, /// = description
|
||||
Number,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum AuthorizedAs
|
||||
{
|
||||
PowerUser,
|
||||
LocalUser,
|
||||
RemoteUser,
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GID-s of user groups, each user is member of one or more groups.
|
||||
/// </summary>
|
||||
public enum GID
|
||||
{
|
||||
Testers,
|
||||
TestingSpecialists,
|
||||
HeadOfLab,
|
||||
MaintenanceSpecialists,
|
||||
Metrologists,
|
||||
CalibrationSpecialists,
|
||||
Administrators, /// application / network / database administrator
|
||||
TraceabilityManagement,
|
||||
MetrologicalAuthority,
|
||||
WaterMeterAuthority,
|
||||
NrOfGroups, /// Number of groups (this is not a GroupID)
|
||||
None,
|
||||
}
|
||||
|
||||
public enum MySortOrder
|
||||
{
|
||||
None,
|
||||
Ascending, /// The same like SortOrder.Ascending
|
||||
Descending, /// The same like SortOrder.Descending
|
||||
Ascending2, /// Sorts by a surname in ascending order in case or 'Name Surname' column
|
||||
Descending2, /// Sorts by a surname in descending order in case or 'Name Surname' column
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flags returned by each device configuration control Verify(...) function.
|
||||
/// </summary>
|
||||
public enum CfgUpdateFlags
|
||||
{
|
||||
None = 0,
|
||||
Error = 0x1, /// Some settings in the user control are invalid and cannot be set
|
||||
Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation
|
||||
RestartRqrd = 0x04, /// TBF program restart is required to apply all changed parameters
|
||||
AnyChange = 0x08, /// At least one parameter have changed
|
||||
VolatileChange = 0x10,
|
||||
InvokeCfgChange = 0x20, /// Invoke CfgChange handler of the component
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event severity
|
||||
/// </summary>
|
||||
public enum Severity
|
||||
{
|
||||
Undefined,
|
||||
Notification,
|
||||
Warning,
|
||||
Error,
|
||||
FatalError,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum EventClass
|
||||
{
|
||||
Undefined,
|
||||
EquipmentHW,
|
||||
Metrology,
|
||||
TestingProcess,
|
||||
BadResults,
|
||||
ComputerResources,
|
||||
Network,
|
||||
Other,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum SubscriberGroup : long
|
||||
{
|
||||
None = 0,
|
||||
Metrology = 1,
|
||||
Maintenance = 2,
|
||||
Production = 4,
|
||||
Management = 8,
|
||||
Finish = 16,
|
||||
}
|
||||
|
||||
public enum EViewerOption
|
||||
{
|
||||
Undefined,
|
||||
AllEvents,
|
||||
RecentEvents,
|
||||
UnreadEvents,
|
||||
}
|
||||
|
||||
public enum ProcedureState
|
||||
{
|
||||
Active,
|
||||
@ -83,6 +214,14 @@ namespace Config.Entities
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum FlowNames
|
||||
{
|
||||
QnQtQmin = 0,
|
||||
Q3Q2Q1 = 1,
|
||||
QpQi = 2,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum ProfileType
|
||||
{
|
||||
Q3R,
|
||||
@ -164,11 +303,13 @@ namespace Config.Entities
|
||||
[Description("V")] V, /// vertical
|
||||
[Description("STR")] S, /// standrohre
|
||||
[Description("F")] F, /// fall
|
||||
[Description("H/V")] HV, /// horizontal / vertical
|
||||
#else
|
||||
[Description("H")] H, /// horizontal
|
||||
[Description("V")] V, /// vertical
|
||||
[Description("S")] S, /// steig
|
||||
[Description("F")] F, /// fall
|
||||
[Description("H")] H, /// horizontal
|
||||
[Description("V")] V, /// vertical
|
||||
[Description("S")] S, /// steig
|
||||
[Description("F")] F, /// fall
|
||||
[Description("H/V")] HV, /// horizontal / vertical
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
@ -200,6 +341,7 @@ namespace Config.Entities
|
||||
[Description("")] NotSpecified,
|
||||
[Description("U0")] U0, /// ?
|
||||
[Description("D0")] D0, /// ?
|
||||
///
|
||||
Count
|
||||
}
|
||||
|
||||
@ -248,6 +390,17 @@ namespace Config.Entities
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// State of water filled in the test bench.
|
||||
/// </summary>
|
||||
public enum FillState
|
||||
{
|
||||
Unknown, /// Test bench fill state is unknown
|
||||
Empty, /// Test bench is empty, no water
|
||||
Full, /// Test bench is full of water
|
||||
Count
|
||||
}
|
||||
|
||||
public enum MeretProtocol
|
||||
{
|
||||
[Description("<undefined>")] Undefined,
|
||||
@ -424,7 +577,7 @@ namespace Config.Entities
|
||||
[Description("Fehler")] FailureDuringOperation, /// Failure during operation -> disabled
|
||||
[Description("Aus")] Off, /// The component is off
|
||||
[Description("Aufzeichnen")] Record,
|
||||
[Description("Reply")] Reply,
|
||||
[Description("Abspielen")] Replay,
|
||||
[Description("Simuliert")] Simulate, /// Test bench simulation, this mode does not require any hardware
|
||||
[Description("Geerbt")] Inherit,
|
||||
#elif LANG_FR
|
||||
@ -435,7 +588,7 @@ namespace Config.Entities
|
||||
[Description("Erreur d'exécution")] FailureDuringOperation,
|
||||
[Description("Éteindre")] Off,
|
||||
[Description("Record")] Record,
|
||||
[Description("Répondre")] Reply,
|
||||
[Description("Répondre")] Replay,
|
||||
[Description("Simuler")] Simulate,
|
||||
[Description("Hériter")] Inherit,
|
||||
#else
|
||||
@ -446,7 +599,7 @@ namespace Config.Entities
|
||||
[Description("Run-time error")] FailureDuringOperation, /// Failure during operation -> disabled
|
||||
[Description("Off")] Off, /// The component is off
|
||||
[Description("Record")] Record,
|
||||
[Description("Reply")] Reply,
|
||||
[Description("Replay")] Replay,
|
||||
[Description("Simulate")] Simulate, /// Test bench simulation, this mode does not require any hardware
|
||||
[Description("Inherit")] Inherit,
|
||||
#endif
|
||||
@ -551,26 +704,32 @@ namespace Config.Entities
|
||||
[Description("aus")] Off,
|
||||
[Description("info")] Info,
|
||||
[Description("ein")] On,
|
||||
[Description("stopp")] Stop,
|
||||
#elif LANG_FR
|
||||
[Description("éteindre")] Off,
|
||||
[Description("info")] Info,
|
||||
[Description("allumé")] On,
|
||||
[Description("arrêter")] Stop,
|
||||
#elif LANG_CS
|
||||
[Description("vypnuto")] Off,
|
||||
[Description("info")] Info,
|
||||
[Description("zapnuto")] On,
|
||||
[Description("stop")] Stop,
|
||||
#elif LANG_RU
|
||||
[Description("выкл")] Off,
|
||||
[Description("инфо")] Info,
|
||||
[Description("вкл")] On,
|
||||
[Description("останов")] Stop,
|
||||
#elif LANG_PL
|
||||
[Description("nie")] Off,
|
||||
[Description("info")] Info,
|
||||
[Description("tak")] On,
|
||||
[Description("przestać")] Stop,
|
||||
#else // LANG_EN
|
||||
[Description("off")] Off,
|
||||
[Description("info")] Info,
|
||||
[Description("on")] On,
|
||||
[Description("stop")] Stop,
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
@ -578,15 +737,15 @@ namespace Config.Entities
|
||||
|
||||
public enum ErrorFlagMask : long
|
||||
{
|
||||
E1 = (1L << 0), /// shift = 0, E1 = 1L
|
||||
E2 = (1L << 1),
|
||||
E3 = (1L << 2),
|
||||
E4 = (1L << 3),
|
||||
E5 = (1L << 4),
|
||||
E6 = (1L << 5),
|
||||
E7 = (1L << 6),
|
||||
E8 = (1L << 7),
|
||||
E9 = (1L << 8),
|
||||
E1 = (1L << 0), /// shift = 0, E1 = 1L
|
||||
E2 = (1L << 1),
|
||||
E3 = (1L << 2),
|
||||
E4 = (1L << 3),
|
||||
E5 = (1L << 4),
|
||||
E6 = (1L << 5),
|
||||
E7 = (1L << 6),
|
||||
E8 = (1L << 7),
|
||||
E9 = (1L << 8),
|
||||
E10 = (1L << 9),
|
||||
E11 = (1L << 10),
|
||||
E12 = (1L << 11),
|
||||
@ -642,4 +801,44 @@ namespace Config.Entities
|
||||
E62 = (1L << 61),
|
||||
E63 = (1L << 62),
|
||||
}
|
||||
|
||||
#region iPERL enums
|
||||
|
||||
public enum Side
|
||||
{
|
||||
#if LANG_CS
|
||||
[Description("Levá")] Left,
|
||||
[Description("Pravá")] Right,
|
||||
#else
|
||||
[Description("Left")] Left,
|
||||
[Description("Right")] Right,
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
|
||||
public enum FlowDir
|
||||
{
|
||||
R_L,
|
||||
L_R,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Counting
|
||||
{
|
||||
Arbitrary,
|
||||
Positive,
|
||||
Negative,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum OptoHeadState
|
||||
{
|
||||
Disabled,
|
||||
OptoAndDirOK,
|
||||
OptoNok,
|
||||
DirNok,
|
||||
Count
|
||||
}
|
||||
|
||||
#endregion iPERL enums
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
@ -9,7 +9,7 @@ using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Common.UIControls
|
||||
namespace Common.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Event Handler for SubItem events
|
||||
@ -61,6 +61,9 @@ namespace Common.UIControls
|
||||
private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
|
||||
#endregion
|
||||
|
||||
public MySortOrder SortOrder = MySortOrder.None;
|
||||
public int SortColumn = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
@ -424,12 +427,18 @@ namespace Common.UIControls
|
||||
|
||||
OnSubItemEndEditing(e);
|
||||
|
||||
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
|
||||
if (_editSubItem >= 0 && _editSubItem < _editItem.SubItems.Count)
|
||||
{
|
||||
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
|
||||
}
|
||||
|
||||
_editingControl.Leave -= new EventHandler(_editControl_Leave);
|
||||
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
|
||||
if (_editingControl != null)
|
||||
{
|
||||
_editingControl.Leave -= new EventHandler(_editControl_Leave);
|
||||
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
|
||||
|
||||
_editingControl.Visible = false;
|
||||
_editingControl.Visible = false;
|
||||
}
|
||||
|
||||
_editingControl = null;
|
||||
_editItem = null;
|
||||
@ -1,9 +1,12 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Users.Forms
|
||||
namespace Common.Forms
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class ListViewExtensions
|
||||
@ -55,7 +58,7 @@ namespace Users.Forms
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
|
||||
|
||||
public static void SetSortIcon(this ListView listViewControl, int columnIndex, MySortOrder order)
|
||||
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, MySortOrder order)
|
||||
{
|
||||
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
|
||||
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
|
||||
@ -86,6 +89,9 @@ namespace Users.Forms
|
||||
item.fmt &= ~HDITEM.Format.SortUp;
|
||||
item.fmt |= HDITEM.Format.SortDown;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1,24 +1,24 @@
|
||||
///
|
||||
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Common.UIControls
|
||||
namespace Common.Forms
|
||||
{
|
||||
public class LviDateTimeColumnComparer : IComparer
|
||||
{
|
||||
int column;
|
||||
SortOrder order;
|
||||
MySortOrder order;
|
||||
|
||||
public LviDateTimeColumnComparer()
|
||||
{
|
||||
column = 0;
|
||||
order = SortOrder.Ascending;
|
||||
order = MySortOrder.Ascending;
|
||||
}
|
||||
|
||||
public LviDateTimeColumnComparer(int column, SortOrder order)
|
||||
public LviDateTimeColumnComparer(int column, MySortOrder order)
|
||||
{
|
||||
this.column = column;
|
||||
this.order = order;
|
||||
@ -33,13 +33,13 @@ namespace Common.UIControls
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (order == SortOrder.Ascending)
|
||||
else if ((order == MySortOrder.Descending || order == MySortOrder.Descending2))
|
||||
{
|
||||
return (valX > valY) ? 1 : -1;
|
||||
return (valY > valX) ? 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (valY > valX) ? 1 : -1;
|
||||
return (valX > valY) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Users.Forms
|
||||
namespace Common.Forms
|
||||
{
|
||||
class LviIntColumnComparer : IComparer
|
||||
public class LviIntColumnComparer : IComparer
|
||||
{
|
||||
int column;
|
||||
MySortOrder order;
|
||||
@ -2,9 +2,9 @@
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Users.Forms
|
||||
namespace Common.Forms
|
||||
{
|
||||
class LviNameSurnameColumnComparer : IComparer
|
||||
public class LviNameSurnameColumnComparer : IComparer
|
||||
{
|
||||
private int column;
|
||||
MySortOrder order;
|
||||
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Users.Forms
|
||||
namespace Common.Forms
|
||||
{
|
||||
class LviTextColumnComparer : IComparer
|
||||
public class LviTextColumnComparer : IComparer
|
||||
{
|
||||
private int column;
|
||||
MySortOrder order;
|
||||
10
Common/Forms/MessageEventArgs.cs
Normal file
10
Common/Forms/MessageEventArgs.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Common.Forms
|
||||
{
|
||||
public class MessageEventArgs : EventArgs
|
||||
{
|
||||
public string Message;
|
||||
public MessageEventArgs(string message) { Message = message; }
|
||||
}
|
||||
}
|
||||
63
Common/Forms/ModelessForm.Designer.cs
generated
Normal file
63
Common/Forms/ModelessForm.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
namespace Common.Forms
|
||||
{
|
||||
partial class ModelessForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(47, 29);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(35, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "label1";
|
||||
//
|
||||
// ModelessForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(191, 56);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Name = "ModelessForm";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ModelessForm";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
79
Common/Forms/ModelessForm.cs
Normal file
79
Common/Forms/ModelessForm.cs
Normal file
@ -0,0 +1,79 @@
|
||||
///
|
||||
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Common.Forms
|
||||
{
|
||||
public partial class ModelessForm : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor to be used by the application
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="message">Displayed message</param>
|
||||
public ModelessForm(string message, int backArgb = 0, int textArgb = 0, Font textFont = null, string title = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
ControlBox = false;
|
||||
|
||||
label1.Text = (message != null) ? message : "Please wait";
|
||||
BackColor = (backArgb != 0) ? Color.FromArgb(backArgb) : Color.LightGreen;
|
||||
ForeColor = (textArgb != 0) ? Color.FromArgb(textArgb) : Color.Black;
|
||||
label1.Font = (textFont != null) ? textFont : new Font("Arial", 14, FontStyle.Regular);
|
||||
Text = (title != null) ? title : string.Empty;
|
||||
|
||||
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
|
||||
float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
|
||||
Width = (int)textWidth + 120; /// Form width calculated from the text width
|
||||
Height += (int)textHeight; /// Form height calculated from the text height
|
||||
|
||||
UpdateMessageHandler += delegate(object sender, MessageEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<MessageEventArgs>(OnUpdateMessage), sender, args); }
|
||||
else OnUpdateMessage(sender, args);
|
||||
};
|
||||
|
||||
CloseFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }
|
||||
else OnCloseForm(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called from the state machine when an operation forces a modeless dialog close.
|
||||
/// </summary>
|
||||
public void UpdateMessage(MessageEventArgs args)
|
||||
{
|
||||
if (UpdateMessageHandler == null) return;
|
||||
try { UpdateMessageHandler(null, args); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
|
||||
void OnUpdateMessage(object sender, MessageEventArgs args)
|
||||
{
|
||||
if (args != null && args.Message != null) label1.Text = args.Message;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called from the state machine when an operation forces a modeless dialog close.
|
||||
/// </summary>
|
||||
public void CloseForm()
|
||||
{
|
||||
if (CloseFormHandler == null) return;
|
||||
try { CloseFormHandler(null, null); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
public event EventHandler<EventArgs> CloseFormHandler;
|
||||
void OnCloseForm(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
352
Common/Formulas.cs
Normal file
352
Common/Formulas.cs
Normal file
@ -0,0 +1,352 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public static class Formulas
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Formulas));
|
||||
|
||||
|
||||
///
|
||||
/// Wrappers
|
||||
///
|
||||
public static double RealDensity() { return GlobalData.SampleDensity; }
|
||||
public static double AtTemperature() { return GlobalData.SampleTemp; }
|
||||
public static double Buoyancy() { return GlobalData.Buoyancy; }
|
||||
|
||||
|
||||
/// Private tables with coeficients to calculate specific enthalpy
|
||||
static readonly int[] Ii;
|
||||
static readonly int[] Ji;
|
||||
static readonly double[] ni;
|
||||
|
||||
/// Private table with coeficients to calculate temperature of a platinum thermometer
|
||||
static readonly double[] Di;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
static Formulas()
|
||||
{
|
||||
///
|
||||
/// Initialize tables to calculate specific enthalpies
|
||||
///
|
||||
Ii = new int[34] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 };
|
||||
Ji = new int[34] { -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 };
|
||||
ni = new double[34] {
|
||||
0.14632971213167, /// 1
|
||||
-0.84548187169114, /// 2
|
||||
-0.37563603672040E1, /// 3
|
||||
0.33855169168385E1, /// 4
|
||||
-0.95791963387872, /// 5
|
||||
0.15772038513228, /// 6
|
||||
-0.16616417199501E-1, /// 7
|
||||
0.81214629983568E-3, /// 8
|
||||
0.28319080123804E-3, /// 9
|
||||
-0.60706301565874E-3, /// 10
|
||||
-0.18990068218419E-1, /// 11
|
||||
-0.32529748770505E-1, /// 12
|
||||
-0.21841717175414E-1, /// 13
|
||||
-0.52838357969930E-4, /// 14
|
||||
-0.47184321073267E-3, /// 15
|
||||
-0.30001780793026E-3, /// 16
|
||||
0.47661393906987E-4, /// 17
|
||||
-0.44141845330846E-5, /// 18
|
||||
-0.72694996297594E-15, /// 19
|
||||
-0.31679644845054E-4, /// 20
|
||||
-0.28270797985312E-5, /// 21
|
||||
-0.85205128120103E-9, /// 22
|
||||
-0.22425281908000E-5, /// 23
|
||||
-0.65171222895601E-6, /// 24
|
||||
-0.14341729937924E-12, /// 25
|
||||
-0.40516996860117E-6, /// 26
|
||||
-0.12734301741641E-8, /// 27
|
||||
-0.17424871230634E-9, /// 28
|
||||
-0.68762131295531E-18, /// 29
|
||||
0.14478307828521E-19, /// 30
|
||||
0.26335781662795E-22, /// 31
|
||||
-0.11947622640071E-22, /// 32
|
||||
0.18228094581404E-23, /// 33
|
||||
-0.93537087292458E-25, /// 34
|
||||
};
|
||||
|
||||
///
|
||||
/// Initialize a table to calculate temperature of a platinum thermometer from resistance
|
||||
///
|
||||
Di = new double[]
|
||||
{
|
||||
439.932854,
|
||||
472.418020,
|
||||
37.684494,
|
||||
7.472018,
|
||||
2.920828,
|
||||
0.005184,
|
||||
-0.963864,
|
||||
-0.188732,
|
||||
0.191203,
|
||||
0.049025,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate density of distilled water from temperature
|
||||
/// </summary>
|
||||
/// <param name="t">ITS-90 temperature in [°C]</param>
|
||||
/// <returns>Density in [kg/m3]</returns>
|
||||
public static double DistilledWaterDensityFromTemp(double t)
|
||||
{
|
||||
if (t <= 40)
|
||||
{
|
||||
const double c0 = 999.839564;
|
||||
const double c1 = 0.067998613;
|
||||
const double c2 = -0.0091101468;
|
||||
const double c3 = 0.00010058299;
|
||||
const double c4 = -0.0000011275659;
|
||||
const double c5 = 6.5985371e-09;
|
||||
|
||||
return ((((c5 * t + c4) * t + c3) * t + c2) * t + c1) * t + c0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double a0 = 9.9983952E2;
|
||||
const double a1 = 1.6952577E1;
|
||||
const double a2 = -7.9905127E-3;
|
||||
const double a3 = -4.6241757E-5;
|
||||
const double a4 = 1.0584601E-7;
|
||||
const double a5 = -2.8103006E-10;
|
||||
const double b = 1.6887236E-2;
|
||||
|
||||
return (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0) / (1.0 + b * t);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate density of distilled water from temperature (obsolete)
|
||||
/// </summary>
|
||||
/// <param name="t">IPTS-68 temperature in [°C]</param>
|
||||
/// <returns>Density in [kg/m3]</returns>
|
||||
public static double DistilledWaterDensityFromTempIPTS68(double t)
|
||||
{
|
||||
const double a0 = 999.842594;
|
||||
const double a1 = 0.06793952;
|
||||
const double a2 = -0.009095290;
|
||||
const double a3 = 0.0001001685;
|
||||
const double a4 = -0.000001120083;
|
||||
const double a5 = 6.536332e-09;
|
||||
|
||||
return ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t + a0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate density by comparing calculated data and data from a certificate
|
||||
/// </summary>
|
||||
/// <param name="realDensity">Density from a certificate in [kg/m3]</param>
|
||||
/// <param name="atTemperature">Temperature from a certificate in [°C]</param>
|
||||
/// <returns>Density correction in [kg/m3]</returns>
|
||||
public static double DensityCorrection(double realDensity, double atTemperature)
|
||||
{
|
||||
/// Calculated data
|
||||
double calculatedDensity = DistilledWaterDensityFromTemp(atTemperature);
|
||||
|
||||
return realDensity - calculatedDensity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate corrected (real) water density from temperature
|
||||
/// </summary>
|
||||
/// <param name="t">Temperature in [°C]</param>
|
||||
/// <returns>Density in [kg/m3]</returns>
|
||||
public static double WaterDensityFromTemp(double t)
|
||||
{
|
||||
return DistilledWaterDensityFromTemp(t) + DensityCorrection(RealDensity(), AtTemperature());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate corrected (real) water density from temperature
|
||||
/// </summary>
|
||||
/// <param name="t">Temperature in [°C]</param>
|
||||
/// <returns>Density in [kg/m3]</returns>
|
||||
public static double WaterDensityFromTempPress(double temp, double pressure)
|
||||
{
|
||||
double x0 = 5.08821E-10;
|
||||
double x1 = 1.2639418;
|
||||
double x2 = 0.2660269;
|
||||
double x3 = 0.3734838;
|
||||
double x4 = 2.0205242;
|
||||
double theta = temp / 100.0;
|
||||
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
|
||||
|
||||
return WaterDensityFromTemp(temp) * (1 + B * Common.Units.ConvertTo(Common.Unit.Pa, pressure));
|
||||
}
|
||||
|
||||
|
||||
public static float AirDensityFromAmbientVales(float tempC, float pressureBar, float humiPct)
|
||||
{
|
||||
double pressurePa = 100000.0 * (double)pressureBar; /// [Pa]
|
||||
double tempKelvin = 273.15 + (double)tempC;
|
||||
double coef1 = 1.2811805 / 10000.0 * tempKelvin * tempKelvin
|
||||
- 1.950987 / 100.0 * tempKelvin
|
||||
+ 34.04926034
|
||||
- 6.353631 * 1000.0 / tempKelvin;
|
||||
double coef3 = humiPct / 100.0 * System.Math.Exp(coef1) / pressurePa;
|
||||
double airDensityKgm3 = 0.00348353 * pressurePa * (1.0 - 0.378 * coef3) / tempKelvin; /// kg/m3
|
||||
return (float)airDensityKgm3;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert 'pulses' to 'volume', prevent division by zero
|
||||
/// </summary>
|
||||
public static double VolumeFromPulses(int pulses, double pulsesPerLiter)
|
||||
{
|
||||
if (pulsesPerLiter <= double.Epsilon) return 0;
|
||||
return Convert.ToDouble(pulses) / pulsesPerLiter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the error in % from 'measured' and 'true' volume, prevent division by zero
|
||||
/// </summary>
|
||||
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
|
||||
{
|
||||
if (trueVolume <= float.Epsilon)
|
||||
{
|
||||
if (measuredVolume <= float.Epsilon)
|
||||
{
|
||||
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
|
||||
return -100.0;
|
||||
}
|
||||
|
||||
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, 99.0);
|
||||
return 99.0;
|
||||
}
|
||||
|
||||
double error = 100.0 * (measuredVolume - trueVolume) / trueVolume;
|
||||
log.InfoFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Converts a measurement error to a correction (used when preparing correction tables).
|
||||
/// </summary>
|
||||
/// <param name="measuredValue">Measured value (in arbitrary units)</param>
|
||||
/// <param name="error">Measurement error in %</param>
|
||||
/// <returns>Correction in the same units as the measured value</returns>
|
||||
public static double CorrectionFromError(double measuredValue, double error)
|
||||
{
|
||||
double trueValue = measuredValue / (1 + error/100);
|
||||
double correction = trueValue - measuredValue;
|
||||
return correction;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the heat coefficient for water
|
||||
/// </summary>
|
||||
/// <param name="pressure">Pressure [bar]</param>
|
||||
/// <param name="T_in">Inlet temperature [°C]</param>
|
||||
/// <param name="T_out">Outlet temperature [°C]</param>
|
||||
/// <param name="flowMeasuredAtInlet">true = flow measured @inlet, false = flow measured @outlet</param>
|
||||
/// <returns> Heat coefficient for water [J/(m3 K)]</returns>
|
||||
public static double HeatCoefficientWater(double pressure, double T_in, double T_out, bool flowMeasuredAtInlet)
|
||||
{
|
||||
if (T_in == T_out) return 0;
|
||||
|
||||
const double R = 461.526; /// [J kg^-1 K^-1]
|
||||
const double p_star_Pa = 16.53E6; /// [Pa] (=16.53 MPa)
|
||||
const double T_star = 1386.0; /// [K]
|
||||
|
||||
double T_in_K = Common.Units.ConvertTo(Common.Unit.K, T_in);
|
||||
double T_out_K = Common.Units.ConvertTo(Common.Unit.K, T_out);
|
||||
double tau_in = T_star / T_in_K;
|
||||
double tau_out = T_star / T_out_K;
|
||||
double pi = Common.Units.ConvertTo(Common.Unit.Pa, pressure) / p_star_Pa;
|
||||
|
||||
double h_in = tau_in * GammaTau(pi, tau_in) * R * T_in_K;
|
||||
double h_out = tau_out * GammaTau(pi, tau_out) * R * T_out_K;
|
||||
|
||||
double ni = flowMeasuredAtInlet ? GammaPi(pi, tau_in) * R * T_in_K / p_star_Pa
|
||||
: GammaPi(pi, tau_out) * R * T_out_K / p_star_Pa;
|
||||
|
||||
return (h_in - h_out) / (ni * (T_in - T_out));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gamma(pi) see also STN EN 1434-1 Annex A (A.4)
|
||||
/// </summary>
|
||||
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
|
||||
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
|
||||
/// <returns>gamma(pi)</returns>
|
||||
static double GammaPi(double pi, double tau)
|
||||
{
|
||||
double result = 0;
|
||||
for (int i = 0; i < 34; i++)
|
||||
{
|
||||
result -= ni[i] * Ii[i] * Math.Pow(7.1 - pi, Ii[i] - 1) * Math.Pow(tau - 1.222, Ji[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gamma(tau) see also STN EN 1434-1 Annex A (A.7)
|
||||
/// </summary>
|
||||
/// <param name="pi">pi = p / p* where p* = 16.53 MPa</param>
|
||||
/// <param name="tau">tau = T* / T where T* = 1386 K</param>
|
||||
/// <returns>gamma(tau)</returns>
|
||||
static double GammaTau(double pi, double tau)
|
||||
{
|
||||
double result = 0;
|
||||
for (int i = 0; i < 34; i++)
|
||||
{
|
||||
result += ni[i] * Math.Pow(7.1 - pi, Ii[i]) * Ji[i] * Math.Pow(tau - 1.222, Ji[i] - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of measured resistance of a platinum thermometer to temperature according to ITS-90
|
||||
/// </summary>
|
||||
/// <param name="R">Measured resistance in [°C]</param>
|
||||
/// <param name="R001C">Calibrated resistance in Ohm at 0.01°C</param>
|
||||
/// <param name="a7">Calibrated ITS-90 coefficient a7</param>
|
||||
/// <param name="b7">Calibrated ITS-90 coefficient b7</param>
|
||||
/// <param name="c7">Calibrated ITS-90 coefficient c7</param>
|
||||
/// <returns>Temperature in [°C]</returns>
|
||||
public static double PlatinumResistanceTM_ITS90_R2T(double R, double R001C, double a7, double b7, double c7)
|
||||
{
|
||||
double w = R / R001C; /// ratio
|
||||
double r1 = w - 1.0;
|
||||
double dw = r1 * (a7 + r1 * (b7 + r1 * c7)); /// = a7*r1 + b7*r1^2 + c7*r1^3
|
||||
double wr = w - dw;
|
||||
double x = (wr - 2.64) / 1.64;
|
||||
|
||||
double sum = 0;
|
||||
for (int i = Di.Length - 1; i >= 0; i--)
|
||||
{
|
||||
sum = sum * x + Di[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of measured resistance of a platinum thermometer to temperature using Callendar-Van Dusen equations
|
||||
/// </summary>
|
||||
/// <param name="R">Measured resistance in [°C]</param>
|
||||
/// <param name="R0">Calibrated resistance in Ohm at 0°C</param>
|
||||
/// <param name="A">Calibration coefficient a</param>
|
||||
/// <param name="B">Calibration coefficient b</param>
|
||||
/// <returns>Temperature in [°C]</returns>
|
||||
public static double PlatinumResistanceTM_ITS27_R2T(double R, double R0, double A, double B)
|
||||
{
|
||||
if (R0 * R0 * A * A - 4 * R0 * B * (R0 - R) <= 0) return 0; /// Out of range
|
||||
|
||||
return (-(R0 * A) + Math.Sqrt(R0 * R0 * A * A - 4 * R0 * B * (R0 - R))) / (2 * R0 * B);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Common/IMeasurementCorrection.cs
Normal file
11
Common/IMeasurementCorrection.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public interface IMeasurementCorrection
|
||||
{
|
||||
int RangeIx { get; set; }
|
||||
double Measurement { get; set; }
|
||||
double Correction { get; set; }
|
||||
}
|
||||
}
|
||||
26
Common/IOrderInfo.cs
Normal file
26
Common/IOrderInfo.cs
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public interface IOrderInfo
|
||||
{
|
||||
string POName { get; }
|
||||
string VariantCode { get; }
|
||||
string ModuleParam { get; }
|
||||
int PiecesCount { get; }
|
||||
string SNPrefix { get; }
|
||||
int SNFirst { get; }
|
||||
int SNDigitsCount { get; }
|
||||
string SNSuffix { get; }
|
||||
string RAPrefix { get; }
|
||||
int RAFirst { get; }
|
||||
string RASuffix { get; }
|
||||
string Remark { get; }
|
||||
int CurrentPcsCount { get; set; }
|
||||
int CurrentSN { get; set; }
|
||||
int CurrentRA { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Config.Entities
|
||||
namespace Common
|
||||
{
|
||||
public interface IParamsProvider
|
||||
{
|
||||
@ -31,7 +31,7 @@ namespace Config.Entities
|
||||
/// Returns a list of possible values of one parameter (ComboBox when editing) or null (Textbox when editing).
|
||||
/// </summary>
|
||||
/// <param name="ix">Zero based index of the parameter</param>
|
||||
IList<string> ParamValues(int ix);
|
||||
ICollection<string> ParamValues(int ix);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a parameter value in the string form
|
||||
14
Common/IUncertainty.cs
Normal file
14
Common/IUncertainty.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public interface IUncertainty
|
||||
{
|
||||
float Measurement { get; }
|
||||
float MainUncertainty { get; }
|
||||
float Resolution { get; }
|
||||
float DriftPerYr { get; }
|
||||
float Conditions { get; }
|
||||
float UncertaintyOfCorrection { get; }
|
||||
}
|
||||
}
|
||||
22
Common/IUser.cs
Normal file
22
Common/IUser.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public interface IUser
|
||||
{
|
||||
string UserName { get; } /// = name, alias, abbreviation
|
||||
string FullName { get; } /// = description
|
||||
string Tag { get; }
|
||||
int Number { get; }
|
||||
|
||||
/// Access rights
|
||||
bool IsMemberOf(GID group);
|
||||
bool IsMemberOf(GID[] groups);
|
||||
bool IsCorrectPassword(string password);
|
||||
|
||||
/// Password complexity, history, etc.
|
||||
bool IsPasswordExpired();
|
||||
bool IsPasswordUsedInPast(string passwordCandidate);
|
||||
void SetPassword(string password);
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,21 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2021 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
namespace Common.Iperl
|
||||
{
|
||||
public class OptoTelegramRaw
|
||||
public enum OptoTelegramFlags : byte
|
||||
{
|
||||
OK = 0,
|
||||
OK_TestStart,
|
||||
OK_TestEnd,
|
||||
InvalidTelegram, /// Wrong telegram format of checksum error
|
||||
SyncError,
|
||||
}
|
||||
|
||||
public class OptoTelegramRaw
|
||||
{
|
||||
public static readonly int Length = 42;
|
||||
private static CultureInfo culture;
|
||||
@ -26,7 +35,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
public float RefFlow; /// [m3/h]
|
||||
public int Counter;
|
||||
|
||||
public UInt32 EmfRaw; /// From iPerl opto data
|
||||
public Int32 EmfRaw; /// Signed EMF from iPerl opto data
|
||||
public Int16 MagneticFieldRaw;
|
||||
public Int16 FlowRaw;
|
||||
public UInt32 VolumeRaw;
|
||||
@ -41,8 +50,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
///
|
||||
public double EMF()
|
||||
{
|
||||
Int32 signedEmf = (EmfRaw > 0x7FFFFF) ? ((int)EmfRaw - 0x1000000) : (int)EmfRaw;
|
||||
return 0.000000333 * (double)signedEmf;
|
||||
return 0.000000333 * (double)EmfRaw;
|
||||
}
|
||||
public double MagneticField() { return (double)MagneticFieldRaw; }
|
||||
public double Flow(double scalingFactor) { return 0.225 * scalingFactor * (double)FlowRaw; }
|
||||
@ -96,22 +104,25 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// </description>
|
||||
/// <param name="data">A complete byte array data</param>
|
||||
/// <returns>true = telegram OK, false = telegram NOK</returns>
|
||||
public bool UpdateFromString(string telegram, int counter, ref Int64 volumeRawExtLast, ref Int64 timestampExtLast)
|
||||
public bool UpdateFromString(string telegram, int counter, float refFlow, ref Int64 volumeRawExtLast, ref Int64 timestampExtLast, bool isLog = false)
|
||||
{
|
||||
DateTime = DateTime.Now;
|
||||
Counter = counter;
|
||||
RefFlow = (float)Sequences.ProcessData.RefFlow.Val;
|
||||
RefFlow = refFlow;
|
||||
|
||||
if ((telegram == null) || (telegram.Length < Length) ||
|
||||
(telegram[6] != '\t') || (telegram[11] != '\t') || (telegram[16] != '\t') ||
|
||||
(telegram[23] != '\t') || (telegram[28] != '\t') || (telegram[37] != '\t') ||
|
||||
(telegram[40] != '\r') || (telegram[41] != '\n'))
|
||||
(!isLog && (telegram[40] != '\r' || telegram[41] != '\n')))
|
||||
{
|
||||
Flags = OptoTelegramFlags.InvalidTelegram;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool f1 = UInt32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out EmfRaw);
|
||||
UInt32 uEmfRaw;
|
||||
bool f1 = UInt32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out uEmfRaw);
|
||||
EmfRaw = (uEmfRaw > 0x7FFFFF) ? ((int)uEmfRaw - 0x1000000) : (int)uEmfRaw;
|
||||
|
||||
bool f2 = Int16.TryParse(telegram.Substring(7, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out MagneticFieldRaw);
|
||||
bool f3 = Int16.TryParse(telegram.Substring(12, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out FlowRaw);
|
||||
bool f4 = UInt32.TryParse(telegram.Substring(17, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out VolumeRaw);
|
||||
@ -119,51 +130,61 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
bool f6 = UInt32.TryParse(telegram.Substring(29, 8), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Timestamp);
|
||||
bool f7 = byte.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out CheckSum);
|
||||
|
||||
bool allOk = f1 && f2 && f3 && f4 && f5 && f6 && f7;
|
||||
byte calculatedCheckSum = 0;
|
||||
for (int i = 0; i < Length - 4; i++)
|
||||
{
|
||||
calculatedCheckSum += (byte)telegram[i];
|
||||
}
|
||||
|
||||
bool allOk = f1 && f2 && f3 && f4 && f5 && f6 && f7 && (calculatedCheckSum == CheckSum);
|
||||
|
||||
if (allOk)
|
||||
{
|
||||
///
|
||||
/// Cope with 'VolumeRaw' overflow
|
||||
///
|
||||
Int64 uncorrected = (Int64)(((UInt64)volumeRawExtLast & 0xFFFFFFFFFF000000UL) | VolumeRaw);
|
||||
if (Math.Abs(uncorrected - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected;
|
||||
}
|
||||
else if (Math.Abs(uncorrected + 0x1000000L - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected + 0x1000000L;
|
||||
}
|
||||
else if (Math.Abs(uncorrected - 0x1000000L - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected - 0x1000000L;
|
||||
}
|
||||
else
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected;
|
||||
}
|
||||
|
||||
///
|
||||
/// Cope with 'Timestamp' overflow
|
||||
///
|
||||
uncorrected = (Int64)(((UInt64)timestampExtLast & 0xFFFFFFFF00000000UL) | Timestamp);
|
||||
if (Math.Abs(uncorrected - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected;
|
||||
}
|
||||
else if (Math.Abs(uncorrected + 0x100000000L - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected + 0x100000000L;
|
||||
}
|
||||
else if (Math.Abs(uncorrected - 0x100000000L - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected - 0x100000000L;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected;
|
||||
}
|
||||
}
|
||||
|
||||
Flags = allOk ? OptoTelegramFlags.OK : OptoTelegramFlags.InvalidTelegram;
|
||||
|
||||
///
|
||||
/// Cope with 'VolumeRaw' overflow
|
||||
///
|
||||
Int64 uncorrected = (Int64)(((UInt64)volumeRawExtLast & 0xFFFFFFFFFF000000UL) | VolumeRaw);
|
||||
if (Math.Abs(uncorrected - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected;
|
||||
}
|
||||
else if (Math.Abs(uncorrected + 0x1000000L - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected + 0x1000000L;
|
||||
}
|
||||
else if (Math.Abs(uncorrected - 0x1000000L - volumeRawExtLast) <= 0x800000L)
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected - 0x1000000L;
|
||||
}
|
||||
else
|
||||
{
|
||||
VolumeRawExt = volumeRawExtLast = uncorrected;
|
||||
}
|
||||
|
||||
///
|
||||
/// Cope with 'Timestamp' overflow
|
||||
///
|
||||
uncorrected = (Int64)(((UInt64)timestampExtLast & 0xFFFFFFFF00000000UL) | Timestamp);
|
||||
if (Math.Abs(uncorrected - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected;
|
||||
}
|
||||
else if (Math.Abs(uncorrected + 0x100000000L - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected + 0x100000000L;
|
||||
}
|
||||
else if (Math.Abs(uncorrected - 0x100000000L - timestampExtLast) <= 0x80000000L)
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected - 0x100000000L;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimestampExt = timestampExtLast = uncorrected;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
@ -173,7 +194,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
public bool UpdateFromStringDummy(string telegram)
|
||||
{
|
||||
DateTime = DateTime.Now;
|
||||
RefFlow = (float)Sequences.ProcessData.RefFlow.Val;
|
||||
RefFlow = 0;
|
||||
|
||||
if ((telegram == null) || (telegram.Length < Length) ||
|
||||
(telegram[6] != '\t') || (telegram[11] != '\t') || (telegram[16] != '\t') ||
|
||||
@ -184,16 +205,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
return false;
|
||||
}
|
||||
|
||||
//bool f1 = UInt32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out EmfRaw);
|
||||
//bool f2 = Int16.TryParse(telegram.Substring(7, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out MagneticFieldRaw);
|
||||
//bool f3 = Int16.TryParse(telegram.Substring(12, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out FlowRaw);
|
||||
//bool f4 = UInt32.TryParse(telegram.Substring(17, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out VolumeRaw);
|
||||
//bool f5 = Int16.TryParse(telegram.Substring(24, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Impedance);
|
||||
//bool f6 = UInt32.TryParse(telegram.Substring(29, 8), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Timestamp);
|
||||
//bool f7 = byte.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out CheckSum);
|
||||
//return f1 && f2 && f3 && f4 && f5 && f6 && f7;
|
||||
bool f7 = byte.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out CheckSum);
|
||||
|
||||
return true;
|
||||
byte calculatedCheckSum = 0;
|
||||
for (int i = 0; i < Length - 4; i++)
|
||||
{
|
||||
calculatedCheckSum += (byte)telegram[i];
|
||||
}
|
||||
|
||||
bool allOk = f7 && (calculatedCheckSum == CheckSum);
|
||||
|
||||
Flags = allOk ? OptoTelegramFlags.OK : OptoTelegramFlags.InvalidTelegram;
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
|
||||
@ -221,7 +245,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
DateTime.Second.ToString("D2"),
|
||||
DateTime.Millisecond.ToString("D4"),
|
||||
Counter,
|
||||
EmfRaw.ToString("X6"),
|
||||
(EmfRaw & 0x00FFFFFF).ToString("X6"),
|
||||
MagneticFieldRaw.ToString("X4"),
|
||||
FlowRaw.ToString("X4"),
|
||||
VolumeRaw.ToString("X6"),
|
||||
@ -241,80 +265,5 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
Label());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter RefFlow data in an array of OptoTelegramRaw objects by a FIR filter:
|
||||
///
|
||||
/// kSize = 5, kSize2 = 2
|
||||
///
|
||||
/// i k
|
||||
/// ---------------------------------------------------------------------------
|
||||
/// 0 -5 filtered[0] = data[0]
|
||||
/// 1 -4 filtered[1] = data[1]
|
||||
/// 2 -3 filtered[2] = data[0]*k[0] + ... + data[4]*k[4]
|
||||
/// 3 -2 filtered[3] = data[1]*k[0] + ... + data[5]*k[4]
|
||||
/// 4 -1 filtered[4] = data[2]*k[0] + ... + data[6]*k[4]
|
||||
/// 5 0 data[0] = filtered[0], filtered[0] = data[3]*k[0] + ... + data[7]*k[4]
|
||||
/// 6 1 data[1] = filtered[1], filtered[1] = data[4]*k[0] + ... + data[8]*k[4]
|
||||
/// 7 ...
|
||||
/// </summary>
|
||||
/// <param name="optoData">array of OptoTelegramRaw objects</param>
|
||||
/// <param name="from">Index of the first optoData item to process</param>
|
||||
/// <param name="to">Index of the last optoData item to process</param>
|
||||
public static void FIRFilterFlow(OptoTelegramRaw[] optoData, int from, int to)
|
||||
{
|
||||
float[] kernel = new float[] { 0.1f, 0.2f, 0.4f, 0.2f, 0.1f };
|
||||
int kSize = kernel.Length;
|
||||
int kSize2 = kernel.Length / 2;
|
||||
|
||||
float[] filtered = new float[kSize];
|
||||
|
||||
for (int i = from; i <= to; i++)
|
||||
{
|
||||
if ((i < from + kSize2) || (i > to - kSize2))
|
||||
{
|
||||
/// Beginning or end of optoData buffer => Just copy data (=do not filter)
|
||||
filtered[i % kSize] = optoData[BufferIdx(i)].RefFlow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Make a convolution of optoData and the kernel
|
||||
float weightedSum = 0;
|
||||
for (int j = -kSize2; j <= kSize2; j++)
|
||||
weightedSum += optoData[BufferIdx(i + j)].RefFlow * kernel[j + kSize2];
|
||||
|
||||
filtered[i % kSize] = weightedSum;
|
||||
}
|
||||
|
||||
if (i >= from + kSize)
|
||||
{
|
||||
/// filtered[] buffer full => copy filtered data to optoData
|
||||
optoData[BufferIdx(i - kSize)].RefFlow = filtered[i % kSize];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = to - kSize + 1; i <= to; i++)
|
||||
{
|
||||
if (i >= 0) optoData[BufferIdx(i)].RefFlow = filtered[i % kSize];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get index to optoData buffer
|
||||
/// </summary>
|
||||
/// <param name="index">Original unwrapped index</param>
|
||||
/// <returns>Index to the buffer</returns>
|
||||
public static int BufferIdx(int index)
|
||||
{
|
||||
if (index < IperlHead.MaxOptoDataCount)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IperlHead.StartOptoDataCount + (index - IperlHead.MaxOptoDataCount) % IperlHead.EndOptoDataCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,9 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Results.Output.Printers
|
||||
namespace Common.Printers
|
||||
{
|
||||
public class PrintersCommon : PrintDocument
|
||||
{
|
||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020-2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace TracingDB
|
||||
namespace Common
|
||||
{
|
||||
public class QuitAppException : Exception
|
||||
{
|
||||
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
|
||||
338
Common/StatisticalMetrics.cs
Normal file
338
Common/StatisticalMetrics.cs
Normal file
@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Common.Iperl;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static float[] SubArray(this float[] array, int offset, int length)
|
||||
{
|
||||
float[] result = new float[length];
|
||||
Array.Copy(array, offset, result, 0, length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class StatisticalMetrics
|
||||
{
|
||||
const int VectorSize = 7;
|
||||
const int MinLength = 100;
|
||||
const float AdcBit = (float)57e-9;
|
||||
const int NeighbourhoodSize = 30; /// To determine extended outliers
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a 7-dimensional vector with these components:
|
||||
/// x[0] = X1 = Number of outliers
|
||||
/// x[1] = X2 = Relative cal-factor shift due to outliers
|
||||
/// x[2] = X3 = Standard deviation of high-pass filteres ++++ demodulation of EMF (cut-off at Nyquist frequency)
|
||||
/// x[3] = X4 = Robust standard deviation of high-pass filtered ++++ demodulation
|
||||
/// x[4] = X5 = Peak-to-peak of low-pass filtered ++++ demodulation of EMF (cut-off TBD)
|
||||
/// x[5] = X6 = Peak-to-peak of reference flow rate
|
||||
/// x[6] = X7 = Mean impedance (++-- demodulation)
|
||||
/// </summary>
|
||||
/// <param name="optoData"></param>
|
||||
/// <param name="optoDataCount"></param>
|
||||
/// <param name="startIx"></param>
|
||||
/// <param name="endIx"></param>
|
||||
/// <returns></returns>
|
||||
public static float[] Calculate(OptoTelegramRaw[] optoData, int optoDataCount, int startIx, int endIx, bool downsample,
|
||||
out float[] offsetV, out float[] kOhmsR, out float[] kOhmsC, out float[] dutFlow,
|
||||
out float[] refFlow, out float[] flowRatio, out float[] magField, out float[] emfV,
|
||||
out PointF[] outliers, out PointF[] extendedOutliers)
|
||||
{
|
||||
offsetV = kOhmsR = kOhmsC = dutFlow = refFlow = flowRatio = magField = emfV = null;
|
||||
outliers = extendedOutliers = null;
|
||||
|
||||
if (optoData == null || optoData.Length < optoDataCount ||
|
||||
startIx < 0 || endIx >= optoDataCount || endIx <= startIx + MinLength + 3) return null;
|
||||
|
||||
float[] modulatedData = GetModulatedEmf(optoData, optoDataCount, AdcBit);
|
||||
|
||||
FindShiftAndDemodulate(modulatedData, downsample,
|
||||
new float[] { +1, +1, +1, +1 }, out offsetV,
|
||||
new float[] { +1, +1, -1, -1 }, out kOhmsR,
|
||||
new float[] { +1, -1, -1, +1 }, out kOhmsC,
|
||||
new float[] { +1, -1, +1, -1 }, out dutFlow);
|
||||
//offsetV = FirFilter(modulatedData, new float[] { 1, 3, 4, 4, 3, 1}, 0.0625F);
|
||||
|
||||
magField = GetMagField(optoData, optoDataCount, downsample, new float[] { 1, 1, 1, 1 });
|
||||
|
||||
refFlow = GetRefFlow(optoData, optoDataCount, downsample, new float[] { 1, 1, 1, 1 });
|
||||
|
||||
flowRatio = new float[Math.Min(dutFlow.Length, refFlow.Length)];
|
||||
for (int i = 0; i < flowRatio.Length; i++)
|
||||
{
|
||||
flowRatio[i] = (refFlow[i] != 0) ? dutFlow[i] / refFlow[i] : 1;
|
||||
}
|
||||
|
||||
|
||||
float[] x = new float[VectorSize];
|
||||
|
||||
/// X1 = Number of outliers
|
||||
int outliersCount = GetOutliers(flowRatio, out outliers, out extendedOutliers);
|
||||
|
||||
|
||||
/// X2 = Relative cal-factor shift due to outliers
|
||||
|
||||
/// X3 = Standard deviation of high-pass filteres ++++ demodulation of EMF (cut-off at Nyquist frequency)
|
||||
|
||||
/// X4 = Robust standard deviation of high-pass filtered ++++ demodulation
|
||||
|
||||
/// X5 = Peak-to-peak of low-pass filtered ++++ demodulation of EMF (cut-off TBD)
|
||||
|
||||
/// X6 = Peak-to-peak of reference flow rate
|
||||
|
||||
/// X7 = Mean impedance (++-- demodulation)
|
||||
double sum = 0;
|
||||
foreach (var z in kOhmsR) sum += z;
|
||||
x[6] = Convert.ToSingle(sum / kOhmsR.Length);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
static float[] GetModulatedEmf(OptoTelegramRaw[] optoData, int optoDataCount, float factor)
|
||||
{
|
||||
if (optoData == null || optoDataCount < 0) return null;
|
||||
|
||||
float[] result = new float[optoDataCount];
|
||||
for (int i = 0; i < optoDataCount; i++)
|
||||
{
|
||||
result[i] = optoData[i].EmfRaw * factor;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static float[] GetMagField(OptoTelegramRaw[] optoData, int optoDataCount, bool downsample, float[] kernel)
|
||||
{
|
||||
if (optoData == null || optoDataCount < 0 || (downsample && (kernel == null || kernel.Length < 4))) return null;
|
||||
|
||||
int resultLen = downsample ? (optoDataCount / 4) : optoDataCount;
|
||||
float[] result = new float[resultLen];
|
||||
|
||||
if (downsample)
|
||||
{
|
||||
float ksum = 0;
|
||||
for (int j = 0; j < kernel.Length; j++) ksum += kernel[j];
|
||||
for (int j = 0; j < kernel.Length; j++) kernel[j] /= ksum;
|
||||
|
||||
for (int i = 0; (4 * i) + kernel.Length - 1 < optoDataCount; i++)
|
||||
{
|
||||
float sum = 0;
|
||||
for (int j = 0; j < kernel.Length; j++) sum += Convert.ToSingle(optoData[4 * i + j].MagneticFieldRaw) * kernel[j];
|
||||
result[i] = sum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < optoDataCount; i++) result[i] = optoData[i].MagneticFieldRaw;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static float[] GetRefFlow(OptoTelegramRaw[] optoData, int optoDataCount, bool downsample, float[] kernel)
|
||||
{
|
||||
if (optoData == null || optoDataCount < 0 || (downsample && (kernel == null || kernel.Length < 4))) return null;
|
||||
|
||||
int resultLen = downsample ? (optoDataCount / 4) : optoDataCount;
|
||||
float[] result = new float[resultLen];
|
||||
|
||||
if (downsample)
|
||||
{
|
||||
float ksum = 0;
|
||||
for (int j = 0; j < kernel.Length; j++) ksum += kernel[j];
|
||||
for (int j = 0; j < kernel.Length; j++) kernel[j] /= ksum;
|
||||
|
||||
for (int i = 0; (4 * i) + kernel.Length - 1 < optoDataCount; i++)
|
||||
{
|
||||
float sum = 0;
|
||||
for (int j = 0; j < kernel.Length; j++) sum += Convert.ToSingle(optoData[4 * i + j].RefFlow) * kernel[j];
|
||||
result[i] = sum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < optoDataCount; i++) result[i] = optoData[i].RefFlow;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void FindShiftAndDemodulate(float[] modulatedData, bool downsample,
|
||||
float[] kernel1, out float[] data1,
|
||||
float[] kernel2, out float[] data2,
|
||||
float[] kernel3, out float[] data3,
|
||||
float[] kernel4, out float[] data4)
|
||||
{
|
||||
int shift = GetShift(modulatedData.SubArray(0, MinLength));
|
||||
|
||||
data1 = (kernel1 != null) ? Demodulate(modulatedData, kernel1, shift, downsample) : null;
|
||||
data2 = (kernel2 != null) ? Demodulate(modulatedData, kernel2, shift, downsample) : null;
|
||||
data3 = (kernel3 != null) ? Demodulate(modulatedData, kernel3, shift, downsample) : null;
|
||||
data4 = (kernel4 != null) ? Demodulate(modulatedData, kernel4, shift, downsample) : null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unlike FIR filtering, demodulation shifts the kernel in 4 phases
|
||||
/// </summary>
|
||||
/// <param name="data">Input data</param>
|
||||
/// <param name="kernel">Demodulation kernel</param>
|
||||
/// <param name="shift">shift 0..3</param>
|
||||
/// <returns>Output data</returns>
|
||||
static float[] Demodulate(float[] data, float[] kernel, int shift, bool downsample)
|
||||
{
|
||||
if (data == null || data.Length < MinLength || kernel == null || kernel.Length != 4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
float ksum = 0;
|
||||
for (int i = 0; i < 4; i++) ksum += Math.Abs(kernel[i]);
|
||||
for (int i = 0; i < 4; i++) kernel[i] /= ksum;
|
||||
|
||||
int rsltLen = downsample ? (data.Length - 3) / 4 : data.Length - 3;
|
||||
float[] result = new float[rsltLen];
|
||||
|
||||
if (downsample)
|
||||
{
|
||||
for (int i = shift; i < 4 * rsltLen; i += 4)
|
||||
{
|
||||
float sum = 0;
|
||||
for (int j = 0; j < 4; j++) sum += data[i + j] * kernel[(i + j + 4 - shift) % 4];
|
||||
result[i / 4] = sum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < rsltLen; i++)
|
||||
{
|
||||
float sum = 0;
|
||||
for (int j = 0; j < 4; j++) sum += data[i + j] * kernel[(i + j + 4 - shift) % 4];
|
||||
result[i] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determine modulation phase by maximizing ++-- demodulation result.
|
||||
/// </summary>
|
||||
/// <param name="modulatedEmf">Input data</param>
|
||||
/// <returns>0..3 = modulation phase or, -1 = error</returns>
|
||||
static int GetShift(float[] modulatedData)
|
||||
{
|
||||
float[] kernel = new float[4] { 1, 1, -1, -1 };
|
||||
int maximizingShift = -1;
|
||||
float maximum = float.MinValue;
|
||||
|
||||
for (int shift = 0; shift <= 3; shift++)
|
||||
{
|
||||
var demodulatedCandidate = Demodulate(modulatedData, kernel, shift, false);
|
||||
float sum = 0;
|
||||
foreach (var d in demodulatedCandidate) sum += d;
|
||||
if (sum > maximum)
|
||||
{
|
||||
maximum = sum;
|
||||
maximizingShift = shift;
|
||||
}
|
||||
}
|
||||
|
||||
return maximizingShift;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FIR filtering = convolution with a kernel
|
||||
/// </summary>
|
||||
/// <param name="data">Input data</param>
|
||||
/// <param name="kernel">Convolution kernel</param>
|
||||
/// <returns>Output data</returns>
|
||||
static float[] FirFilter(float[] data, float[] kernel, float factor)
|
||||
{
|
||||
if (data == null || kernel == null) return null;
|
||||
|
||||
int kernelLen = kernel.Length;
|
||||
int rsltLen = data.Length - kernelLen + 1;
|
||||
if (rsltLen < 0) return null;
|
||||
|
||||
float[] result = new float[rsltLen];
|
||||
for (int i = 0; i < rsltLen; i++)
|
||||
{
|
||||
float sum = 0;
|
||||
for (int j = 0; j < kernelLen; j++) sum += data[i + j] * kernel[j];
|
||||
result[i] = sum * factor;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int GetOutliers(float[] flowRatio, out PointF[] outliers, out PointF[] extendedOutliers)
|
||||
{
|
||||
float mean = Enumerable.Average(flowRatio);
|
||||
var fr = new float[flowRatio.Length];
|
||||
for (int i = 0; i < fr.Length; i++) fr[i] = flowRatio[i] - mean;
|
||||
|
||||
Array.Sort(fr);
|
||||
float qLo = fr[fr.Length / 4];
|
||||
float qHi = fr[3 * fr.Length / 4];
|
||||
|
||||
int N = fr.Length / 2;
|
||||
float sumY = 0;
|
||||
float sumYY = 0;
|
||||
for (int i = fr.Length / 4; i < 3 * fr.Length / 4; i++)
|
||||
{
|
||||
sumY += fr[i];
|
||||
sumYY += fr[i] * fr[i];
|
||||
}
|
||||
float std = (float)Math.Sqrt(sumYY / N - (sumY / N) * (sumY / N));
|
||||
float robustStd = std * 5.1812824F;
|
||||
float threshold = 7 * robustStd;
|
||||
|
||||
/// Restore fr as it was before sorting
|
||||
for (int i = 0; i < fr.Length; i++) fr[i] = flowRatio[i] - mean;
|
||||
|
||||
IList<PointF> listOfOutliers = new List<PointF>();
|
||||
bool[] boolExtendedOutliers = new bool[fr.Length];
|
||||
int outliersCount = 0;
|
||||
for (int i = 0; i < fr.Length; i++)
|
||||
{
|
||||
if (fr[i] < -threshold || fr[i] > threshold)
|
||||
{
|
||||
/// This is an outlier
|
||||
listOfOutliers.Add(new PointF(Convert.ToSingle(i), fr[i] + mean));
|
||||
outliersCount++;
|
||||
for (int j = Math.Max(0, i - NeighbourhoodSize); j <= Math.Min(i + NeighbourhoodSize, fr.Length - 1); j++)
|
||||
{
|
||||
boolExtendedOutliers[j] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IList<PointF> listOfExtendedOutliers = new List<PointF>();
|
||||
for (int i = 0; i < fr.Length; i++)
|
||||
{
|
||||
if (boolExtendedOutliers[i])
|
||||
{
|
||||
listOfExtendedOutliers.Add(new PointF(Convert.ToSingle(i), fr[i] + mean));
|
||||
}
|
||||
}
|
||||
|
||||
outliers = listOfOutliers.ToArray<PointF>();
|
||||
extendedOutliers = listOfExtendedOutliers.ToArray<PointF>();
|
||||
|
||||
return outliersCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2019 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2021 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TBF.BenchControl
|
||||
namespace Common
|
||||
{
|
||||
public class Telegram
|
||||
public static class Telegram
|
||||
{
|
||||
const UInt16 crcSeed = 0xFFFF; // Initial crc value
|
||||
const UInt16 crcGP = 0xA001; // Generating polynomial
|
||||
@ -39,13 +39,29 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>Calculated CRC</returns>
|
||||
public static UInt16 ClaculateTelegramCRC(byte[] data)
|
||||
public static UInt16 CalculateTelegramCRC(byte[] data, int enforcedLen = 0)
|
||||
{
|
||||
int len = (enforcedLen != 0) ? Math.Min(enforcedLen, data.Length) : data.Length;
|
||||
UInt16 crc = crcSeed;
|
||||
for (int i = 0; i < data.Length - 2; i++) UpdateCRC(data[i], ref crc);
|
||||
for (int i = 0; i < len - 2; i++) UpdateCRC(data[i], ref crc);
|
||||
return crc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the CRC from a data telegram (an array of bytes).
|
||||
/// A complete telegram including two bytes reserved for the CRC
|
||||
/// must be supplied as an argument.
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>Calculated CRC</returns>
|
||||
public static UInt16 CalculateTelegramCRC(int offset, byte[] data, int enforcedLen = 0)
|
||||
{
|
||||
int len = (enforcedLen != 0) ? Math.Min(enforcedLen, data.Length - offset) : data.Length - offset;
|
||||
UInt16 crc = crcSeed;
|
||||
for (int i = 0; i < len - 2; i++) UpdateCRC(data[offset + i], ref crc);
|
||||
return crc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function modifies the last 2 bytes in the message buffer
|
||||
/// by the CRC calculated from the remaining first (Lenght - 2) bytes.
|
||||
@ -58,7 +74,7 @@ namespace TBF.BenchControl
|
||||
int len = data.Length;
|
||||
if (len < 2) return;
|
||||
|
||||
UInt16 crc = ClaculateTelegramCRC(data);
|
||||
UInt16 crc = CalculateTelegramCRC(data);
|
||||
|
||||
data[len - 2] = (byte)(crc & 0xFF);
|
||||
data[len - 1] = (byte)(crc >> 8);
|
||||
@ -72,16 +88,38 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>true if the CRC in the telegram is correct</returns>
|
||||
public static bool VerifyTelegramCRC(byte[] data)
|
||||
public static bool VerifyTelegramCRC(byte[] data, int enforcedLen = 0)
|
||||
{
|
||||
int len = data.Length;
|
||||
if (data == null || data.Length == 0 || enforcedLen > data.Length) return false;
|
||||
|
||||
int len = (enforcedLen != 0) ? enforcedLen : data.Length;
|
||||
if (len < 2) return false;
|
||||
|
||||
UInt16 crc = ClaculateTelegramCRC(data);
|
||||
UInt16 crc = CalculateTelegramCRC(data, len);
|
||||
|
||||
return (data[len - 2] == (byte)(crc & 0xFF)) && (data[len - 1] == (byte)(crc >> 8));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function compares the last 2 bytes in the message buffer
|
||||
/// with the CRC calculated from the remaining first (Lenght - 2) bytes.
|
||||
/// A complete telegram including two bytes reserved for the CRC
|
||||
/// must be supplied as an argument.
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>true if the CRC in the telegram is correct</returns>
|
||||
public static bool VerifyTelegramCRC(int offset, byte[] data, int enforcedLen = 0)
|
||||
{
|
||||
if (data == null || data.Length == 0 || enforcedLen > data.Length - offset) return false;
|
||||
|
||||
int len = (enforcedLen != 0) ? enforcedLen : data.Length - offset;
|
||||
if (len < 2) return false;
|
||||
|
||||
UInt16 crc = CalculateTelegramCRC(offset, data, len);
|
||||
|
||||
return (data[offset + len - 2] == (byte)(crc & 0xFF)) && (data[offset + len - 1] == (byte)(crc >> 8));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -91,7 +129,7 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>Calculated checksum</returns>
|
||||
public static byte ClaculateTelegramChecksum(byte[] data)
|
||||
public static byte CalculateTelegramChecksum(byte[] data)
|
||||
{
|
||||
byte checksum = 0;
|
||||
for (int i = 0; i < data.Length - 1; i++) checksum = (byte)(checksum ^ data[i]);
|
||||
@ -106,7 +144,7 @@ namespace TBF.BenchControl
|
||||
/// <param name="hartPreambLen">Length of HART telegram preamble (FF bytes)</param>
|
||||
/// <param name="data">Data telegram</param>
|
||||
/// <returns>Calculated checksum</returns>
|
||||
public static byte ClaculateTelegramChecksum(int hartPreambLen, byte[] data)
|
||||
public static byte CalculateTelegramChecksum(int hartPreambLen, byte[] data)
|
||||
{
|
||||
byte checksum = 0;
|
||||
for (int i = hartPreambLen; i < data.Length - 1; i++) checksum = (byte)(checksum ^ data[i]);
|
||||
@ -124,7 +162,7 @@ namespace TBF.BenchControl
|
||||
{
|
||||
int len = data.Length;
|
||||
if (len < 1) return;
|
||||
data[len - 1] = ClaculateTelegramChecksum(data);
|
||||
data[len - 1] = CalculateTelegramChecksum(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,7 +177,7 @@ namespace TBF.BenchControl
|
||||
public static void UpdateTelegramChecksum(int hartPreambLen, byte[] data)
|
||||
{
|
||||
if (data.Length - hartPreambLen < 1) return;
|
||||
data[data.Length - 1] = ClaculateTelegramChecksum(hartPreambLen, data);
|
||||
data[data.Length - 1] = CalculateTelegramChecksum(hartPreambLen, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -154,7 +192,7 @@ namespace TBF.BenchControl
|
||||
{
|
||||
int len = data.Length;
|
||||
if (len < 1) return false;
|
||||
return (data[len - 1] == ClaculateTelegramChecksum(data));
|
||||
return (data[len - 1] == CalculateTelegramChecksum(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -169,11 +207,10 @@ namespace TBF.BenchControl
|
||||
public static bool VerifyTelegramChecksum(int hartPreambLen, byte[] data)
|
||||
{
|
||||
if (data.Length - hartPreambLen < 1) return false;
|
||||
return (data[data.Length - 1] == ClaculateTelegramChecksum(hartPreambLen, data));
|
||||
return (data[data.Length - 1] == CalculateTelegramChecksum(hartPreambLen, data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string LogTelegram(string intro, byte[] data, int from = 0, int len = -1)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
|
||||
@ -194,6 +231,7 @@ namespace TBF.BenchControl
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static string LogTelegram(string intro, IList<byte> data, int from = 0, int len = -1)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
|
||||
@ -215,7 +253,6 @@ namespace TBF.BenchControl
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string LogTelegram(string intro, string data)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(80);
|
||||
@ -1,107 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Common.UIControls
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class ListViewExtensions
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HDITEM
|
||||
{
|
||||
public Mask mask;
|
||||
public int cxy;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pszText;
|
||||
public IntPtr hbm;
|
||||
public int cchTextMax;
|
||||
public Format fmt;
|
||||
public IntPtr lParam;
|
||||
// _WIN32_IE >= 0x0300
|
||||
public int iImage;
|
||||
public int iOrder;
|
||||
// _WIN32_IE >= 0x0500
|
||||
public uint type;
|
||||
public IntPtr pvFilter;
|
||||
// _WIN32_WINNT >= 0x0600
|
||||
public uint state;
|
||||
|
||||
[Flags]
|
||||
public enum Mask
|
||||
{
|
||||
Format = 0x4, // HDI_FORMAT
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum Format
|
||||
{
|
||||
SortDown = 0x200, // HDF_SORTDOWN
|
||||
SortUp = 0x400, // HDF_SORTUP
|
||||
};
|
||||
};
|
||||
|
||||
public const int LVM_FIRST = 0x1000;
|
||||
public const int LVM_GETHEADER = LVM_FIRST + 31;
|
||||
|
||||
public const int HDM_FIRST = 0x1200;
|
||||
public const int HDM_GETITEM = HDM_FIRST + 11;
|
||||
public const int HDM_SETITEM = HDM_FIRST + 12;
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
|
||||
|
||||
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, SortOrder order)
|
||||
{
|
||||
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
|
||||
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
|
||||
{
|
||||
var columnPtr = new IntPtr(columnNumber);
|
||||
var item = new HDITEM
|
||||
{
|
||||
mask = HDITEM.Mask.Format
|
||||
};
|
||||
|
||||
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
|
||||
{
|
||||
throw new Win32Exception();
|
||||
}
|
||||
|
||||
if (order != SortOrder.None && columnNumber == columnIndex)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case SortOrder.Ascending:
|
||||
item.fmt &= ~HDITEM.Format.SortDown;
|
||||
item.fmt |= HDITEM.Format.SortUp;
|
||||
break;
|
||||
|
||||
case SortOrder.Descending:
|
||||
item.fmt &= ~HDITEM.Format.SortUp;
|
||||
item.fmt |= HDITEM.Format.SortDown;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
|
||||
}
|
||||
|
||||
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
|
||||
{
|
||||
throw new Win32Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Common.UIControls
|
||||
{
|
||||
public class LviIntColumnComparer : IComparer
|
||||
{
|
||||
int column;
|
||||
SortOrder order;
|
||||
|
||||
public LviIntColumnComparer()
|
||||
{
|
||||
column = 0;
|
||||
order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
public LviIntColumnComparer(int column, SortOrder order)
|
||||
{
|
||||
this.column = column;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
|
||||
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
|
||||
return (order == SortOrder.Descending) ? (valY - valX) : (valX - valY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Common.UIControls
|
||||
{
|
||||
public class LviTextColumnComparer : IComparer
|
||||
{
|
||||
private int column;
|
||||
SortOrder order;
|
||||
|
||||
public LviTextColumnComparer()
|
||||
{
|
||||
column = 0;
|
||||
order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
public LviTextColumnComparer(int column, SortOrder order)
|
||||
{
|
||||
this.column = column;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
string txtX = ((ListViewItem)x).SubItems[column].Text;
|
||||
string txtY = ((ListViewItem)y).SubItems[column].Text;
|
||||
return (order == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
|
||||
}
|
||||
}
|
||||
}
|
||||
564
Common/Units.cs
Normal file
564
Common/Units.cs
Normal file
@ -0,0 +1,564 @@
|
||||
///
|
||||
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public enum Unit
|
||||
{
|
||||
[Description("---")] None,
|
||||
|
||||
[Description("imp.")] pulse,
|
||||
#if LANG_PL
|
||||
[Description("stopień")] degree,
|
||||
#else
|
||||
[Description("degree")] degree,
|
||||
#endif
|
||||
[Description("ml")] ml, /// 1 ml = 0.001 l
|
||||
[Description("l")] l, /// * 1 liter
|
||||
[Description("dm3")] dm3, /// 1 dm3 = 1 l
|
||||
[Description("US gal")] USgal, /// 1 US gallon = 3.78541178 l
|
||||
[Description("imper.gal")] UKgal, /// 1 imperial gallon = 4.54609 l
|
||||
[Description("cf")] cf, /// 1 cubic foot = 28.316846592 l
|
||||
[Description("m3")] m3, /// 1 m3 = 1000 l
|
||||
|
||||
[Description("l/h")] lph, /// 1 l/h = 0.001 m3/h
|
||||
[Description("cf/h")] cfph, /// 1 cf/h = 0.028316846592 m3/h
|
||||
[Description("l/m")] lpm, /// 1 l/m = 60 l/h = 0.06 m3/h
|
||||
[Description("US gal/m")] USgalpm, /// 1 US gallon per minute = 0.2271247068 m3/h
|
||||
[Description("m3/h")] m3ph, /// * 1 m3/h
|
||||
[Description("l/s")] lps, /// 1 liter/s = 3.6 m3/h
|
||||
[Description("US gal/s")] USgalps, /// 1 US gallon per second = 13.627482408 m3/h
|
||||
[Description("m3/m")] m3pm, /// 1 m3/m = 60 m3/h
|
||||
[Description("cf/s")] cfs, /// 1 cubic foot per second = 101.9406477312 m3/h
|
||||
|
||||
[Description("g")] g, /// 0.001 kg
|
||||
[Description("oz")] oz, /// 0.0283495231 kg
|
||||
[Description("lb")] lb, /// 0.45359237 kg
|
||||
[Description("kg")] kg, /// * 1 kilogram
|
||||
[Description("t")] t, /// 1000 kg
|
||||
|
||||
[Description("ms")] ms, /// 1 ms = 0.001 s
|
||||
[Description("s")] s, /// * 1 second
|
||||
[Description("min")] min, /// 1 min = 60 s
|
||||
[Description("hr")] hour, /// 1 hour = 60 min = 3600 s
|
||||
|
||||
[Description("°C")] C, /// * degree Celsius (°C)
|
||||
[Description("°F")] F, /// degree Fahrenheit
|
||||
[Description("K")] K, /// degree Kelvin
|
||||
|
||||
[Description("Pa")] Pa, /// 1 Pa = 0.01 hPa
|
||||
[Description("hPa")] hPa, /// 1 hPa = 100 Pa
|
||||
[Description("mbar")] mbar, /// 1 mbar = 1 hPa = 100 Pa
|
||||
[Description("kPa")] kPa, /// 1 kPa = 10 hPa = 1000 Pa
|
||||
[Description("inHg")] inHg, /// 1 inHg = 33.864 hPa
|
||||
[Description("psi")] psi, /// 1 psi = 0.0689475729 bar
|
||||
[Description("bar")] bar, /// * 1 Bar = 1000 mbar = 0.1 MPa = 100000 Pa
|
||||
[Description("MPa")] MPa, /// 1 MPa = 10000 hPa
|
||||
|
||||
[Description("R%")] RPct, /// * 1 R%
|
||||
|
||||
[Description("promile")] Promile, /// 1 promile = 0.1 %
|
||||
[Description("%")] Pct, /// * 1 %
|
||||
|
||||
[Description("mm")] mm, /// * 1 millimeter
|
||||
[Description("cm")] cm, /// 1 cm = 10 mm
|
||||
[Description("in")] inch, /// 1 inch = 25.4 mm
|
||||
[Description("dm")] dm, /// 1 dm = 100 mm
|
||||
[Description("ft")] foot, /// 1 foot = 304.8 mm
|
||||
[Description("yd")] yard, /// 1 yard = 914.4 mm
|
||||
[Description("m")] m, /// 1 m = 1000 mm
|
||||
|
||||
[Description("kg/m3")] kgpm3, /// * 1 kg/m3 = 0.001 kg/l
|
||||
[Description("kg/l")] kgpl, /// 1 kg/l = 1000 kg/m3
|
||||
|
||||
[Description("J")] J, /// * 1 Joul
|
||||
[Description("kJ")] kJ, /// 1 kJ = 1000 J
|
||||
[Description("MJ")] MJ, /// 1 MJ = 1000000 J
|
||||
[Description("Wh")] Wh, /// 1 Wh = 3600 J
|
||||
[Description("kWh")] kWh, /// 1 kWh = 3600000 J
|
||||
[Description("MWh")] MWh, /// 1 MWh = 3600000000 J
|
||||
|
||||
[Description("uS/cm")] uSpcm, /// * 1 uS/cm
|
||||
[Description("mS/m")] mSpm, /// 1 mS/m = 10 uS/cm
|
||||
|
||||
#if LANG_PL
|
||||
[Description("imp/l")] ppl, /// * 1 pulse/l
|
||||
[Description("imp/dm3")] ppdm3, /// * 1 pulse/dm3
|
||||
[Description("stopień/l")] degpl, /// * 1 degree/l
|
||||
[Description("stopień/dm3")] degpdm3, /// * 1 degree/dm3
|
||||
[Description("l/imp")] lpp, /// * 1 l/pulse
|
||||
[Description("dm3/imp")] dm3pp, /// * 1 dm3/pulse
|
||||
[Description("l/stopień")] lpdeg, /// * 1 l/degree
|
||||
[Description("dm3/stopień")] dm3pdeg, /// * 1 dm3/degree
|
||||
#else
|
||||
[Description("pulse/l")] ppl, /// * 1 pulse/l
|
||||
[Description("pulse/dm3")] ppdm3, /// 1 pulse/dm3
|
||||
[Description("degree/l")] degpl, /// 1 degree/l
|
||||
[Description("degree/dm3")] degpdm3, /// 1 degree/dm3
|
||||
[Description("l/pulse")] lpp, /// 1 l/pulse
|
||||
[Description("dm3/pulse")] dm3pp, /// 1 dm3/pulse
|
||||
[Description("l/degree")] lpdeg, /// 1 l/degree
|
||||
[Description("dm3/degree")] dm3pdeg, /// 1 dm3/degree
|
||||
#endif
|
||||
///
|
||||
[Description("pulse/kWh")] ppkWh, /// * 1 pulse/kWh
|
||||
[Description("kWh/pulse")] kWhpp, /// 1 kWh/pulse
|
||||
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Quantity
|
||||
{
|
||||
/// Quantities with units and conversions (double -> double)
|
||||
#if LANG_DE
|
||||
[Description("Volumen")] Volume,
|
||||
[Description("Durchfluss")] Flow,
|
||||
[Description("Masse")] Mass,
|
||||
[Description("Zeit")] Time,
|
||||
[Description("Temperatur")] Temperature,
|
||||
[Description("Druck")] Pressure,
|
||||
[Description("Feuchtigkeit")] Humidity,
|
||||
[Description("Fehler")] Error,
|
||||
[Description("Länge")] Length,
|
||||
[Description("Dichte")] Density,
|
||||
[Description("Energie")] Energy,
|
||||
[Description("Impulse")] Pulses,
|
||||
[Description("Impulse/l")] PulsePerLtr,
|
||||
[Description("Impulse/kWh")] PulsePerKWh,
|
||||
[Description("Leitfähigkeit")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Nummer")] Number,
|
||||
[Description("Text")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Datum und Uhrzeit")] DateTime,
|
||||
[Description("Aufgezählt")] Enumerated,
|
||||
#elif LANG_PL
|
||||
[Description("Objętość")] Volume,
|
||||
[Description("Przepływ")] Flow,
|
||||
[Description("Masa")] Mass,
|
||||
[Description("Czas")] Time,
|
||||
[Description("Temperatura")] Temperature,
|
||||
[Description("Ciśnienie")] Pressure,
|
||||
[Description("Wilgotność")] Humidity,
|
||||
[Description("Błąd")] Error,
|
||||
[Description("Długość")] Length,
|
||||
[Description("Gęstość")] Density,
|
||||
[Description("Energia")] Energy,
|
||||
[Description("Impulsy")] Pulses,
|
||||
[Description("Impulsy/litr")] PulsePerLtr,
|
||||
[Description("Impulsy/kWh")] PulsePerKWh,
|
||||
[Description("Przewodność")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Numer")] Number,
|
||||
[Description("Tekst")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Data i czas")] DateTime,
|
||||
[Description("Wyliczone")] Enumerated,
|
||||
#elif LANG_CS
|
||||
[Description("Objem")] Volume,
|
||||
[Description("Průtok")] Flow,
|
||||
[Description("Hmotnost")] Mass,
|
||||
[Description("Čas")] Time,
|
||||
[Description("Teplota")] Temperature,
|
||||
[Description("Tlak")] Pressure,
|
||||
[Description("Vlhkost")] Humidity,
|
||||
[Description("Chyba")] Error,
|
||||
[Description("Délka")] Length,
|
||||
[Description("Hustota")] Density,
|
||||
[Description("Energie")] Energy,
|
||||
[Description("Pulzy")] Pulses,
|
||||
[Description("Pulzy/litr")] PulsePerLtr,
|
||||
[Description("Pulzy/kWh")] PulsePerKWh,
|
||||
[Description("Vodivost")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Počet")] Number,
|
||||
[Description("Text")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Datum a čas")] DateTime,
|
||||
[Description("Vyjmenované")] Enumerated,
|
||||
#elif LANG_IT
|
||||
[Description("Volume")] Volume,
|
||||
[Description("Flusso")] Flow,
|
||||
[Description("Massa")] Mass,
|
||||
[Description("Tempo")] Time,
|
||||
[Description("Temperatura")] Temperature,
|
||||
[Description("Pressione")] Pressure,
|
||||
[Description("Umidità")] Humidity,
|
||||
[Description("Errore")] Error,
|
||||
[Description("Lungezza")] Length,
|
||||
[Description("Densità")] Density,
|
||||
[Description("Energia")] Energy,
|
||||
[Description("Impulso")] Pulses,
|
||||
[Description("Impulso/litro")] PulsePerLtr,
|
||||
[Description("Impulso/kWh")] PulsePerKWh,
|
||||
[Description("Conduttività")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Numero")] Number,
|
||||
[Description("Stringa")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Data e ora")] DateTime,
|
||||
[Description("Enumerato")] Enumerated,
|
||||
#else
|
||||
[Description("Volume")] Volume,
|
||||
[Description("Flow")] Flow,
|
||||
[Description("Mass")] Mass,
|
||||
[Description("Time")] Time,
|
||||
[Description("Temperature")] Temperature,
|
||||
[Description("Pressure")] Pressure,
|
||||
[Description("Humidity")] Humidity,
|
||||
[Description("Error")] Error,
|
||||
[Description("Length")] Length,
|
||||
[Description("Density")] Density,
|
||||
[Description("Energy")] Energy,
|
||||
[Description("Pulses")] Pulses,
|
||||
[Description("Pulses/liter")] PulsePerLtr,
|
||||
[Description("Pulses/kWh")] PulsePerKWh,
|
||||
[Description("Conductivity")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Number")] Number,
|
||||
[Description("String")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Date and time")] DateTime,
|
||||
[Description("Enumerated")] Enumerated,
|
||||
#endif
|
||||
Count,
|
||||
}
|
||||
|
||||
public static class Units
|
||||
{
|
||||
public static bool IsUnitless(Quantity quantity)
|
||||
{
|
||||
return quantity >= Quantity.Number;
|
||||
}
|
||||
|
||||
public static bool IsDefaultUnit(Unit unit)
|
||||
{
|
||||
return unit == Unit.l || unit == Unit.m3ph || unit == Unit.kg || unit == Unit.s || unit == Unit.C ||
|
||||
unit == Unit.bar || unit == Unit.RPct || unit == Unit.Pct || unit == Unit.mm || unit == Unit.kgpm3 ||
|
||||
unit == Unit.J || unit == Unit.uSpcm || unit == Unit.ppl || unit == Unit.ppkWh;
|
||||
}
|
||||
|
||||
public static bool IsQuantity(Unit unit, Quantity quantity)
|
||||
{
|
||||
return (quantity == GetQuantity(unit));
|
||||
}
|
||||
|
||||
public static Quantity GetQuantity(Unit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case Unit.pulse:
|
||||
case Unit.degree:
|
||||
return Quantity.Pulses;
|
||||
|
||||
case Unit.ml:
|
||||
case Unit.l:
|
||||
case Unit.dm3:
|
||||
case Unit.USgal:
|
||||
case Unit.UKgal:
|
||||
case Unit.cf:
|
||||
case Unit.m3:
|
||||
return Quantity.Volume;
|
||||
|
||||
case Unit.lph:
|
||||
case Unit.cfph:
|
||||
case Unit.lpm:
|
||||
case Unit.USgalpm:
|
||||
case Unit.m3ph:
|
||||
case Unit.lps:
|
||||
case Unit.USgalps:
|
||||
case Unit.m3pm:
|
||||
case Unit.cfs:
|
||||
return Quantity.Flow;
|
||||
|
||||
case Unit.g:
|
||||
case Unit.oz:
|
||||
case Unit.lb:
|
||||
case Unit.kg:
|
||||
case Unit.t:
|
||||
return Quantity.Mass;
|
||||
|
||||
case Unit.ms:
|
||||
case Unit.s:
|
||||
case Unit.min:
|
||||
case Unit.hour:
|
||||
return Quantity.Time;
|
||||
|
||||
case Unit.C:
|
||||
case Unit.F:
|
||||
case Unit.K:
|
||||
return Quantity.Temperature;
|
||||
|
||||
case Unit.Pa:
|
||||
case Unit.hPa:
|
||||
case Unit.mbar:
|
||||
case Unit.kPa:
|
||||
case Unit.inHg:
|
||||
case Unit.psi:
|
||||
case Unit.bar:
|
||||
case Unit.MPa:
|
||||
return Quantity.Pressure;
|
||||
|
||||
case Unit.RPct:
|
||||
return Quantity.Humidity;
|
||||
|
||||
case Unit.Promile:
|
||||
case Unit.Pct:
|
||||
return Quantity.Error;
|
||||
|
||||
case Unit.mm:
|
||||
case Unit.cm:
|
||||
case Unit.inch:
|
||||
case Unit.dm:
|
||||
case Unit.foot:
|
||||
case Unit.yard:
|
||||
case Unit.m:
|
||||
return Quantity.Length;
|
||||
|
||||
case Unit.kgpm3:
|
||||
case Unit.kgpl:
|
||||
return Quantity.Density;
|
||||
|
||||
case Unit.J:
|
||||
case Unit.kJ:
|
||||
case Unit.MJ:
|
||||
case Unit.Wh:
|
||||
case Unit.kWh:
|
||||
case Unit.MWh:
|
||||
return Quantity.Energy;
|
||||
|
||||
case Unit.uSpcm:
|
||||
case Unit.mSpm:
|
||||
return Quantity.Conductivity;
|
||||
|
||||
case Unit.ppl:
|
||||
case Unit.ppdm3:
|
||||
case Unit.degpl:
|
||||
case Unit.degpdm3:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg:
|
||||
return Quantity.PulsePerLtr;
|
||||
|
||||
case Unit.ppkWh:
|
||||
case Unit.kWhpp:
|
||||
return Quantity.PulsePerKWh;
|
||||
|
||||
default:
|
||||
return Quantity.Number;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVolume(Unit unit) { return IsQuantity(unit, Quantity.Volume); }
|
||||
public static bool IsFlow(Unit unit) { return IsQuantity(unit, Quantity.Flow); }
|
||||
public static bool IsMass(Unit unit) { return IsQuantity(unit, Quantity.Mass); }
|
||||
public static bool IsTime(Unit unit) { return IsQuantity(unit, Quantity.Time); }
|
||||
public static bool IsTemperature(Unit unit) { return IsQuantity(unit, Quantity.Temperature); }
|
||||
public static bool IsPressure(Unit unit) { return IsQuantity(unit, Quantity.Pressure); }
|
||||
public static bool IsHumidity(Unit unit) { return IsQuantity(unit, Quantity.Humidity); }
|
||||
public static bool IsError(Unit unit) { return IsQuantity(unit, Quantity.Error); }
|
||||
public static bool IsLength(Unit unit) { return IsQuantity(unit, Quantity.Length); }
|
||||
public static bool IsDensity(Unit unit) { return IsQuantity(unit, Quantity.Density); }
|
||||
public static bool IsEnergy(Unit unit) { return IsQuantity(unit, Quantity.Energy); }
|
||||
public static bool IsPulses(Unit unit) { return IsQuantity(unit, Quantity.Pulses); }
|
||||
public static bool IsPulsePerLtr(Unit unit) { return IsQuantity(unit, Quantity.PulsePerLtr); }
|
||||
public static bool IsPulsePerKWh(Unit unit) { return IsQuantity(unit, Quantity.PulsePerKWh); }
|
||||
public static bool IsConductivity(Unit unit) { return IsQuantity(unit, Quantity.Conductivity); }
|
||||
|
||||
|
||||
|
||||
public static float ConvertTo(Unit unit, float v)
|
||||
{
|
||||
return (float)ConvertTo(unit, (double)v);
|
||||
}
|
||||
|
||||
public static double ConvertTo(Unit unit, double v)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.ml: return 1000 * v; /// 1 ml = 0.001 l
|
||||
case Unit.USgal: return 0.26417205 * v; /// 1 gal(US) = 3.78541178 l
|
||||
case Unit.UKgal: return 0.21996925 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.cf: return 0.0353146667215 * v; /// 1 cubic foot = 28.316846592 l
|
||||
case Unit.m3: return 0.001 * v; /// 1 m3 = 1000 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 1000 * v; /// 1 l/h
|
||||
case Unit.cfph: return 35.3146667214886 * v;/// 1 cf/h
|
||||
case Unit.lpm: return v / 0.06; /// 1 l/m
|
||||
case Unit.USgalpm: return 4.40286754395493 * v;/// 1 US gallon per minute
|
||||
case Unit.lps: return v / 3.6; /// 1 l/s
|
||||
case Unit.USgalps: return 0.0733811257326 * v; /// 1 US gallon per second
|
||||
case Unit.m3pm: return v / 60; /// 1 m3/m
|
||||
case Unit.cfs: return 0.009809629644858 * v; /// 1 cubic foot per second
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 1000 * v; /// 1 g = 0.001 kg
|
||||
case Unit.oz: return 35.273962 * v; /// 1 oz = 0.0283495231 kg
|
||||
case Unit.lb: return 2.2046226 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 0.001 * v; /// 1 t = 1000 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.ms: return 1000 * v;
|
||||
case Unit.min: return v / 60;
|
||||
case Unit.hour: return v / 3600;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.F: return 1.8 * v + 32; /// degree Fahrenheit
|
||||
case Unit.K: return v + 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 100000 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.hPa: return 1000 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 1000 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 100 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.inHg: return 29.53 * v; /// 1 inHg =
|
||||
case Unit.psi: return 14.5037738 * v; /// 1 psi =
|
||||
case Unit.MPa: return 0.1 * v; /// 1 MPa = 10000 hPa
|
||||
|
||||
/// Relative error: internal representation in %
|
||||
case Unit.Promile: return 10 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.cm: return 0.1 * v; /// 1 cm = 10 mm
|
||||
case Unit.inch: return v / 25.4; /// 1 inch = 25.4 mm
|
||||
case Unit.dm: return 0.01 * v; /// 1 dm = 100 mm
|
||||
case Unit.foot: return v / 304.8; /// 1 foot = 304.8 mm
|
||||
case Unit.yard: return v / 914.4; /// 1 yard = 914,4 mm
|
||||
case Unit.m: return 0.001 * v; /// 1 m = 1000 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpl: return 0.001 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.kJ: return 0.001 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 0.000001 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return v / 3600.0; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return v / 3600000.0; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return v / 3600000000.0; /// 1 MWh = 3600000000 J
|
||||
|
||||
/// Electrical conductivity
|
||||
case Unit.mSpm: return 0.1 * v;
|
||||
|
||||
/// Invert pulses
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return (v <= float.Epsilon) ? 0 : 1/v;
|
||||
|
||||
default: return v; /// Do not convert
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static float ConvertFrom(Unit unit, float v)
|
||||
{
|
||||
return (float)ConvertFrom(unit, (double)v);
|
||||
}
|
||||
|
||||
public static double ConvertFrom(Unit unit, double v)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.ml: return 0.001 * v; /// 0.001 l
|
||||
case Unit.USgal: return 3.78541178 * v; /// 1 gal(US) = 3.78541178 l
|
||||
case Unit.UKgal: return 4.54609 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.cf: return 28.316846592 * v; /// 1 cubic foot = 28.316846592 l
|
||||
case Unit.m3: return 1000 * v; /// 1000 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 0.001 * v; /// 1 l/h
|
||||
case Unit.cfph: return 0.028316846592 * v; /// 1 cf/h
|
||||
case Unit.lpm: return 0.06 * v; /// 1 l/m
|
||||
case Unit.USgalpm: return 0.2271247068 * v; /// 1 US gallon per minute
|
||||
case Unit.lps: return 3.6 * v; /// 1 l/s
|
||||
case Unit.USgalps: return 13.627482408 * v; /// 1 US gallon per second
|
||||
case Unit.m3pm: return 60 * v; /// 1 m3/m
|
||||
case Unit.cfs: return 101.9406477312 * v; /// 1 cubic foot per second
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 0.001 * v; /// 1 g = 0.001 kg
|
||||
case Unit.oz: return 0.0283495231 * v; /// 1 oz = 0.0283495231 kg
|
||||
case Unit.lb: return 0.45359237 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 1000 * v; /// 1 t = 1000 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.ms: return 0.001 * v;
|
||||
case Unit.min: return 60 * v;
|
||||
case Unit.hour: return 3600 * v;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.F: return 5 * (v - 32) / 9; /// degree Fahrenheit
|
||||
case Unit.K: return v - 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 0.00001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.hPa: return 0.001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 0.001 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 0.01 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.inHg: return 0.033864 * v; /// 1 inHg = 33.864 hPa
|
||||
case Unit.psi: return 0.0689475729 * v; /// 1 psi = 0.0689475729 bar
|
||||
case Unit.MPa: return 10 * v; /// 1 MPa = 10000 hPa
|
||||
|
||||
/// Relative error: internal representation in %
|
||||
case Unit.Promile: return 0.1 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.cm: return 10 * v; /// 1 cm = 10 mm
|
||||
case Unit.inch: return 25.4 * v; /// 1 inch = 25.4 mm
|
||||
case Unit.dm: return 100 * v; /// 1 dm = 100 mm
|
||||
case Unit.foot: return 304.8 * v; /// 1 foot = 304.8 mm
|
||||
case Unit.yard: return 914.4 * v; /// 1 yard = 914,4 mm
|
||||
case Unit.m: return 1000 * v; /// 1 m = 1000 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpl: return 1000 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.kJ: return 1000 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 1000000 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return 3600 * v; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return 3600000 * v; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return 3600000000 * v; /// 1 kWh = 3600000000 J
|
||||
|
||||
/// Electrical conductivity
|
||||
case Unit.mSpm: return 10 * v;
|
||||
|
||||
/// Invert
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return (v <= float.Epsilon) ? 0 : 1/v;
|
||||
|
||||
default: return v; /// Do not convert
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a string to a unit
|
||||
/// </summary>
|
||||
/// <param name="description">Unit description string</param>
|
||||
/// <returns>Converted unit or Unit.None if not recognized</returns>
|
||||
public static Unit FromDescription(string description)
|
||||
{
|
||||
for (Unit unit = 0; unit < Unit.Count; unit++)
|
||||
{
|
||||
if (unit.ToDescription() == description) return unit;
|
||||
}
|
||||
|
||||
return Unit.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
135
Common/Utils.cs
135
Common/Utils.cs
@ -1,12 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
///
|
||||
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
public static string GetTestName(string name, int repeats, int repetitionNr)
|
||||
{
|
||||
if (name == null) return null;
|
||||
if (repeats == 1) return name;
|
||||
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
|
||||
}
|
||||
|
||||
public static string ToNiceString(double value, int sigDigits)
|
||||
{
|
||||
string format = SignificantDigitsToFmt(value, sigDigits);
|
||||
return (format == "F0") ? value.ToString("F0") : value.ToString(format).TrimEnd(new char[] { '0' });
|
||||
}
|
||||
|
||||
public static FlowNames ProfileType2FlowNames(ProfileType pt)
|
||||
{
|
||||
switch (pt)
|
||||
{
|
||||
case ProfileType.Q3R: return FlowNames.Q3Q2Q1;
|
||||
case ProfileType.QnClassColdWater: return FlowNames.QnQtQmin;
|
||||
case ProfileType.QnClassHotWater: return FlowNames.QnQtQmin;
|
||||
case ProfileType.QpQi: return FlowNames.QpQi;
|
||||
default: return FlowNames.Q3Q2Q1;
|
||||
}
|
||||
}
|
||||
|
||||
public static string SignificantDigitsToFmt(double value, int sigDigits)
|
||||
{
|
||||
if (sigDigits == 6)
|
||||
{
|
||||
if (value >= 99999.5 || value < -99999.5) return "F0";
|
||||
else if (value >= 9999.95 || value < -9999.95) return "F1";
|
||||
else if (value >= 999.995 || value < -999.995) return "F2";
|
||||
else if (value >= 99.9995 || value < -99.9995) return "F3";
|
||||
else if (value >= 9.99995 || value < -9.99995) return "F4";
|
||||
else if (value >= 0.999995 || value < -0.999995) return "F5";
|
||||
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
|
||||
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
|
||||
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
|
||||
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
|
||||
else return "F10";
|
||||
}
|
||||
else if (sigDigits == 5)
|
||||
{
|
||||
if (value >= 9999.5 || value < -9999.5) return "F0";
|
||||
else if (value >= 999.95 || value < -999.95) return "F1";
|
||||
else if (value >= 99.995 || value < -99.995) return "F2";
|
||||
else if (value >= 9.9995 || value < -9.9995) return "F3";
|
||||
else if (value >= 0.99995 || value < -0.99995) return "F4";
|
||||
else if (value >= 0.099995 || value < -0.099995) return "F5";
|
||||
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
|
||||
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
|
||||
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
|
||||
else return "F9";
|
||||
}
|
||||
else if (sigDigits == 4)
|
||||
{
|
||||
if (value >= 999.5 || value < -999.5) return "F0";
|
||||
else if (value >= 99.95 || value < -99.95) return "F1";
|
||||
else if (value >= 9.995 || value < -9.995) return "F2";
|
||||
else if (value >= 0.9995 || value < -0.9995) return "F3";
|
||||
else if (value >= 0.09995 || value < -0.09995) return "F4";
|
||||
else if (value >= 0.009995 || value < -0.009995) return "F5";
|
||||
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
|
||||
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
|
||||
else return "F8";
|
||||
}
|
||||
else if (sigDigits == 3)
|
||||
{
|
||||
if (value >= 99.5 || value < -99.5) return "F0";
|
||||
else if (value >= 9.95 || value < -9.95) return "F1";
|
||||
else if (value >= 0.995 || value < -0.995) return "F2";
|
||||
else if (value >= 0.0995 || value < -0.0995) return "F3";
|
||||
else if (value >= 0.00995 || value < -0.00995) return "F4";
|
||||
else if (value >= 0.000995 || value < -0.000995) return "F5";
|
||||
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
|
||||
else return "F7";
|
||||
}
|
||||
else if (sigDigits == 2)
|
||||
{
|
||||
if (value >= 9.5 || value < -9.5) return "F0";
|
||||
else if (value >= 0.95 || value < -0.95) return "F1";
|
||||
else if (value >= 0.095 || value < -0.095) return "F2";
|
||||
else if (value >= 0.0095 || value < -0.0095) return "F3";
|
||||
else if (value >= 0.00095 || value < -0.00095) return "F4";
|
||||
else if (value >= 0.000095 || value < -0.000095) return "F5";
|
||||
else return "F6";
|
||||
}
|
||||
else /// if (sigDigits == 1)
|
||||
{
|
||||
if (value >= 0.95 || value < -0.95) return "F0";
|
||||
else if (value >= 0.095 || value < -0.095) return "F1";
|
||||
else if (value >= 0.0095 || value < -0.0095) return "F2";
|
||||
else if (value >= 0.00095 || value < -0.00095) return "F3";
|
||||
else if (value >= 0.000095 || value < -0.000095) return "F4";
|
||||
else return "F5";
|
||||
}
|
||||
}
|
||||
|
||||
public static Parity GetParity(string str, Parity defaultParity = Parity.None)
|
||||
{
|
||||
if (str.Equals(Parity.None.ToString())) return Parity.None;
|
||||
if (str.Equals(Parity.Even.ToString())) return Parity.Even;
|
||||
if (str.Equals(Parity.Odd.ToString())) return Parity.Odd;
|
||||
if (str.Equals(Parity.Mark.ToString())) return Parity.Mark;
|
||||
if (str.Equals(Parity.Space.ToString())) return Parity.Space;
|
||||
return defaultParity;
|
||||
}
|
||||
|
||||
public static StopBits GetStopBits(string str, StopBits defaultStopBits = StopBits.One)
|
||||
{
|
||||
if (str.Equals(StopBits.None.ToString())) return StopBits.None;
|
||||
if (str.Equals(StopBits.One.ToString())) return StopBits.One;
|
||||
if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive;
|
||||
if (str.Equals(StopBits.Two.ToString())) return StopBits.Two;
|
||||
return defaultStopBits;
|
||||
}
|
||||
|
||||
public static Handshake GetHandshake(string str, Handshake defaultHandshake = Handshake.None)
|
||||
{
|
||||
if (str.Equals(Handshake.None.ToString())) return Handshake.None;
|
||||
if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend;
|
||||
if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff;
|
||||
if (str.Equals(Handshake.RequestToSendXOnXOff.ToString())) return Handshake.RequestToSendXOnXOff;
|
||||
return defaultHandshake;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ namespace Config.CalendarEvent
|
||||
}
|
||||
|
||||
|
||||
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime currentDate)
|
||||
public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime dateTimeNow)
|
||||
{
|
||||
DateTime evntDT = evnt.AllDay
|
||||
? new DateTime(evnt.Date.Year, evnt.Date.Month, evnt.Date.Day, 0, 0, 0)
|
||||
@ -133,17 +133,17 @@ namespace Config.CalendarEvent
|
||||
DateTime dt1 = evntDT;
|
||||
DateTime dt2 = evntDT + new TimeSpan(8, 0, 0);
|
||||
DateTime dt3 = evntDT + new TimeSpan(16, 0, 0);
|
||||
return (currentDate >= dt1) || (currentDate >= dt1) || (currentDate >= dt3);
|
||||
return (dateTimeNow >= dt1) || (dateTimeNow >= dt1) || (dateTimeNow >= dt3);
|
||||
}
|
||||
else if (!evnt.TriggerOnExactDayOnly)
|
||||
{
|
||||
/// Trigger after event expires
|
||||
return (currentDate >= evntDT);
|
||||
return (dateTimeNow >= evntDT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Trigger event on exact date only
|
||||
return (currentDate >= evntDT) && DayMatchesExactly(evnt, currentDate);
|
||||
return (dateTimeNow >= evntDT) && DayMatchesExactly(evnt, dateTimeNow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
@ -69,21 +69,17 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CalendarEvent\ICalendarEvent.cs" />
|
||||
<Compile Include="Data.cs" />
|
||||
<Compile Include="DatabaseSettings.cs" />
|
||||
<Compile Include="Entities\BenchPath.cs" />
|
||||
<Compile Include="Entities\CustomEvent.cs" />
|
||||
<Compile Include="Entities\Component.cs" />
|
||||
<Compile Include="Entities\ComponentProcedure.cs" />
|
||||
<Compile Include="Entities\ComponentTest.cs" />
|
||||
<Compile Include="Entities\Enums.cs" />
|
||||
<Compile Include="Entities\FeedingPath.cs" />
|
||||
<Compile Include="Entities\Group.cs" />
|
||||
<Compile Include="Entities\HeatMetersPath.cs" />
|
||||
<Compile Include="Entities\IHasItemNr.cs" />
|
||||
<Compile Include="Entities\IHasName.cs" />
|
||||
<Compile Include="Entities\IHasValves.cs" />
|
||||
<Compile Include="Entities\IParamsProvider.cs" />
|
||||
<Compile Include="Entities\IperlEnums.cs" />
|
||||
<Compile Include="Entities\MeasurementCorrection.cs" />
|
||||
<Compile Include="Entities\MetersPath.cs" />
|
||||
<Compile Include="Entities\OutputPath.cs" />
|
||||
@ -91,6 +87,7 @@
|
||||
<Compile Include="Entities\Profile.cs" />
|
||||
<Compile Include="Entities\PTest.cs" />
|
||||
<Compile Include="Entities\Test.cs" />
|
||||
<Compile Include="Entities\TestInstance.cs" />
|
||||
<Compile Include="Entities\TransitionSequence.cs" />
|
||||
<Compile Include="Entities\TransitionStep.cs" />
|
||||
<Compile Include="Entities\Uncertainty.cs" />
|
||||
@ -125,7 +122,6 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Strings.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Units.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -141,6 +137,10 @@
|
||||
<EmbeddedResource Include="Resources\Strings.zh-CN.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Common.csproj">
|
||||
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
|
||||
<Name>Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Users\Users.csproj">
|
||||
<Project>{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}</Project>
|
||||
<Name>Users</Name>
|
||||
|
||||
105
Config/Data.cs
105
Config/Data.cs
@ -2,37 +2,55 @@
|
||||
|
||||
namespace Config
|
||||
{
|
||||
public class Data : Users.GlobalData
|
||||
public class Data : Users.CurrentUser
|
||||
{
|
||||
public const string AdminUsername = "admin";
|
||||
public const string AdminPassword = "staratura";
|
||||
public const string SQLiteDbFName = "SQLite.db";
|
||||
|
||||
#if MUNICH
|
||||
public const int WMsCount = 3;
|
||||
public const int LineSize = 3;
|
||||
public const int CompoundWMsCount = 3;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 3;
|
||||
#elif DN100 || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || CEVAK_200
|
||||
#if DN100 || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || CEVAK_200
|
||||
public const int WMsCount = 3;
|
||||
public const int LineSize = 3;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif FUZHOU_300 || FUZHOU_150 || IZRAEL_200 || GENESIS || SLM_150 || PETERSBURG_200
|
||||
public const int MaxPartNr = 1;
|
||||
#elif MUNICH
|
||||
public const int WMsCount = 3;
|
||||
public const int LineSize = 3;
|
||||
public const int CompoundWMsCount = 3;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 3;
|
||||
#elif MALTA_WSD25
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int CompoundWMsCount = 0;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 3;
|
||||
public const int MaxPartNr = 1;
|
||||
#elif BADGER_MALA_TRAT || BERLIN || FUZHOU_150 || FUZHOU_300 || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || SENTEC || SLM_150 || TORINO_50
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 1;
|
||||
#elif PUCHONG_200
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 3;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 3;
|
||||
#elif DEWA_300 || ROMA_200
|
||||
#elif RUM_MOB
|
||||
public const int WMsCount = 8;
|
||||
public const int LineSize = 8;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif TURA_SPECIAL
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif DEWA_300 || FUZHOU_100 || ROMA_200 || LUXEMBURG_40
|
||||
public const int WMsCount = 10;
|
||||
public const int LineSize = 10;
|
||||
public const int CompoundWMsCount = 1;
|
||||
@ -44,73 +62,38 @@ namespace Config
|
||||
public const int CompoundWMsCount = 0;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif IZRAEL_50
|
||||
public const int WMsCount = 40;
|
||||
public const int LineSize = 10;
|
||||
public const int CompoundWMsCount = 0;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif FUZHOU_100
|
||||
public const int WMsCount = 10;
|
||||
public const int LineSize = 10;
|
||||
#elif SLM_END || WARSAW_END
|
||||
public const int WMsCount = 10;
|
||||
public const int LineSize = 5;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif TORINO_50 || BADGER_MALA_TRAT || BERLIN || GELSENWASSER
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int MaxPartNr = 4;
|
||||
#elif SLM_50
|
||||
public const int WMsCount = 12;
|
||||
public const int LineSize = 12;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 1;
|
||||
#elif TORUN_50 || CEVAK_40 || MURES_40 || FUZHOU_50 || PETERSBURG_50 || KEMPNO_50 || BAHRAIN_50 || KRAKOW_50 || JUZNA_AFRIKA_50 || IZRAEL_25 || ZAMBIA || ZODINO || FEWA_50 || FILIPINY_50 || ALZIR_25
|
||||
public const int HeatMetersCount = 6;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif ALZIR_25 || BAHRAIN_50 || CEVAK_40 || FEWA_50 || FILIPINY_50 || FUZHOU_50 || HONGKONG_50 || IZRAEL_25 || JUZNA_AFRIKA_50 || KEMPNO_50 || KRAKOW_50 || MILWAUKEE || MURES_40 || PETERSBURG_50 || TORUN_50 || WARSAW_50 || ZAMBIA || ZODINO
|
||||
public const int WMsCount = 20;
|
||||
public const int LineSize = 10;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif RUM_MOB
|
||||
public const int WMsCount = 8;
|
||||
public const int LineSize = 8;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif TURA_IPERL || TURA_IPERL_NEW
|
||||
public const int WMsCount = 40;
|
||||
public const int LineSize = 20;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif TURA_SPECIAL || SENTEC
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif SLM_50
|
||||
public const int WMsCount = 12;
|
||||
public const int LineSize = 12;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 6;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#elif SLM_END || WARSAW_END
|
||||
public const int WMsCount = 10;
|
||||
public const int LineSize = 5;
|
||||
public const int CompoundWMsCount = 1;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = 4;
|
||||
#elif MALTA_WSD25
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
#elif IZRAEL_50
|
||||
public const int WMsCount = 40;
|
||||
public const int LineSize = 10;
|
||||
public const int CompoundWMsCount = 0;
|
||||
public const int HeatMetersCount = 0;
|
||||
public const int MaxPartNr = WMsCount / LineSize;
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Database related: This object reference is set after a successful user login
|
||||
///
|
||||
public static DatabaseSettings CurrentBench;
|
||||
|
||||
public static double RealDensity = 0; /// true water density [kg/m3]
|
||||
public static double AtTemperature = 0; /// measured at temperature [°C]
|
||||
public static double Buoyancy = 0;
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Test bench database settings, contains bench name and settings od several databases
|
||||
/// </summary>
|
||||
public class DatabaseSettings : ICloneable
|
||||
{
|
||||
// Public fields
|
||||
public string BenchName;
|
||||
public bool IsRealBench;
|
||||
public Users.DBSettings ProceduresDBSettings; /// Configuration database settings
|
||||
public Users.DBSettings WaterMetersDBSettings; /// Results database settings
|
||||
public Users.DBSettings EventsDBSettings; /// Events database settings
|
||||
public Users.DBSettings UsersDBSettings; /// Shared configuration database settings
|
||||
|
||||
// Constructor
|
||||
public DatabaseSettings()
|
||||
{
|
||||
BenchName = String.Empty; /// Empty string (avoid null)
|
||||
IsRealBench = false;
|
||||
ProceduresDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
|
||||
WaterMetersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
|
||||
EventsDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
|
||||
UsersDBSettings = new Users.DBSettings(Users.Entities.DBType.MySql, string.Empty);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
DatabaseSettings result = new DatabaseSettings();
|
||||
|
||||
result.BenchName = BenchName;
|
||||
result.IsRealBench = IsRealBench;
|
||||
result.ProceduresDBSettings = (Users.DBSettings)ProceduresDBSettings.Clone();
|
||||
result.WaterMetersDBSettings = (Users.DBSettings)WaterMetersDBSettings.Clone();
|
||||
result.EventsDBSettings = (Users.DBSettings)EventsDBSettings.Clone();
|
||||
result.UsersDBSettings = (Users.DBSettings)UsersDBSettings.Clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} config={1} results={2} events={3} users={4}",
|
||||
BenchName,
|
||||
ProceduresDBSettings.ConnectionString,
|
||||
WaterMetersDBSettings.ConnectionString,
|
||||
EventsDBSettings.ConnectionString,
|
||||
UsersDBSettings.ConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -14,6 +15,8 @@ namespace Config.Entities
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string TempMtrUp { get; set; }
|
||||
public virtual string TempMtrDown { get; set; }
|
||||
public virtual string PressMtrUp { get; set; }
|
||||
@ -25,13 +28,16 @@ namespace Config.Entities
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public BenchPath()
|
||||
{
|
||||
ValvesOpen = string.Empty;
|
||||
ValvesClose = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public BenchPath(string name, int itemNr)
|
||||
: this()
|
||||
@ -46,7 +52,9 @@ namespace Config.Entities
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.TempMtrUp = TempMtrUp;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.TempMtrUp = TempMtrUp;
|
||||
result.TempMtrDown = TempMtrDown;
|
||||
result.PressMtrUp = PressMtrUp;
|
||||
result.PressMtrDown = PressMtrDown;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -86,7 +87,7 @@ namespace Config.Entities
|
||||
else if (line.Equals(DebugMode.FailureDuringOperation.ToString())) result.Mode = DebugMode.FailureDuringOperation;
|
||||
else if (line.Equals(DebugMode.Off.ToString())) result.Mode = DebugMode.Off;
|
||||
else if (line.Equals(DebugMode.Record.ToString())) result.Mode = DebugMode.Record;
|
||||
else if (line.Equals(DebugMode.Reply.ToString())) result.Mode = DebugMode.Reply;
|
||||
else if (line.Equals(DebugMode.Replay.ToString())) result.Mode = DebugMode.Replay;
|
||||
else if (line.Equals(DebugMode.Simulate.ToString())) result.Mode = DebugMode.Simulate;
|
||||
else if (line.Equals(DebugMode.Inherit.ToString())) result.Mode = DebugMode.Inherit;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
|
||||
@ -46,8 +46,8 @@ namespace Config.Entities
|
||||
Rank = 2;
|
||||
Hidden = false;
|
||||
ReadOnly = false;
|
||||
BackColor = unchecked((int)0xFFFF5050);
|
||||
TextColor = unchecked((int)0xFFFFFFFF);
|
||||
BackColor = unchecked((int)0xFFFF5050); /// (MSB)AARRGGBB(LSB) ... pink
|
||||
TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
|
||||
TooltipEnabled = true;
|
||||
CustomRecurringFunction = null;
|
||||
}
|
||||
|
||||
@ -1,19 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class FeedingPath : IHasName, IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string Pump { get; set; }
|
||||
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
|
||||
|
||||
@ -21,6 +24,9 @@ namespace Config.Entities
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public FeedingPath()
|
||||
@ -40,12 +46,14 @@ namespace Config.Entities
|
||||
{
|
||||
FeedingPath result = new FeedingPath(name, itemNr);
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.Pump = Pump;
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.Pump = Pump;
|
||||
result.RegulValvesPct = RegulValvesPct;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Config.Entities
|
||||
public class Group
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual Users.Entities.GID GID { get; set; }
|
||||
public virtual Common.GID GID { get; set; }
|
||||
public virtual long AccessFlags { get; set; } /// Bitfield of access flags: bit0 .. bit62
|
||||
public virtual IList<User> Users { get; set; } /// Group can be a member of a list of users
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Config.Entities
|
||||
Users = new List<User>();
|
||||
}
|
||||
|
||||
public Group(Users.Entities.GID gid)
|
||||
public Group(Common.GID gid)
|
||||
: this()
|
||||
{
|
||||
GID = gid;
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
|
||||
public enum Side
|
||||
{
|
||||
#if LANG_CS
|
||||
[Description("Levá")] Left,
|
||||
[Description("Pravá")] Right,
|
||||
#else
|
||||
[Description("Left")] Left,
|
||||
[Description("Right")] Right,
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
|
||||
public enum FlowDir
|
||||
{
|
||||
R_L,
|
||||
L_R,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Counting
|
||||
{
|
||||
Arbitrary,
|
||||
Positive,
|
||||
Negative,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum OptoHeadState
|
||||
{
|
||||
Disabled,
|
||||
OptoAndDirOK,
|
||||
OptoNok,
|
||||
DirNok,
|
||||
Count
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,17 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class MeasurementCorrection
|
||||
public class MeasurementCorrection : Common.IMeasurementCorrection, IComparable<MeasurementCorrection>
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int RangeIx { get; set; } /// 0..5
|
||||
public virtual float Measurement { get; set; }
|
||||
public virtual float Correction { get; set; }
|
||||
public virtual double Measurement { get; set; }
|
||||
public virtual double Correction { get; set; }
|
||||
|
||||
public MeasurementCorrection()
|
||||
{
|
||||
@ -21,5 +22,68 @@ namespace Config.Entities
|
||||
{
|
||||
RangeIx = rangeIx;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int CompareTo(MeasurementCorrection other)
|
||||
{
|
||||
return (Measurement > other.Measurement) ? 1 : ((Measurement == other.Measurement) ? 0 : -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates corrected value from a list of corrections by interpolation.
|
||||
/// It is assumed that values in the list 'corrections' are sorted.
|
||||
/// </summary>
|
||||
/// <param name="rawMeasurement">Raw uncorrected value</param>
|
||||
/// <param name="corrections">Sorted (value, correction) pairs</param>
|
||||
/// <returns>Corrected value</returns>
|
||||
public static double CorrectedValue(double rawValue, IList<MeasurementCorrection> corrections)
|
||||
{
|
||||
return rawValue + GetCorrection(rawValue, corrections);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a correction from a list of corrections by interpolation.
|
||||
/// It is assumed that values in the list 'corrections' are sorted.
|
||||
/// </summary>
|
||||
/// <param name="rawMeasurement">Raw uncorrected value</param>
|
||||
/// <param name="corrections">Sorted (value, correction) pairs</param>
|
||||
/// <returns>Corrected value</returns>
|
||||
public static double GetCorrection(double rawValue, IList<MeasurementCorrection> corrections)
|
||||
{
|
||||
if ((corrections == null) || (corrections.Count == 0)) return 0; /// No correction
|
||||
|
||||
if (rawValue < corrections[0].Measurement)
|
||||
{
|
||||
/// rawValue is below the lowest value in the correction table
|
||||
return corrections[0].Correction;
|
||||
}
|
||||
|
||||
for (int i = 1; i < corrections.Count; i++)
|
||||
{
|
||||
if (rawValue < corrections[i].Measurement)
|
||||
{
|
||||
double d1 = rawValue - corrections[i - 1].Measurement;
|
||||
double d2 = corrections[i].Measurement - rawValue;
|
||||
|
||||
if (d1 + d2 <= float.Epsilon)
|
||||
{
|
||||
/// Neigboring values in the corection table are close to each other -> calculate the average
|
||||
return (corrections[i - 1].Correction + corrections[i].Correction) / 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Interpolate the correction from neigboring values in the corection table
|
||||
return (corrections[i - 1].Correction * d2 + corrections[i].Correction * d1) / (d1 + d2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// rawValue is above the highest value in the correction table
|
||||
return corrections[corrections.Count - 1].Correction;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1} ({2})", Measurement, Correction, RangeIx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,39 +1,45 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class OutputPath : IHasName, IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string OriName { get; set; } /// Not mapped to database
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in UI
|
||||
public virtual string Selector { get; set; }
|
||||
public virtual string RegulValve { get; set; }
|
||||
public virtual string FlowMeter { get; set; }
|
||||
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
|
||||
public virtual float PidCoef { get; set; } /// PID coefficient for the regulation path
|
||||
public virtual string StartValve { get; set; }
|
||||
public virtual string Diverter { get; set; }
|
||||
public virtual string TempDiv { get; set; }
|
||||
public virtual string Scale { get; set; }
|
||||
public virtual string EmptyTankValve { get; set; } /// Not used anywhere
|
||||
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
|
||||
|
||||
/// Valves
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public OutputPath()
|
||||
{
|
||||
ValvesOpen = string.Empty;
|
||||
ValvesClose = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public OutputPath(string name, int itemNr)
|
||||
: this()
|
||||
@ -46,19 +52,21 @@ namespace Config.Entities
|
||||
{
|
||||
OutputPath result = new OutputPath(name, itemNr);
|
||||
|
||||
result.Name = Name;
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.RegulValve = RegulValve;
|
||||
result.FlowMeter = FlowMeter;
|
||||
result.PidCoef = PidCoef;
|
||||
result.StartValve = StartValve;
|
||||
result.Diverter = Diverter;
|
||||
result.TempDiv = TempDiv;
|
||||
result.Scale = Scale;
|
||||
result.EmptyTankValve = EmptyTankValve;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
result.Name = Name;
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.Selector = Selector;
|
||||
result.RegulValve = RegulValve;
|
||||
result.FlowMeter = FlowMeter;
|
||||
result.PidCoef = PidCoef;
|
||||
result.StartValve = StartValve;
|
||||
result.Diverter = Diverter;
|
||||
result.TempDiv = TempDiv;
|
||||
result.Scale = Scale;
|
||||
result.RegulValvesPct = RegulValvesPct;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -26,6 +27,7 @@ namespace Config.Entities
|
||||
public virtual double PressLimHi { get; set; } /// [bar] max. water pressure
|
||||
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
|
||||
public virtual bool Evaluate { get; set; }
|
||||
public virtual string Method { get; set; } /// Test method (component name)
|
||||
|
||||
public virtual sbyte E1 { get; set; } ///
|
||||
public virtual sbyte E2 { get; set; } ///
|
||||
@ -78,8 +80,9 @@ namespace Config.Entities
|
||||
TempLimHi = 25.0; /// [°C]
|
||||
PressLimLo = 0; /// [bar]
|
||||
PressLimHi = 16.0; /// [bar]
|
||||
Publish = (sbyte)Config.Entities.Publish.Always;
|
||||
Publish = (sbyte)Common.Publish.Always;
|
||||
Evaluate = true;
|
||||
Method = string.Empty;
|
||||
|
||||
E1 = (sbyte)ErrorFlagsMode.On;
|
||||
E2 = (sbyte)ErrorFlagsMode.On;
|
||||
@ -139,6 +142,7 @@ namespace Config.Entities
|
||||
result.PressLimHi = PressLimHi;
|
||||
result.Publish = Publish;
|
||||
result.Evaluate = Evaluate;
|
||||
result.Method = Method;
|
||||
|
||||
result.E1 = E1;
|
||||
result.E2 = E2;
|
||||
@ -192,6 +196,7 @@ namespace Config.Entities
|
||||
output.WriteLine(PressLimHi.ToString(ci));
|
||||
output.WriteLine(Publish.ToString());
|
||||
output.WriteLine(Evaluate.ToString());
|
||||
output.WriteLine(Method);
|
||||
|
||||
output.WriteLine(E1.ToString());
|
||||
output.WriteLine(E2.ToString());
|
||||
@ -246,10 +251,29 @@ namespace Config.Entities
|
||||
tst.ErrLimHi = double.Parse(input.ReadLine(), ci);
|
||||
tst.TempLimLo = double.Parse(input.ReadLine(), ci);
|
||||
tst.TempLimHi = double.Parse(input.ReadLine(), ci);
|
||||
tst.Publish = sbyte.Parse(input.ReadLine());
|
||||
tst.PressLimLo = double.Parse(input.ReadLine(), ci);
|
||||
tst.PressLimHi = double.Parse(input.ReadLine(), ci);
|
||||
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.Evaluate = bool.Parse(input.ReadLine());
|
||||
tst.Method = input.ReadLine();
|
||||
|
||||
/// TODO (E1 .. E21)
|
||||
tst.E1 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E2 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E3 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E4 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E5 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E6 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E7 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E8 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E9 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E10 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E11 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E12 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E13 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E14 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E15 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E16 = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.E21 = sbyte.Parse(input.ReadLine(), ci);
|
||||
|
||||
tst.Delta_Q_pct = double.Parse(input.ReadLine(), ci);
|
||||
tst.Delta_T = double.Parse(input.ReadLine(), ci);
|
||||
@ -292,6 +316,7 @@ namespace Config.Entities
|
||||
ln = inp.ReadLine(); if (ln != PressLimHi.ToString(ci)) { diff.AppendFormat(fmt, "Pressure_max", PressLimHi.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Publish.ToString()) { diff.AppendFormat(fmt, "Publish", Publish.ToString(), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Evaluate.ToString()) { diff.AppendFormat(fmt, "Evaluate", Evaluate.ToString(), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); };
|
||||
|
||||
ln = inp.ReadLine(); if (ln != E1.ToString()) { diff.AppendFormat(fmt, "E1", E1.ToString(), ln); };
|
||||
ln = inp.ReadLine(); if (ln != E2.ToString()) { diff.AppendFormat(fmt, "E2", E2.ToString(), ln); };
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores one test procedure, supports revisions and history log
|
||||
/// </summary>
|
||||
public class Procedure : IHasName, IHasItemNr
|
||||
public class Procedure : IHasName, IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
@ -46,21 +47,20 @@ namespace Config.Entities
|
||||
public virtual int AltProcPeriod { get; set; } /// Period of alternative procedures (0 = no alt. procedure)
|
||||
|
||||
public virtual float DN { get; set; } /// Not mapped to DB, valid in ProceduresCtrl for procedure filtering only
|
||||
public virtual float Qn { get; set; } /// - ' ' -
|
||||
public virtual double Qn { get; set; } /// - ' ' -
|
||||
public virtual string MClass { get; set; } /// - ' ' -
|
||||
public virtual string Producer { get; set; } /// - ' ' -
|
||||
|
||||
public virtual IList<ComponentProcedure> MoreParams { get; set; }
|
||||
public virtual IList<Test> Tests { get; set; }
|
||||
|
||||
TestInstance[] testInstances;
|
||||
|
||||
/// Wrapper
|
||||
public virtual IList<Test> RegularTests()
|
||||
{
|
||||
IList<Test> rslt = new List<Test>();
|
||||
foreach (var t in Tests)
|
||||
{
|
||||
if ((t.Name.Length > 0 && t.Name[0] != '[') || !t.Name.Contains("]")) rslt.Add(t);
|
||||
}
|
||||
foreach (var t in Tests) if (t.IsRegular()) rslt.Add(t);
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@ -70,15 +70,16 @@ namespace Config.Entities
|
||||
{
|
||||
MoreParams = new List<ComponentProcedure>();
|
||||
Tests = new List<Test>();
|
||||
testInstances = null;
|
||||
|
||||
///
|
||||
/// Default values
|
||||
///
|
||||
CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
|
||||
CreationUser = Users.CurrentUser.UserName();
|
||||
CreationTime = DateTime.Now;
|
||||
LastChgUser = CreationUser;
|
||||
LastChgTime = CreationTime;
|
||||
MetersKind = Entities.MetersKind.Single;
|
||||
MetersKind = MetersKind.Single;
|
||||
Watermeters = string.Empty;
|
||||
Description = string.Empty;
|
||||
LongDescription = string.Empty;
|
||||
@ -96,6 +97,70 @@ namespace Config.Entities
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual TestInstance[] UpdateTestInstances(IList<string> loopStartNames, IList<string> loopEndNames, IList<string> autoTests = null)
|
||||
{
|
||||
List<TestInstance> instances = new List<TestInstance>();
|
||||
|
||||
if (Tests != null)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < Tests.Count)
|
||||
{
|
||||
if (!loopStartNames.Contains(Tests[i].Method) && !loopEndNames.Contains(Tests[i].Method)) /// Loop.End is ignored outside a loop
|
||||
{
|
||||
///
|
||||
/// Outside a loop
|
||||
///
|
||||
for (int j = 1; j <= Tests[i].Repeats; j++)
|
||||
if (Tests[i].BelongsTo(autoTests))
|
||||
instances.Add(new TestInstance(Tests[i], j));
|
||||
}
|
||||
else if (loopStartNames.Contains(Tests[i].Method))
|
||||
{
|
||||
///
|
||||
/// Entering a loop
|
||||
///
|
||||
int loopsCount = Tests[i].Repeats;
|
||||
List<Test> testsInsideLoop = new List<Test>();
|
||||
i++;
|
||||
|
||||
while (i < Tests.Count && !loopEndNames.Contains(Tests[i].Method))
|
||||
{
|
||||
///
|
||||
/// Inside a loop
|
||||
///
|
||||
if (Tests[i].Repeats == loopsCount && !loopStartNames.Contains(Tests[i].Method)) /// Loop.Start is ignored inside a loop
|
||||
{
|
||||
if (Tests[i].BelongsTo(autoTests))
|
||||
testsInsideLoop.Add(Tests[i]);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
///
|
||||
/// Append instances of tests inside the last loop to the list
|
||||
///
|
||||
for (int j = 1; j <= loopsCount; j++)
|
||||
{
|
||||
foreach (var t in testsInsideLoop)
|
||||
instances.Add(new TestInstance(t, j));
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
testInstances = instances.ToArray();
|
||||
return testInstances;
|
||||
}
|
||||
|
||||
public virtual TestInstance[] GetTestInstances()
|
||||
{
|
||||
return testInstances;
|
||||
}
|
||||
|
||||
public virtual Procedure Clone()
|
||||
{
|
||||
Procedure result = new Procedure();
|
||||
|
||||
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -35,7 +36,7 @@ namespace Config.Entities
|
||||
///
|
||||
/// Default values
|
||||
///
|
||||
CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
|
||||
CreationUser = Users.CurrentUser.UserName();
|
||||
CreationTime = DateTime.Now;
|
||||
LastChgUser = CreationUser;
|
||||
LastChgTime = CreationTime;
|
||||
@ -77,6 +78,8 @@ namespace Config.Entities
|
||||
output.WriteLine(CreationTime.ToString(CultureInfo.InvariantCulture));
|
||||
output.WriteLine(LastChgUser);
|
||||
output.WriteLine(LastChgTime.ToString(CultureInfo.InvariantCulture));
|
||||
output.WriteLine(((sbyte)ProfileType).ToString());
|
||||
output.WriteLine(((sbyte)ErrorLimitType).ToString());
|
||||
|
||||
foreach (var test in Tests) { test.Export(output); }
|
||||
output.WriteLine();
|
||||
@ -95,7 +98,8 @@ namespace Config.Entities
|
||||
result.CreationTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
|
||||
result.LastChgUser = input.ReadLine();
|
||||
result.LastChgTime = DateTime.Parse(input.ReadLine(), CultureInfo.InvariantCulture);
|
||||
string line = input.ReadLine();
|
||||
result.ProfileType = (ProfileType)sbyte.Parse(input.ReadLine());
|
||||
result.ErrorLimitType = (ErrorLimitType)sbyte.Parse(input.ReadLine());
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Common;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
@ -21,11 +22,11 @@ namespace Config.Entities
|
||||
public virtual TestProfile Profile { get; set; } /// UserDefined, Protected, UserDefinedHeatMeter, ProtectedHeatMeter
|
||||
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
|
||||
public virtual bool DoEvaluate { get; set; }
|
||||
public virtual float Qtg { get; set; } /// Target water flow [m3/h]
|
||||
public virtual float Qfrom { get; set; } /// Water flow low limit in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow high limit in [m3/h]
|
||||
public virtual float Volume { get; set; } /// Test volume (target) in [l]
|
||||
public virtual float TstTime { get; set; } /// Test time (estimate) in [s]
|
||||
public virtual double Qtg { get; set; } /// Target water flow [m3/h]
|
||||
public virtual double Qfrom { get; set; } /// Water flow low limit in [m3/h]
|
||||
public virtual double Qto { get; set; } /// Water flow high limit in [m3/h]
|
||||
public virtual double Volume { get; set; } /// Test volume (target) in [l]
|
||||
public virtual double TestTime { get; set; } /// Test time (estimate) in [s]
|
||||
public virtual string Method { get; set; }
|
||||
public virtual float ErrLimLo { get; set; } /// in [%] usually < 0, in case of heat meters: 1=class1, 2=class2, 3=class3
|
||||
public virtual float ErrLimHi { get; set; } /// in [%] usually > 0, in case of heat meters: -Qn in m3/h
|
||||
@ -33,10 +34,10 @@ namespace Config.Entities
|
||||
public virtual int Repeats { get; set; }
|
||||
public virtual bool DoDraining { get; set; }
|
||||
public virtual bool DoDrainingAfter { get; set; }
|
||||
public virtual bool DoControlWaterTemp { get; set; }
|
||||
public virtual float TempLimLo { get; set; } /// Lower limit for the controlled temperature
|
||||
public virtual float TempLimHi { get; set; } /// Upper limit for the controlled temperature
|
||||
public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
|
||||
public virtual string TempControl { get; set; } /// Water temperature controller, null or empty = Do not control water temp
|
||||
public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps
|
||||
public virtual int MassRepeats { get; set; } /// Number of mass. measurements at the beginning/end of test, 0 = default (=5)
|
||||
public virtual float MassSpread { get; set; } /// Max spread of mass. measurements at the beginning/end of test, 0 = default
|
||||
public virtual MassMethod MassMethod { get; set; } /// method of mass. measurement at the beginning/end of test: false=slow (precise), true=using immediate mass measurement and evaluation
|
||||
@ -44,7 +45,7 @@ namespace Config.Entities
|
||||
public virtual int TimeFlow2Mass { get; set; } /// Delay time from the flow stable to the 1st mass measurement in [s]
|
||||
public virtual int TimePump2StartV { get; set; } /// Delay time from the start of the pump to opening the start valve in [s]
|
||||
public virtual int TimeStop2Mass { get; set; } /// Delay time from the test end (diverted) to the 2nd mass measuremen in [s]
|
||||
public virtual double TolerRed { get; set; } /// = Filter
|
||||
public virtual double ShortPulses { get; set; } /// = Filter
|
||||
public virtual string RedType { get; set; }
|
||||
public virtual string FeedingPath { get; set; }
|
||||
public virtual string BenchPath { get; set; }
|
||||
@ -53,12 +54,32 @@ namespace Config.Entities
|
||||
#if HEAT_METERS
|
||||
public virtual string HeatMetersPath { get; set; }
|
||||
#endif
|
||||
public virtual string RelTransBefore { get; set; }
|
||||
public virtual string RelTransBetween { get; set; }
|
||||
public virtual string TransitionAfter { get; set; }
|
||||
public virtual string TransBefore { get; set; }
|
||||
public virtual string TransBetween { get; set; }
|
||||
public virtual string TransAfter { get; set; }
|
||||
#if ORACLE_DB
|
||||
public virtual int OraId { get; set; }
|
||||
public virtual int OraIdRepetMulti { get; set; }
|
||||
public virtual string OraDesignation { get; set; }
|
||||
public virtual int RawDataId { get; set; }
|
||||
public virtual int RawDataIdRepetMulti { get; set; }
|
||||
public virtual string RawDataDesignation { get; set; }
|
||||
#endif
|
||||
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
|
||||
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
|
||||
|
||||
public virtual bool IsOuterLoopStart { get; set; } /// Not mapped to database
|
||||
public virtual bool IsOuterLoopEnd { get; set; } /// Not mapped to database
|
||||
public virtual bool QtgTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QfromTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool QtoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool VolumeTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool TempLimLoTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual bool TempLimHiTextChngd { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit VolumeUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit FlowUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit MassUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit TempUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit PressUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
public virtual Unit LengthUnit { get; set; } /// Not mapped to database, used in ProcedureDlg / Metrology1Tab
|
||||
|
||||
public virtual IList<ComponentTest> MoreParams { get; set; }
|
||||
|
||||
@ -75,30 +96,38 @@ namespace Config.Entities
|
||||
///
|
||||
Part = 0;
|
||||
Profile = TestProfile.UserDefined;
|
||||
Publish = (sbyte)Config.Entities.Publish.Always;
|
||||
Publish = (sbyte)Common.Publish.Always;
|
||||
DoEvaluate = true;
|
||||
Repeats = 1;
|
||||
ErrLimLo = -2.0f; /// [%] lower error limit
|
||||
ErrLimHi = 2.0f; /// [%] upper error limit
|
||||
Uncertainty = 0;
|
||||
Repeats = 1;
|
||||
DoDraining = false;
|
||||
DoDrainingAfter = false;
|
||||
DoControlWaterTemp = false;
|
||||
TempLimLo = 15.0f;
|
||||
TempLimHi = 25.0f;
|
||||
ErrLimLo = -2.0f; /// [%] lower error limit
|
||||
ErrLimHi = 2.0f; /// [%] upper error limit
|
||||
Uncertainty = 0;
|
||||
TempControl = string.Empty;
|
||||
PumpPower = 60.0f; /// [%]
|
||||
MassRepeats = 0; /// default
|
||||
MassSpread = 0; /// default
|
||||
MassMethod = MassMethod.Scale; /// default
|
||||
MassMethod = MassMethod.Scale; /// default
|
||||
TimeBeforeFlow = 10; /// [s] time before the start of flow control in [s]
|
||||
TimeFlow2Mass = 5; /// [s] time from the flow stable to the 1st mass measurement in [s]
|
||||
TimePump2StartV = 1; /// [s] time from the 1st mass measurement to the test start in [s]
|
||||
TimeStop2Mass = 5; /// [s] between the test end and the final mass measurement
|
||||
TolerRed = 0; /// = Filter parameter
|
||||
RelTransBefore = string.Empty;
|
||||
RelTransBetween = string.Empty;
|
||||
TransitionAfter = string.Empty;
|
||||
}
|
||||
ShortPulses = 0; /// Short pulses parameter (0 or 1)
|
||||
TransBefore = string.Empty;
|
||||
TransBetween = string.Empty;
|
||||
TransAfter = string.Empty;
|
||||
#if ORACLE_DB
|
||||
OraId = 0;
|
||||
OraIdRepetMulti = 0;
|
||||
OraDesignation = string.Empty;
|
||||
RawDataId = 0;
|
||||
RawDataIdRepetMulti = 0;
|
||||
RawDataDesignation = string.Empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
public Test(string name, int itemNr, Procedure procedure)
|
||||
: this()
|
||||
@ -108,6 +137,32 @@ namespace Config.Entities
|
||||
Procedure = procedure;
|
||||
}
|
||||
|
||||
public virtual bool IsRegular()
|
||||
{
|
||||
/// Irregular / event triggered test names have form "[event] TestName"
|
||||
return (Name.Length > 0 && Name[0] != '[') || !Name.Contains("]");
|
||||
}
|
||||
|
||||
public virtual bool BelongsTo(IList<string> autoTests)
|
||||
{
|
||||
if (IsRegular()) return true;
|
||||
|
||||
if (autoTests == null) return false;
|
||||
|
||||
string action = Name.Substring(1, Name.IndexOf(']') - 1);
|
||||
return autoTests.Contains(action);
|
||||
}
|
||||
|
||||
public virtual void ResetChngdFlags()
|
||||
{
|
||||
QtgTextChngd = false;
|
||||
QfromTextChngd = false;
|
||||
QtoTextChngd = false;
|
||||
VolumeTextChngd = false;
|
||||
TempLimLoTextChngd = false;
|
||||
TempLimHiTextChngd = false;
|
||||
}
|
||||
|
||||
// Makes a new copy of this object (not just a reference)
|
||||
public virtual Test Clone()
|
||||
{
|
||||
@ -121,7 +176,7 @@ namespace Config.Entities
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.Volume = Volume;
|
||||
result.TstTime = TstTime;
|
||||
result.TestTime = TestTime;
|
||||
result.Method = Method;
|
||||
result.ErrLimLo = ErrLimLo;
|
||||
result.ErrLimHi = ErrLimHi;
|
||||
@ -129,10 +184,10 @@ namespace Config.Entities
|
||||
result.Repeats = Repeats;
|
||||
result.DoDraining = DoDraining;
|
||||
result.DoDrainingAfter = DoDrainingAfter;
|
||||
result.DoControlWaterTemp = DoControlWaterTemp;
|
||||
result.TempLimLo = TempLimLo;
|
||||
result.TempLimHi = TempLimHi;
|
||||
result.PumpPower = PumpPower;
|
||||
result.TempControl = TempControl;
|
||||
result.PumpPower = PumpPower;
|
||||
result.MassRepeats = MassRepeats;
|
||||
result.MassSpread = MassSpread;
|
||||
result.MassMethod = MassMethod;
|
||||
@ -140,7 +195,7 @@ namespace Config.Entities
|
||||
result.TimeFlow2Mass = TimeFlow2Mass;
|
||||
result.TimePump2StartV = TimePump2StartV;
|
||||
result.TimeStop2Mass = TimeStop2Mass;
|
||||
result.TolerRed = TolerRed;
|
||||
result.ShortPulses = ShortPulses;
|
||||
result.RedType = RedType;
|
||||
result.FeedingPath = FeedingPath;
|
||||
result.BenchPath = BenchPath;
|
||||
@ -149,10 +204,24 @@ namespace Config.Entities
|
||||
#if HEAT_METERS
|
||||
result.HeatMetersPath = HeatMetersPath;
|
||||
#endif
|
||||
result.RelTransBefore = RelTransBefore;
|
||||
result.RelTransBetween = RelTransBetween;
|
||||
result.TransitionAfter = TransitionAfter;
|
||||
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
|
||||
result.TransBefore = TransBefore;
|
||||
result.TransBetween = TransBetween;
|
||||
result.TransAfter = TransAfter;
|
||||
#if ORACLE_DB
|
||||
result.OraId = OraId;
|
||||
result.OraIdRepetMulti = OraIdRepetMulti;
|
||||
result.OraDesignation = OraDesignation;
|
||||
result.RawDataId = RawDataId;
|
||||
result.RawDataIdRepetMulti = RawDataIdRepetMulti;
|
||||
result.RawDataDesignation = RawDataDesignation;
|
||||
#endif
|
||||
result.VolumeUnit = VolumeUnit;
|
||||
result.FlowUnit = FlowUnit;
|
||||
result.MassUnit = MassUnit;
|
||||
result.TempUnit = TempUnit;
|
||||
result.PressUnit = PressUnit;
|
||||
result.LengthUnit = LengthUnit;
|
||||
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -169,7 +238,7 @@ namespace Config.Entities
|
||||
output.WriteLine(Qfrom.ToString(ci));
|
||||
output.WriteLine(Qto.ToString(ci));
|
||||
output.WriteLine(Volume.ToString(ci));
|
||||
output.WriteLine(TstTime.ToString(ci));
|
||||
output.WriteLine(TestTime.ToString(ci));
|
||||
output.WriteLine(Method);
|
||||
output.WriteLine(ErrLimLo.ToString(ci));
|
||||
output.WriteLine(ErrLimHi.ToString(ci));
|
||||
@ -177,10 +246,10 @@ namespace Config.Entities
|
||||
output.WriteLine(Repeats.ToString(ci));
|
||||
output.WriteLine(DoDraining.ToString());
|
||||
output.WriteLine(DoDrainingAfter.ToString());
|
||||
output.WriteLine(DoControlWaterTemp.ToString());
|
||||
output.WriteLine(TempLimLo.ToString(ci));
|
||||
output.WriteLine(TempLimHi.ToString(ci));
|
||||
output.WriteLine(PumpPower.ToString(ci));
|
||||
output.WriteLine((TempControl != null) ? TempControl : string.Empty);
|
||||
output.WriteLine(PumpPower.ToString(ci));
|
||||
output.WriteLine(MassRepeats.ToString(ci));
|
||||
output.WriteLine(MassSpread.ToString(ci));
|
||||
output.WriteLine(((byte)MassMethod).ToString(ci));
|
||||
@ -192,11 +261,18 @@ namespace Config.Entities
|
||||
output.WriteLine(BenchPath);
|
||||
output.WriteLine(OutputPath);
|
||||
output.WriteLine(MetersPath);
|
||||
output.WriteLine(RelTransBefore);
|
||||
output.WriteLine(RelTransBetween);
|
||||
output.WriteLine(TransBefore);
|
||||
output.WriteLine(TransBetween);
|
||||
output.WriteLine(Profile);
|
||||
output.WriteLine(TransitionAfter);
|
||||
|
||||
output.WriteLine(TransAfter);
|
||||
#if ORACLE_DB
|
||||
output.WriteLine(OraId);
|
||||
output.WriteLine(OraIdRepetMulti);
|
||||
output.WriteLine(OraDesignation);
|
||||
output.WriteLine(RawDataId);
|
||||
output.WriteLine(RawDataIdRepetMulti);
|
||||
output.WriteLine(RawDataDesignation);
|
||||
#endif
|
||||
foreach (var prms in MoreParams) { prms.Export(output); }
|
||||
output.WriteLine();
|
||||
}
|
||||
@ -216,11 +292,11 @@ namespace Config.Entities
|
||||
tst.Part = int.Parse(input.ReadLine(), ci);
|
||||
tst.Publish = sbyte.Parse(input.ReadLine(), ci);
|
||||
tst.DoEvaluate = bool.Parse(input.ReadLine());
|
||||
tst.Qtg = float.Parse(input.ReadLine(), ci);
|
||||
tst.Qfrom = float.Parse(input.ReadLine(), ci);
|
||||
tst.Qto = float.Parse(input.ReadLine(), ci);
|
||||
tst.Volume = float.Parse(input.ReadLine(), ci);
|
||||
tst.TstTime = float.Parse(input.ReadLine(), ci);
|
||||
tst.Qtg = double.Parse(input.ReadLine(), ci);
|
||||
tst.Qfrom = double.Parse(input.ReadLine(), ci);
|
||||
tst.Qto = double.Parse(input.ReadLine(), ci);
|
||||
tst.Volume = double.Parse(input.ReadLine(), ci);
|
||||
tst.TestTime = double.Parse(input.ReadLine(), ci);
|
||||
tst.Method = input.ReadLine();
|
||||
tst.ErrLimLo = float.Parse(input.ReadLine(), ci);
|
||||
tst.ErrLimHi = float.Parse(input.ReadLine(), ci);
|
||||
@ -228,10 +304,10 @@ namespace Config.Entities
|
||||
tst.Repeats = int.Parse(input.ReadLine(), ci);
|
||||
tst.DoDraining = bool.Parse(input.ReadLine());
|
||||
tst.DoDrainingAfter = bool.Parse(input.ReadLine());
|
||||
tst.DoControlWaterTemp = bool.Parse(input.ReadLine());
|
||||
tst.TempLimLo = float.Parse(input.ReadLine(), ci);
|
||||
tst.TempLimHi = float.Parse(input.ReadLine(), ci);
|
||||
tst.PumpPower = float.Parse(input.ReadLine(), ci);
|
||||
tst.TempControl = input.ReadLine();
|
||||
tst.PumpPower = float.Parse(input.ReadLine(), ci);
|
||||
tst.MassRepeats = int.Parse(input.ReadLine(), ci);
|
||||
tst.MassSpread = float.Parse(input.ReadLine(), ci);
|
||||
tst.MassMethod = (MassMethod)byte.Parse(input.ReadLine(), ci);
|
||||
@ -243,13 +319,21 @@ namespace Config.Entities
|
||||
tst.BenchPath = input.ReadLine();
|
||||
tst.OutputPath = input.ReadLine();
|
||||
tst.MetersPath = input.ReadLine();
|
||||
tst.RelTransBefore = input.ReadLine();
|
||||
tst.RelTransBetween = input.ReadLine();
|
||||
tst.TransBefore = input.ReadLine();
|
||||
tst.TransBetween = input.ReadLine();
|
||||
string line = input.ReadLine();
|
||||
tst.Profile = line.Equals(TestProfile.ProtectedHeatMeter.ToString()) ? TestProfile.ProtectedHeatMeter
|
||||
: line.Equals(TestProfile.UserDefinedHeatMeter.ToString()) ? TestProfile.UserDefinedHeatMeter
|
||||
: line.Equals(TestProfile.Protected.ToString()) ? TestProfile.Protected : TestProfile.UserDefined; /// UserDefined is the default
|
||||
tst.TransitionAfter = input.ReadLine();
|
||||
tst.TransAfter = input.ReadLine();
|
||||
#if ORACLE_DB
|
||||
tst.OraId = int.Parse(input.ReadLine(), ci);
|
||||
tst.OraIdRepetMulti = int.Parse(input.ReadLine(), ci);
|
||||
tst.OraDesignation = input.ReadLine();
|
||||
tst.RawDataId = int.Parse(input.ReadLine(), ci);
|
||||
tst.RawDataIdRepetMulti = int.Parse(input.ReadLine(), ci);
|
||||
tst.RawDataDesignation = input.ReadLine();
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -282,7 +366,7 @@ namespace Config.Entities
|
||||
ln = inp.ReadLine(); if (ln != Qfrom.ToString(ci)) { diff.AppendFormat(fmt, "Qfrom", Qfrom.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Qto.ToString(ci)) { diff.AppendFormat(fmt, "Qto", Qto.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Volume.ToString(ci)) { diff.AppendFormat(fmt, "Volume", Volume.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != TstTime.ToString(ci)) { diff.AppendFormat(fmt, "TstTime", TstTime.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != TestTime.ToString(ci)) { diff.AppendFormat(fmt, "TstTime", TestTime.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != Method) { diff.AppendFormat(fmt, "Method", Method, ln); };
|
||||
ln = inp.ReadLine(); if (ln != ErrLimLo.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimLo", ErrLimLo.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != ErrLimHi.ToString(ci)) { diff.AppendFormat(fmt, "ErrLimHi", ErrLimHi.ToString(ci), ln); };
|
||||
@ -290,9 +374,9 @@ namespace Config.Entities
|
||||
ln = inp.ReadLine(); if (ln != Repeats.ToString(ci)) { diff.AppendFormat(fmt, "Repeats", Repeats.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != DoDraining.ToString(ci)) { diff.AppendFormat(fmt, "Draining", DoDraining.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != DoDrainingAfter.ToString(ci)) { diff.AppendFormat(fmt, "Zeroing", DoDrainingAfter.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != DoControlWaterTemp.ToString()) { diff.AppendFormat(fmt, "DoControlWaterTemp", DoControlWaterTemp.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != TempLimLo.ToString(ci)) { diff.AppendFormat(fmt, "TempLimLo", TempLimLo.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != TempLimHi.ToString(ci)) { diff.AppendFormat(fmt, "TempLimHi", TempLimHi.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != TempControl) { diff.AppendFormat(fmt, "TempController", TempControl, ln); };
|
||||
ln = inp.ReadLine(); if (ln != PumpPower.ToString(ci)) { diff.AppendFormat(fmt, "PumpPower", PumpPower.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != MassRepeats.ToString(ci)) { diff.AppendFormat(fmt, "MassRepeats", MassRepeats.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != MassSpread.ToString(ci)) { diff.AppendFormat(fmt, "MassSpread", MassSpread.ToString(ci), ln); };
|
||||
@ -305,11 +389,18 @@ namespace Config.Entities
|
||||
ln = inp.ReadLine(); if (ln != BenchPath) { diff.AppendFormat(fmt, "BenchPath", BenchPath, ln); };
|
||||
ln = inp.ReadLine(); if (ln != OutputPath) { diff.AppendFormat(fmt, "OutputPath", OutputPath, ln); };
|
||||
ln = inp.ReadLine(); if (ln != MetersPath) { diff.AppendFormat(fmt, "MetersPath", MetersPath, ln); };
|
||||
ln = inp.ReadLine(); if (ln != RelTransBefore) { diff.AppendFormat(fmt, "RelTransBefore", RelTransBefore, ln); };
|
||||
ln = inp.ReadLine(); if (ln != RelTransBetween) { diff.AppendFormat(fmt, "RelTransBetween", RelTransBetween, ln); };
|
||||
ln = inp.ReadLine(); if (ln != Profile.ToString()) { diff.AppendFormat(fmt, "RelTransAfter", Profile, ln); };
|
||||
ln = inp.ReadLine(); if (ln != TransitionAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransitionAfter, ln); };
|
||||
|
||||
ln = inp.ReadLine(); if (ln != TransBefore) { diff.AppendFormat(fmt, "RelTransBefore", TransBefore, ln); };
|
||||
ln = inp.ReadLine(); if (ln != TransBetween) { diff.AppendFormat(fmt, "RelTransBetween", TransBetween, ln); };
|
||||
ln = inp.ReadLine(); if (ln != Profile.ToString()) { diff.AppendFormat(fmt, "RelTransAfter", Profile, ln); };
|
||||
ln = inp.ReadLine(); if (ln != TransAfter) { diff.AppendFormat(fmt, "TransitionAfter", TransAfter, ln); };
|
||||
#if ORACLE_DB
|
||||
ln = inp.ReadLine(); if (ln != OraId.ToString(ci)) { diff.AppendFormat(fmt, "OraId", OraId.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != OraIdRepetMulti.ToString(ci)) { diff.AppendFormat(fmt, "OraIdRepetMulti", OraIdRepetMulti.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != OraDesignation) { diff.AppendFormat(fmt, "OraDesignation", OraDesignation, ln); };
|
||||
ln = inp.ReadLine(); if (ln != RawDataId.ToString(ci)) { diff.AppendFormat(fmt, "RawDataId", RawDataId.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != RawDataIdRepetMulti.ToString(ci)){ diff.AppendFormat(fmt, "RawDataIdRepetMulti", RawDataIdRepetMulti.ToString(ci), ln); };
|
||||
ln = inp.ReadLine(); if (ln != RawDataDesignation) { diff.AppendFormat(fmt, "RawDataDesignation", RawDataDesignation, ln); };
|
||||
#endif
|
||||
return diff.ToString();
|
||||
}
|
||||
|
||||
@ -409,29 +500,6 @@ namespace Config.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether tests part number is OK.
|
||||
/// Examples of correct part number are:
|
||||
/// 1, 2, 12, 21 in case of max. part nr.== 2
|
||||
/// 1, 2, 3, 4, 12, 13, 14, 23, 24, 34, 123, 124, 134, 234, 1234 in case of max. part nr.== 4
|
||||
/// </summary>
|
||||
/// <param name="partNr">Tests par tnumber</param>
|
||||
/// <returns>true when Part number is OK</returns>
|
||||
public static bool IsGoodPartNr(int partNr)
|
||||
{
|
||||
bool firstDigitIsOK = ((partNr % 10) > 0) && ((partNr % 10) <= Config.Data.MaxPartNr);
|
||||
bool secondDigitIsOK = (((partNr/10) % 10) > 0) && (((partNr/10) % 10) <= Config.Data.MaxPartNr);
|
||||
bool thirdDigitIsOK = (((partNr/100) % 10) > 0) && (((partNr/100) % 10) <= Config.Data.MaxPartNr);
|
||||
bool fourthDigitIsOK = (((partNr/1000) % 10) > 0) && (((partNr/1000) % 10) <= Config.Data.MaxPartNr);
|
||||
|
||||
if (firstDigitIsOK && (partNr / 10 == 0)) return true;
|
||||
if (firstDigitIsOK && secondDigitIsOK && (partNr / 100 == 0)) return true;
|
||||
if (firstDigitIsOK && secondDigitIsOK && thirdDigitIsOK && (partNr / 1000 == 0)) return true;
|
||||
if (firstDigitIsOK && secondDigitIsOK && thirdDigitIsOK && fourthDigitIsOK && (partNr / 10000 == 0)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string partStr = (Part > 0) ? string.Format(", part {0}", Part) : string.Empty;
|
||||
|
||||
32
Config/Entities/TestInstance.cs
Normal file
32
Config/Entities/TestInstance.cs
Normal file
@ -0,0 +1,32 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class TestInstance
|
||||
{
|
||||
public Test Test;
|
||||
public int Repetition;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Test != null) ? Common.Utils.GetTestName(Test.Name, Test.Repeats, Repetition) : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public TestInstance(Test test, int repetition)
|
||||
{
|
||||
Test = test;
|
||||
Repetition = repetition;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class Uncertainty
|
||||
public class Uncertainty : Common.IUncertainty
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual float Measurement { get; set; }
|
||||
|
||||
@ -1,193 +1,10 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using Config.Resources;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
public static class FluentCommon
|
||||
{
|
||||
/// <summary>
|
||||
/// Session factories for regular sessions.
|
||||
/// </summary>
|
||||
public static ISessionFactory[] SessionFactories = new ISessionFactory[(int)Users.Entities.DBKind.Count];
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
static ISessionFactory CreateSessionFactory(Users.Entities.DBKind database)
|
||||
{
|
||||
Users.Entities.DBType dbType;
|
||||
string connectionString;
|
||||
|
||||
switch (database)
|
||||
{
|
||||
default:
|
||||
case Users.Entities.DBKind.Config:
|
||||
dbType = Data.CurrentBench.ProceduresDBSettings.DbType;
|
||||
connectionString = Data.CurrentBench.ProceduresDBSettings.ConnectionString;
|
||||
break;
|
||||
case Users.Entities.DBKind.Results:
|
||||
dbType = Data.CurrentBench.WaterMetersDBSettings.DbType;
|
||||
connectionString = Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
|
||||
break;
|
||||
case Users.Entities.DBKind.RemoteConfig:
|
||||
dbType = Data.CurrentBench.UsersDBSettings.DbType;
|
||||
connectionString = Data.CurrentBench.UsersDBSettings.ConnectionString;
|
||||
break;
|
||||
}
|
||||
|
||||
return CreateSessionFactory(database, dbType, connectionString, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
public static ISessionFactory CreateSessionFactory(Users.Entities.DBKind database, Users.Entities.DBType dbType, string connectionString, bool createDB)
|
||||
{
|
||||
try
|
||||
{
|
||||
FluentConfiguration cfg = Fluently.Configure();
|
||||
|
||||
switch (dbType)
|
||||
{
|
||||
default:
|
||||
case Users.Entities.DBType.SQLite:
|
||||
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
|
||||
break;
|
||||
case Users.Entities.DBType.MySql:
|
||||
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (database)
|
||||
{
|
||||
default:
|
||||
case Users.Entities.DBKind.Config:
|
||||
case Users.Entities.DBKind.RemoteConfig:
|
||||
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
|
||||
break;
|
||||
case Users.Entities.DBKind.Results:
|
||||
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
|
||||
break;
|
||||
}
|
||||
|
||||
if (createDB)
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageBox.Show(string.Format(Strings.Cannot_open_DB_Cause_0, exc.Message),
|
||||
Strings.Error,
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void BuildSchemaDlgt(Configuration config);
|
||||
|
||||
static void BuildSchema(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).SetOutputFile("db_schema");
|
||||
}
|
||||
|
||||
static void BuildSchemaCreate(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).Create(true, true);
|
||||
}
|
||||
|
||||
/// Create a NHibernate session for the given database
|
||||
public static ISession CreateSession(Users.Entities.DBKind database)
|
||||
{
|
||||
if (database < 0 || database >= Users.Entities.DBKind.Count) return null;
|
||||
|
||||
int ix = (int)database;
|
||||
if (SessionFactories[ix] == null) SessionFactories[ix] = CreateSessionFactory(database);
|
||||
|
||||
return SessionFactories[ix].OpenSession();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty users database.
|
||||
/// Database contains only the user 'admin' and the control board component 'CB'.
|
||||
/// </summary>
|
||||
/// <param name="dbType">DBType.SQLite or DBType.MySql</param>
|
||||
/// <param name="connectionString">Connection string</param>
|
||||
/// <returns>true=success, false=error</returns>
|
||||
public static bool CreateEmptyConfigDB(Users.Entities.DBType dbType, string connectionString)
|
||||
{
|
||||
ISessionFactory sessionFactory = CreateSessionFactory(Users.Entities.DBKind.Config, dbType, connectionString, true);
|
||||
if (sessionFactory == null) return false;
|
||||
|
||||
/// Populate the database
|
||||
using (var session = sessionFactory.OpenSession())
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
///
|
||||
/// Create user 'admin'
|
||||
///
|
||||
var admin = new Config.Entities.User
|
||||
{
|
||||
UserName = Data.AdminUsername,
|
||||
FullName = Strings.Administrator,
|
||||
LastPwChange = DateTime.Now
|
||||
};
|
||||
admin.SetPassword(Data.AdminPassword);
|
||||
|
||||
///
|
||||
/// Prepare all groups, add some of them to admin
|
||||
///
|
||||
for (Users.Entities.GID gid = 0; gid < Users.Entities.GID.NrOfGroups; gid++)
|
||||
{
|
||||
Config.Entities.Group group = new Config.Entities.Group(gid);
|
||||
switch (gid)
|
||||
{
|
||||
case Users.Entities.GID.Testers:
|
||||
case Users.Entities.GID.TestingSpecialists:
|
||||
case Users.Entities.GID.HeadOfLab:
|
||||
case Users.Entities.GID.MaintenanceSpecialists:
|
||||
case Users.Entities.GID.Metrologists:
|
||||
case Users.Entities.GID.CalibrationSpecialists:
|
||||
case Users.Entities.GID.Administrators:
|
||||
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
|
||||
case Users.Entities.GID.TraceabilityManagement:
|
||||
#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END
|
||||
case Users.Entities.GID.MetrologicalAuthority:
|
||||
case Users.Entities.GID.WaterMeterAuthority:
|
||||
#endif
|
||||
admin.AddGroup(group);
|
||||
session.SaveOrUpdate(group); /// Save this group
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
session.SaveOrUpdate(admin); /// Save user 'admin'
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Common;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
@ -182,7 +183,7 @@ namespace Config
|
||||
double theta = temp / 100.0;
|
||||
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
|
||||
|
||||
return WaterDensityFromTemp(temp) * (1 + B * Config.Units.ConvertTo(Config.Unit.Pa, pressure));
|
||||
return WaterDensityFromTemp(temp) * (1 + B * Units.ConvertTo(Unit.Pa, pressure));
|
||||
}
|
||||
|
||||
|
||||
@ -213,9 +214,9 @@ namespace Config
|
||||
/// </summary>
|
||||
public static double ErrorFromVolumes(double measuredVolume, double trueVolume)
|
||||
{
|
||||
if (trueVolume <= float.Epsilon)
|
||||
if (-float.Epsilon <= trueVolume && trueVolume <= float.Epsilon)
|
||||
{
|
||||
if (measuredVolume <= float.Epsilon)
|
||||
if (-float.Epsilon <= measuredVolume && measuredVolume <= float.Epsilon)
|
||||
{
|
||||
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, -100.0);
|
||||
return -100.0;
|
||||
@ -238,7 +239,7 @@ namespace Config
|
||||
/// <param name="rawMeasurement">Raw uncorrected value</param>
|
||||
/// <param name="corrections">Sorted (value, correction) pairs</param>
|
||||
/// <returns>Corrected value</returns>
|
||||
public static double CorrectedValue(double rawValue, IList<Config.Entities.MeasurementCorrection> corrections)
|
||||
public static double CorrectedValue(double rawValue, IList<IMeasurementCorrection> corrections)
|
||||
{
|
||||
return rawValue + GetCorrection(rawValue, corrections);
|
||||
}
|
||||
@ -250,7 +251,7 @@ namespace Config
|
||||
/// <param name="rawMeasurement">Raw uncorrected value</param>
|
||||
/// <param name="corrections">Sorted (value, correction) pairs</param>
|
||||
/// <returns>Corrected value</returns>
|
||||
public static double GetCorrection(double rawValue, IList<Config.Entities.MeasurementCorrection> corrections)
|
||||
public static double GetCorrection(double rawValue, IList<IMeasurementCorrection> corrections)
|
||||
{
|
||||
if ((corrections == null) || (corrections.Count == 0)) return 0; /// No correction
|
||||
|
||||
@ -316,11 +317,11 @@ namespace Config
|
||||
const double p_star_Pa = 16.53E6; /// [Pa] (=16.53 MPa)
|
||||
const double T_star = 1386.0; /// [K]
|
||||
|
||||
double T_in_K = Config.Units.ConvertTo(Config.Unit.K, T_in);
|
||||
double T_out_K = Config.Units.ConvertTo(Config.Unit.K, T_out);
|
||||
double T_in_K = Units.ConvertTo(Unit.K, T_in);
|
||||
double T_out_K = Units.ConvertTo(Unit.K, T_out);
|
||||
double tau_in = T_star / T_in_K;
|
||||
double tau_out = T_star / T_out_K;
|
||||
double pi = Config.Units.ConvertTo(Config.Unit.Pa, pressure) / p_star_Pa;
|
||||
double pi = Units.ConvertTo(Unit.Pa, pressure) / p_star_Pa;
|
||||
|
||||
double h_in = tau_in * GammaTau(pi, tau_in) * R * T_in_K;
|
||||
double h_out = tau_out * GammaTau(pi, tau_out) * R * T_out_K;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
@ -15,7 +15,8 @@ namespace Config.Mappings
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.TempMtrUp).Column("TempIn");
|
||||
Map(x => x.Selector);
|
||||
Map(x => x.TempMtrUp).Column("TempIn");
|
||||
Map(x => x.TempMtrDown).Column("TempOut");
|
||||
Map(x => x.PressMtrUp).Column("PressIn");
|
||||
Map(x => x.PressMtrDown).Column("PressOut");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
@ -15,7 +15,8 @@ namespace Config.Mappings
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Pump);
|
||||
Map(x => x.Selector);
|
||||
Map(x => x.Pump);
|
||||
Map(x => x.RegulValvesPct);
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
@ -15,7 +15,8 @@ namespace Config.Mappings
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.RegulValve);
|
||||
Map(x => x.Selector);
|
||||
Map(x => x.RegulValve);
|
||||
Map(x => x.FlowMeter);
|
||||
Map(x => x.PidCoef);
|
||||
Map(x => x.StartValve);
|
||||
@ -23,7 +24,8 @@ namespace Config.Mappings
|
||||
Map(x => x.TempDiv);
|
||||
Map(x => x.Scale)
|
||||
.Column("Balance");
|
||||
Map(x => x.EmptyTankValve);
|
||||
Map(x => x.RegulValvesPct)
|
||||
.Column("EmptyTankValve");
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
|
||||
@ -24,6 +24,7 @@ namespace Config.Mappings
|
||||
Map(x => x.PressLimHi);
|
||||
Map(x => x.Publish);
|
||||
Map(x => x.Evaluate);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.E1);
|
||||
Map(x => x.E2);
|
||||
Map(x => x.E3);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
@ -22,16 +22,17 @@ namespace Config.Mappings
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Volume);
|
||||
Map(x => x.TstTime);
|
||||
Map(x => x.TestTime)
|
||||
.Column("TstTime");
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.DoDraining)
|
||||
.Column("Emptying");
|
||||
Map(x => x.DoDrainingAfter)
|
||||
.Column("Zeroing");
|
||||
Map(x => x.DoControlWaterTemp);
|
||||
Map(x => x.TempLimLo);
|
||||
Map(x => x.TempLimHi);
|
||||
Map(x => x.PumpPower);
|
||||
Map(x => x.TempControl);
|
||||
Map(x => x.PumpPower);
|
||||
Map(x => x.MassRepeats);
|
||||
Map(x => x.MassSpread);
|
||||
Map(x => x.MassMethod)
|
||||
@ -45,7 +46,7 @@ namespace Config.Mappings
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
Map(x => x.TolerRed)
|
||||
Map(x => x.ShortPulses)
|
||||
.Column("TolerRed"); /// ???
|
||||
Map(x => x.RedType);
|
||||
Map(x => x.FeedingPath);
|
||||
@ -55,12 +56,20 @@ namespace Config.Mappings
|
||||
#if HEAT_METERS
|
||||
Map(x => x.HeatMetersPath);
|
||||
#endif
|
||||
Map(x => x.RelTransBefore)
|
||||
Map(x => x.TransBefore)
|
||||
.Column("RelTransBefore");
|
||||
Map(x => x.RelTransBetween)
|
||||
Map(x => x.TransBetween)
|
||||
.Column("RelTransBetween");
|
||||
Map(x => x.TransitionAfter)
|
||||
Map(x => x.TransAfter)
|
||||
.Column("TransitionAfter");
|
||||
#if ORACLE_DB
|
||||
Map(x => x.OraId);
|
||||
Map(x => x.OraIdRepetMulti);
|
||||
Map(x => x.OraDesignation);
|
||||
Map(x => x.RawDataId);
|
||||
Map(x => x.RawDataIdRepetMulti);
|
||||
Map(x => x.RawDataDesignation);
|
||||
#endif
|
||||
|
||||
HasMany(x => x.MoreParams)
|
||||
.Cascade.All();
|
||||
|
||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Sensus")]
|
||||
[assembly: AssemblyProduct("Config")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013 - 2018 Sensus Slovensko a.s.")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko a.s.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// 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("2.26.1458.0")]
|
||||
[assembly: AssemblyFileVersion("2.26.1458.0")]
|
||||
[assembly: AssemblyVersion("2.31.1990.0")]
|
||||
[assembly: AssemblyFileVersion("2.31.1990.0")]
|
||||
|
||||
@ -118,15 +118,15 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>NiO</value>
|
||||
<value>Nicht OK</value>
|
||||
</data>
|
||||
<data name="Passed" xml:space="preserve">
|
||||
<value>iO</value>
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>Fehler</value>
|
||||
</data>
|
||||
<data name="Cannot_open_DB_Cause_0" xml:space="preserve">
|
||||
<value>Datenbank kann nicht geöffnet.\\r\\nUrsache:\\r\\n{0}</value>
|
||||
<value>Datenbank kann nicht geöffnet werden.\\r\\nUrsache:\\r\\n{0}</value>
|
||||
</data>
|
||||
</root>
|
||||
491
Config/Units.cs
491
Config/Units.cs
@ -1,491 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2016-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
public enum Unit
|
||||
{
|
||||
[Description("---")] None,
|
||||
|
||||
[Description("imp.")] pulse,
|
||||
#if LANG_PL
|
||||
[Description("stopień")] degree,
|
||||
#else
|
||||
[Description("degree")] degree,
|
||||
#endif
|
||||
[Description("l")] l, /// * 1 liter
|
||||
[Description("dm3")] dm3, /// 1 dm3 = 1 liter
|
||||
[Description("m3")] m3, /// 1000 l
|
||||
[Description("gal(UK)")] gal_UK, /// 1 gal(UK) = 4.54609 l
|
||||
[Description("gal(US)")] gal_US, /// 1 gal(US) = 3.78541178 l
|
||||
|
||||
[Description("l/h")] lph, /// 1 liter/h
|
||||
[Description("m3/h")] m3ph, /// * 1 m3/h = 1000 l/h
|
||||
|
||||
[Description("g")] g, /// 0.001 kg
|
||||
[Description("kg")] kg, /// * 1 kilogram
|
||||
[Description("t")] t, /// 1000 kg
|
||||
[Description("lb")] lb, /// 0.45359237 kg
|
||||
|
||||
[Description("s")] s, /// * 1 second
|
||||
[Description("min")] min, /// 1 min = 60 s
|
||||
[Description("hr")] hour, /// 1 hour = 60 min = 3600 s
|
||||
[Description("ms")] ms, /// 1 ms = 0.001 s
|
||||
|
||||
[Description("°C")] C, /// * degree Celsius (°C)
|
||||
[Description("°F")] F, /// degree Fahrenheit
|
||||
[Description("K")] K, /// degree Kelvin
|
||||
|
||||
[Description("Pa")] Pa, /// 1 Pa = 0.01 hPa
|
||||
[Description("hPa")] hPa, /// 1 hPa = 100 Pa
|
||||
[Description("kPa")] kPa, /// 1 kPa = 10 HPa
|
||||
[Description("MPa")] MPa, /// 1 MPa = 10000 hPa
|
||||
[Description("mbar")] mbar, /// 1 mbar = 1 hPa = 100 Pa
|
||||
[Description("bar")] bar, /// * 1 Bar = 1000 mbar = 0.1 MPa = 100000 Pa
|
||||
[Description("inHg")] inHg, /// 1 inHg = 33.864 hPa
|
||||
|
||||
[Description("R%")] RPct, /// * 1 R%
|
||||
|
||||
[Description("%")] Pct, /// * 1 %
|
||||
[Description("promile")] Promile, /// 1 promile = 0.1 %
|
||||
|
||||
[Description("mm")] mm, /// * 1 millimeter
|
||||
[Description("cm")] cm, /// 1 cm = 10 mm
|
||||
[Description("m")] m, /// 1 m = 1000 mm
|
||||
[Description("in")] inch, /// 1 inch = 25.4 mm
|
||||
|
||||
[Description("kg/m3")] kgpm3, /// * 1 kg/m3 = 0.001 kg/l
|
||||
[Description("kg/l")] kgpl, /// 1 kg/l = 1000 kg/m3
|
||||
|
||||
[Description("J")] J, /// * 1 Joul
|
||||
[Description("kJ")] kJ, /// 1 kJ = 1000 J
|
||||
[Description("MJ")] MJ, /// 1 MJ = 1000000 J
|
||||
[Description("Wh")] Wh, /// 1 Wh = 3600 J
|
||||
[Description("kWh")] kWh, /// 1 kWh = 3600000 J
|
||||
[Description("MWh")] MWh, /// 1 MWh = 3600000000 J
|
||||
|
||||
[Description("uS/cm")] uSpcm, /// * 1 uS/cm
|
||||
|
||||
#if LANG_PL
|
||||
[Description("imp/l")] ppl, /// * 1 pulse/l
|
||||
[Description("imp/dm3")] ppdm3, /// * 1 pulse/dm3
|
||||
[Description("stopień/l")] degpl, /// * 1 degree/l
|
||||
[Description("stopień/dm3")] degpdm3, /// * 1 degree/dm3
|
||||
[Description("l/imp")] lpp, /// * 1 l/pulse
|
||||
[Description("dm3/imp")] dm3pp, /// * 1 dm3/pulse
|
||||
[Description("l/stopień")] lpdeg, /// * 1 l/degree
|
||||
[Description("dm3/stopień")] dm3pdeg, /// * 1 dm3/degree
|
||||
#else
|
||||
[Description("pulse/l")] ppl, /// * 1 pulse/l
|
||||
[Description("pulse/dm3")] ppdm3, /// * 1 pulse/dm3
|
||||
[Description("degree/l")] degpl, /// * 1 degree/l
|
||||
[Description("degree/dm3")] degpdm3, /// * 1 degree/dm3
|
||||
[Description("l/pulse")] lpp, /// * 1 l/pulse
|
||||
[Description("dm3/pulse")] dm3pp, /// * 1 dm3/pulse
|
||||
[Description("l/degree")] lpdeg, /// * 1 l/degree
|
||||
[Description("dm3/degree")] dm3pdeg, /// * 1 dm3/degree
|
||||
#endif
|
||||
///
|
||||
[Description("pulse/kWh")] ppkWh, /// * 1 pulse/kWh
|
||||
[Description("kWh/pulse")] kWhpp, /// * 1 kWh/pulse
|
||||
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Quantity
|
||||
{
|
||||
/// Quantities with units and conversions (double -> double)
|
||||
#if LANG_DE
|
||||
[Description("Volumen")] Volume,
|
||||
[Description("Durchfluss")] Flow,
|
||||
[Description("Masse")] Mass,
|
||||
[Description("Zeit")] Time,
|
||||
[Description("Temperatur")] Temperature,
|
||||
[Description("Druck")] Pressure,
|
||||
[Description("Feuchtigkeit")] Humidity,
|
||||
[Description("Fehler")] Error,
|
||||
[Description("Länge")] Length,
|
||||
[Description("Dichte")] Density,
|
||||
[Description("Energie")] Energy,
|
||||
[Description("Impulse")] Pulses,
|
||||
[Description("Impulse/l")] PulsePerLtr,
|
||||
[Description("Impulse/kWh")] PulsePerKWh,
|
||||
[Description("Leitfähigkeit")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Nummer")] Number,
|
||||
[Description("Text")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Datum und Uhrzeit")] DateTime,
|
||||
#elif LANG_PL
|
||||
[Description("Objętość")] Volume,
|
||||
[Description("Przepływ")] Flow,
|
||||
[Description("Masa")] Mass,
|
||||
[Description("Czas")] Time,
|
||||
[Description("Temperatura")] Temperature,
|
||||
[Description("Ciśnienie")] Pressure,
|
||||
[Description("Wilgotność")] Humidity,
|
||||
[Description("Błąd")] Error,
|
||||
[Description("Długość")] Length,
|
||||
[Description("Gęstość")] Density,
|
||||
[Description("Energia")] Energy,
|
||||
[Description("Impulsy")] Pulses,
|
||||
[Description("Impulsy/litr")] PulsePerLtr,
|
||||
[Description("Impulsy/kWh")] PulsePerKWh,
|
||||
[Description("Przewodność")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Numer")] Number,
|
||||
[Description("Tekst")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Data i czas")] DateTime,
|
||||
#elif LANG_CS
|
||||
[Description("Objem")] Volume,
|
||||
[Description("Průtok")] Flow,
|
||||
[Description("Hmotnost")] Mass,
|
||||
[Description("Čas")] Time,
|
||||
[Description("Teplota")] Temperature,
|
||||
[Description("Tlak")] Pressure,
|
||||
[Description("Vlhkost")] Humidity,
|
||||
[Description("Chyba")] Error,
|
||||
[Description("Délka")] Length,
|
||||
[Description("Hustota")] Density,
|
||||
[Description("Energie")] Energy,
|
||||
[Description("Pulzy")] Pulses,
|
||||
[Description("Pulzy/litr")] PulsePerLtr,
|
||||
[Description("Pulzy/kWh")] PulsePerKWh,
|
||||
[Description("Vodivost")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Počet")] Number,
|
||||
[Description("Text")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Datum a čas")] DateTime,
|
||||
#elif LANG_IT
|
||||
[Description("Volume")] Volume,
|
||||
[Description("Flusso")] Flow,
|
||||
[Description("Massa")] Mass,
|
||||
[Description("Tempo")] Time,
|
||||
[Description("Temperatura")] Temperature,
|
||||
[Description("Pressione")] Pressure,
|
||||
[Description("Umidità")] Humidity,
|
||||
[Description("Errore")] Error,
|
||||
[Description("Lungezza")] Length,
|
||||
[Description("Densità")] Density,
|
||||
[Description("Energia")] Energy,
|
||||
[Description("Impulso")] Pulses,
|
||||
[Description("Impulso/litro")] PulsePerLtr,
|
||||
[Description("Impulso/kWh")] PulsePerKWh,
|
||||
[Description("Conduttività")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Numero")] Number,
|
||||
[Description("Stringa")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Data e ora")] DateTime,
|
||||
#else
|
||||
[Description("Volume")] Volume,
|
||||
[Description("Flow")] Flow,
|
||||
[Description("Mass")] Mass,
|
||||
[Description("Time")] Time,
|
||||
[Description("Temperature")] Temperature,
|
||||
[Description("Pressure")] Pressure,
|
||||
[Description("Humidity")] Humidity,
|
||||
[Description("Error")] Error,
|
||||
[Description("Length")] Length,
|
||||
[Description("Density")] Density,
|
||||
[Description("Energy")] Energy,
|
||||
[Description("Pulses")] Pulses,
|
||||
[Description("Pulses/liter")] PulsePerLtr,
|
||||
[Description("Pulses/kWh")] PulsePerKWh,
|
||||
[Description("Conductivity")] Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
[Description("Number")] Number,
|
||||
[Description("String")] String,
|
||||
[Description("Boolean")] Boolean,
|
||||
[Description("Date and time")] DateTime,
|
||||
[Description("Enum")] Enum,
|
||||
#endif
|
||||
Count,
|
||||
}
|
||||
|
||||
public static class Units
|
||||
{
|
||||
public static bool IsUnitless(Quantity quantity)
|
||||
{
|
||||
return quantity >= Quantity.Number;
|
||||
}
|
||||
|
||||
public static bool IsDefaultUnit(Unit unit)
|
||||
{
|
||||
return unit == Unit.l || unit == Unit.m3ph || unit == Unit.kg || unit == Unit.s || unit == Unit.C || unit == Unit.bar || unit == Unit.RPct ||
|
||||
unit == Unit.Pct || unit == Unit.mm || unit == Unit.kgpm3 || unit == Unit.J || unit == Unit.ppl || unit == Unit.ppkWh || unit == Unit.uSpcm;
|
||||
}
|
||||
|
||||
public static bool IsQuantity(Unit units, Quantity quantity)
|
||||
{
|
||||
return (quantity == GetQuantity(units));
|
||||
}
|
||||
|
||||
public static Quantity GetQuantity(Unit units)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
case Unit.pulse:
|
||||
case Unit.degree:
|
||||
return Config.Quantity.Pulses;
|
||||
|
||||
case Unit.l:
|
||||
case Unit.dm3:
|
||||
case Unit.m3:
|
||||
case Unit.gal_UK:
|
||||
case Unit.gal_US:
|
||||
return Config.Quantity.Volume;
|
||||
|
||||
case Unit.lph:
|
||||
case Unit.m3ph:
|
||||
return Config.Quantity.Flow;
|
||||
|
||||
case Unit.g:
|
||||
case Unit.kg:
|
||||
case Unit.t:
|
||||
case Unit.lb:
|
||||
return Config.Quantity.Mass;
|
||||
|
||||
case Unit.s:
|
||||
case Unit.min:
|
||||
case Unit.hour:
|
||||
case Unit.ms:
|
||||
return Config.Quantity.Time;
|
||||
|
||||
case Unit.C:
|
||||
case Unit.F:
|
||||
case Unit.K:
|
||||
return Config.Quantity.Temperature;
|
||||
|
||||
case Unit.Pa:
|
||||
case Unit.hPa:
|
||||
case Unit.mbar:
|
||||
case Unit.kPa:
|
||||
case Unit.bar:
|
||||
case Unit.MPa:
|
||||
case Unit.inHg:
|
||||
return Config.Quantity.Pressure;
|
||||
|
||||
case Unit.RPct:
|
||||
return Config.Quantity.Humidity;
|
||||
|
||||
case Unit.Pct:
|
||||
case Unit.Promile:
|
||||
return Config.Quantity.Error;
|
||||
|
||||
case Unit.mm:
|
||||
case Unit.cm:
|
||||
case Unit.m:
|
||||
case Unit.inch:
|
||||
return Config.Quantity.Length;
|
||||
|
||||
case Unit.kgpm3:
|
||||
case Unit.kgpl:
|
||||
return Config.Quantity.Density;
|
||||
|
||||
case Unit.J:
|
||||
case Unit.kJ:
|
||||
case Unit.MJ:
|
||||
case Unit.Wh:
|
||||
case Unit.kWh:
|
||||
case Unit.MWh:
|
||||
return Config.Quantity.Energy;
|
||||
|
||||
case Unit.ppl:
|
||||
case Unit.ppdm3:
|
||||
case Unit.degpl:
|
||||
case Unit.degpdm3:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg:
|
||||
return Config.Quantity.PulsePerLtr;
|
||||
|
||||
case Unit.ppkWh:
|
||||
case Unit.kWhpp:
|
||||
return Config.Quantity.PulsePerKWh;
|
||||
|
||||
case Unit.uSpcm:
|
||||
return Config.Quantity.Conductivity;
|
||||
|
||||
default:
|
||||
return Config.Quantity.Number;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVolume(Unit units) { return IsQuantity(units, Config.Quantity.Volume); }
|
||||
public static bool IsFlow(Unit units) { return IsQuantity(units, Config.Quantity.Flow); }
|
||||
public static bool IsMass(Unit units) { return IsQuantity(units, Config.Quantity.Mass); }
|
||||
public static bool IsTime(Unit units) { return IsQuantity(units, Config.Quantity.Time); }
|
||||
public static bool IsTemperature(Unit units) { return IsQuantity(units, Config.Quantity.Temperature); }
|
||||
public static bool IsPressure(Unit units) { return IsQuantity(units, Config.Quantity.Pressure); }
|
||||
public static bool IsHumidity(Unit units) { return IsQuantity(units, Config.Quantity.Humidity); }
|
||||
public static bool IsError(Unit units) { return IsQuantity(units, Config.Quantity.Error); }
|
||||
public static bool IsLength(Unit units) { return IsQuantity(units, Config.Quantity.Length); }
|
||||
public static bool IsDensity(Unit units) { return IsQuantity(units, Config.Quantity.Density); }
|
||||
public static bool IsEnergy(Unit units) { return IsQuantity(units, Config.Quantity.Energy); }
|
||||
public static bool IsPulses(Unit units) { return IsQuantity(units, Config.Quantity.Pulses); }
|
||||
public static bool IsPulsePerLtr(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerLtr); }
|
||||
public static bool IsPulsePerKWh(Unit units) { return IsQuantity(units, Config.Quantity.PulsePerKWh); }
|
||||
public static bool IsConductivity(Unit units) { return IsQuantity(units, Config.Quantity.Conductivity); }
|
||||
|
||||
|
||||
|
||||
public static double ConvertTo(Unit units, double v)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.dm3:
|
||||
case Unit.l: return v; /// 1 liter
|
||||
case Unit.m3: return 0.001 * v; /// 1 m3 = 1000 l
|
||||
case Unit.gal_UK: return 0.21996925 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.gal_US: return 0.26417205 * v; /// 1 gal(US) = 3.78541178 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 1000 * v; /// 1 liter/h
|
||||
case Unit.m3ph: return v; /// 1 m3/h = 1000 l/h
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 1000 * v; /// 1 g = 0.001 kg
|
||||
case Unit.kg: return v; /// 1 kilogram
|
||||
case Unit.t: return 0.001 * v; /// 1 t = 1000 kg
|
||||
case Unit.lb: return 2.2046226 * v; /// 1 lb = 0.45359237 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.s: return v;
|
||||
case Unit.min: return v / 60;
|
||||
case Unit.hour: return v / 3600;
|
||||
case Unit.ms: return 1000 * v;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.C: return v; /// degree Celsius (°C)
|
||||
case Unit.F: return 1.8 * v + 32; /// degree Fahrenheit
|
||||
case Unit.K: return v + 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 100000 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.hPa: return 1000 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 1000 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 100 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.bar: return v; /// 1 bar = 1000 mbar = 100000 Pa
|
||||
case Unit.MPa: return 0.1 * v; /// 1 MPa = 10000 hPa
|
||||
case Unit.inHg: return 29.53 * v; /// 1 inHg = 33.864 hPa
|
||||
|
||||
/// Error: internal representation in %
|
||||
case Unit.Pct: return v; /// 1 %
|
||||
case Unit.Promile: return 10 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.mm: return v; /// 1 mm
|
||||
case Unit.cm: return 0.1 * v; /// 1 cm = 10 mm
|
||||
case Unit.m: return 0.001 * v; /// 1 m = 1000 mm
|
||||
case Unit.inch: return v / 25.4; /// 1 inch = 25.4 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpm3: return v;
|
||||
case Unit.kgpl: return 0.001 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.J: return v; /// 1 Joul
|
||||
case Unit.kJ: return 0.001 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 0.000001 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return v / 3600.0; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return v / 3600000.0; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return v / 3600000000.0;/// 1 MWh = 3600000000 J
|
||||
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return ((v <= float.Epsilon) ? 0 : 1 / v);
|
||||
|
||||
default: return v;
|
||||
}
|
||||
}
|
||||
|
||||
public static double ConvertFrom(Unit units, double v)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.dm3:
|
||||
case Unit.l: return v; /// 1 liter
|
||||
case Unit.m3: return 1000 * v; /// 1000 l
|
||||
case Unit.gal_UK: return 4.54609 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.gal_US: return 3.78541178 * v; /// 1 gal(US) = 3.78541178 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 0.001 * v; /// 1 liter/h
|
||||
case Unit.m3ph: return v; /// 1 m3/h = 1000 l/h
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 0.001 * v; /// 1 g = 0.001 kg
|
||||
case Unit.kg: return v; /// 1 kilogram
|
||||
case Unit.t: return 1000 * v; /// 1 t = 1000 kg
|
||||
case Unit.lb: return 0.45359237 * v; /// 1 lb = 0.45359237 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.s: return v;
|
||||
case Unit.min: return 60 * v;
|
||||
case Unit.hour: return 3600 * v;
|
||||
case Unit.ms: return v / 1000;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.C: return v; /// degree Celsius (°C)
|
||||
case Unit.F: return 5 * (v-32) / 9; /// degree Fahrenheit
|
||||
case Unit.K: return v - 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 0.00001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.hPa: return 0.001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 0.001 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 0.01 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.bar: return v; /// 1 bar = 1000 mbar = 100000 Pa
|
||||
case Unit.MPa: return 10 * v; /// 1 MPa = 10000 hPa
|
||||
case Unit.inHg: return 0.033864 * v; /// 1 inHg = 33.864 hPa
|
||||
|
||||
/// Error: internal representation in %
|
||||
case Unit.Pct: return v; /// 1 %
|
||||
case Unit.Promile: return 0.1 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.mm: return v; /// 1 mm
|
||||
case Unit.cm: return 10 * v; /// 1 cm = 10 mm
|
||||
case Unit.m: return 1000 * v; /// 1 m = 1000 mm
|
||||
case Unit.inch: return 25.4 * v; /// 1 inch = 25.4 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpm3: return v;
|
||||
case Unit.kgpl: return 1000 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.J: return v; /// 1 Joul
|
||||
case Unit.kJ: return 1000 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 1000000 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return 3600 * v; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return 3600000 * v; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return 3600000000 * v; /// 1 kWh = 3600000000 J
|
||||
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return ((v == 0) ? 0 : 1 / v);
|
||||
|
||||
default: return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
Config/Utils.cs
190
Config/Utils.cs
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -10,80 +10,6 @@ namespace Config
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string SignificantDigitsToFmt(double value, int sigDigits)
|
||||
{
|
||||
if (sigDigits == 6)
|
||||
{
|
||||
if (value >= 99999.5 || value < -99999.5) return "F0";
|
||||
else if (value >= 9999.95 || value < -9999.95) return "F1";
|
||||
else if (value >= 999.995 || value < -999.995) return "F2";
|
||||
else if (value >= 99.9995 || value < -99.9995) return "F3";
|
||||
else if (value >= 9.99995 || value < -9.99995) return "F4";
|
||||
else if (value >= 0.999995 || value < -0.999995) return "F5";
|
||||
else if (value >= 0.0999995 || value < -0.0999995) return "F6";
|
||||
else if (value >= 0.00999995 || value < -0.00999995) return "F7";
|
||||
else if (value >= 0.000999995 || value < -0.000999995) return "F8";
|
||||
else if (value >= 0.0000999995 || value < -0.0000999995) return "F9";
|
||||
else return "F10";
|
||||
}
|
||||
else if (sigDigits == 5)
|
||||
{
|
||||
if (value >= 9999.5 || value < -9999.5) return "F0";
|
||||
else if (value >= 999.95 || value < -999.95) return "F1";
|
||||
else if (value >= 99.995 || value < -99.995) return "F2";
|
||||
else if (value >= 9.9995 || value < -9.9995) return "F3";
|
||||
else if (value >= 0.99995 || value < -0.99995) return "F4";
|
||||
else if (value >= 0.099995 || value < -0.099995) return "F5";
|
||||
else if (value >= 0.0099995 || value < -0.0099995) return "F6";
|
||||
else if (value >= 0.00099995 || value < -0.00099995) return "F7";
|
||||
else if (value >= 0.000099995 || value < -0.000099995) return "F8";
|
||||
else return "F9";
|
||||
}
|
||||
else if (sigDigits == 4)
|
||||
{
|
||||
if (value >= 999.5 || value < -999.5) return "F0";
|
||||
else if (value >= 99.95 || value < -99.95) return "F1";
|
||||
else if (value >= 9.995 || value < -9.995) return "F2";
|
||||
else if (value >= 0.9995 || value < -0.9995) return "F3";
|
||||
else if (value >= 0.09995 || value < -0.09995) return "F4";
|
||||
else if (value >= 0.009995 || value < -0.009995) return "F5";
|
||||
else if (value >= 0.0009995 || value < -0.0009995) return "F6";
|
||||
else if (value >= 0.00009995 || value < -0.00009995) return "F7";
|
||||
else return "F8";
|
||||
}
|
||||
else if (sigDigits == 3)
|
||||
{
|
||||
if (value >= 99.5 || value < -99.5) return "F0";
|
||||
else if (value >= 9.95 || value < -9.95) return "F1";
|
||||
else if (value >= 0.995 || value < -0.995) return "F2";
|
||||
else if (value >= 0.0995 || value < -0.0995) return "F3";
|
||||
else if (value >= 0.00995 || value < -0.00995) return "F4";
|
||||
else if (value >= 0.000995 || value < -0.000995) return "F5";
|
||||
else if (value >= 0.0000995 || value < -0.0000995) return "F6";
|
||||
else return "F7";
|
||||
}
|
||||
else if (sigDigits == 2)
|
||||
{
|
||||
if (value >= 9.5 || value < -9.5) return "F0";
|
||||
else if (value >= 0.95 || value < -0.95) return "F1";
|
||||
else if (value >= 0.095 || value < -0.095) return "F2";
|
||||
else if (value >= 0.0095 || value < -0.0095) return "F3";
|
||||
else if (value >= 0.00095 || value < -0.00095) return "F4";
|
||||
else if (value >= 0.000095 || value < -0.000095) return "F5";
|
||||
else return "F6";
|
||||
}
|
||||
else /// if (sigDigits == 1)
|
||||
{
|
||||
if (value >= 0.95 || value < -0.95) return "F0";
|
||||
else if (value >= 0.095 || value < -0.095) return "F1";
|
||||
else if (value >= 0.0095 || value < -0.0095) return "F2";
|
||||
else if (value >= 0.00095 || value < -0.00095) return "F3";
|
||||
else if (value >= 0.000095 || value < -0.000095) return "F4";
|
||||
else return "F5";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extract and return a DB server from a MySQL connection string.
|
||||
/// </summary>
|
||||
@ -138,119 +64,5 @@ namespace Config
|
||||
/// pattern NOT found
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get either Q1 or Qmin flow for a given Qn and metrological class
|
||||
/// </summary>
|
||||
/// <param name="Qn">Nominal flow in m3/h</param>
|
||||
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
|
||||
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
|
||||
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
|
||||
/// <returns>Q1 or Qmin flow in m3/h</returns>
|
||||
public static double GetQ1Qmin(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
|
||||
|
||||
int metroClassRatio;
|
||||
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
|
||||
{
|
||||
return Qn / (double)metroClassRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (medium == Entities.Medium.HotWater)
|
||||
{
|
||||
switch (metroClass)
|
||||
{
|
||||
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
|
||||
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.04 * Qn);
|
||||
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.02 * Qn);
|
||||
case "D": return (Qn < 15) ? (0.01 * Qn) : Qdflt;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (metroClass)
|
||||
{
|
||||
case "A": return (Qn < 15) ? (0.04 * Qn) : (0.08 * Qn);
|
||||
case "B": return (Qn < 15) ? (0.02 * Qn) : (0.03 * Qn);
|
||||
case "C": return (Qn < 15) ? (0.01 * Qn) : (0.006 * Qn);
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Qdflt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get either Q2 or Qt flow for a given Qn and metrological class
|
||||
/// </summary>
|
||||
/// <param name="Qn">Nominal flow in m3/h</param>
|
||||
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
|
||||
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
|
||||
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
|
||||
/// <returns>Q2 or Qt flow in m3/h</returns>
|
||||
public static double GetQ2Qt(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
|
||||
|
||||
int metroClassRatio;
|
||||
if ((metroClass[0] == 'R') && int.TryParse(metroClass.Substring(1), out metroClassRatio) && (metroClassRatio > 0))
|
||||
{
|
||||
return 1.6 * Qn / (double)metroClassRatio;
|
||||
}
|
||||
|
||||
if (medium == Entities.Medium.HotWater)
|
||||
{
|
||||
switch (metroClass)
|
||||
{
|
||||
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.2 * Qn);
|
||||
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.15 * Qn);
|
||||
case "C": return (Qn < 15) ? (0.06 * Qn) : (0.1 * Qn);
|
||||
case "D": return (Qn < 15) ? (0.015 * Qn) : Qdflt;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (metroClass)
|
||||
{
|
||||
case "A": return (Qn < 15) ? (0.1 * Qn) : (0.3 * Qn);
|
||||
case "B": return (Qn < 15) ? (0.08 * Qn) : (0.2 * Qn);
|
||||
case "C": return (Qn < 15) ? (0.015 * Qn) : (0.015 * Qn);
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return Qdflt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get either Q4 or Qmax flow for a given Qn and metrological class
|
||||
/// </summary>
|
||||
/// <param name="Qn">Nominal flow in m3/h</param>
|
||||
/// <param name="metroClass">Metrological class ("A" ,"B", "C" or "R#")</param>
|
||||
/// <param name="medium">NotSpecified, ColdWater or HotWater</param>
|
||||
/// <param name="Qdflt">Default flow when metrologic does not match pattern</param>
|
||||
/// <returns>Q4 or Qmax flow in m3/h</returns>
|
||||
public static double GetQ4Qmax(double Qn, string metroClass, Entities.Medium medium = Entities.Medium.ColdWater, double Qdflt = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(metroClass)) return Qdflt;
|
||||
|
||||
switch (metroClass[0])
|
||||
{
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
return 2 * Qn;
|
||||
case 'R':
|
||||
return 1.25 * Qn;
|
||||
default:
|
||||
return Qdflt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,12 +7,12 @@ namespace DataStreamInterface
|
||||
{
|
||||
public class DataFrame
|
||||
{
|
||||
public readonly UInt64 ID; /// Frame ID
|
||||
public readonly Int64 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)
|
||||
public DataFrame(Int64 id, double time, double volume, double[] quantity)
|
||||
{
|
||||
ID = id;
|
||||
Time = time;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataStreamInterface</RootNamespace>
|
||||
<AssemblyName>DataStreamInterface</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
@ -21,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -29,9 +30,11 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
Binary file not shown.
@ -13,22 +13,28 @@ namespace DataStreamInterface
|
||||
degree,
|
||||
|
||||
/// Volume
|
||||
ml, /// 0.001 l
|
||||
l, /// * 1 liter = 1 l
|
||||
ml, /// 1 ml = 0.001 l
|
||||
l, /// * 1 liter
|
||||
dm3, /// 1 dm3 = 1 l
|
||||
m3, /// 1000 l
|
||||
gal_UK, /// 1 gal(UK) = 4.54609 l
|
||||
gal_US, /// 1 gal(US) = 3.78541178 l
|
||||
USgal, /// 1 US gallon = 3.78541178 l
|
||||
UKgal, /// 1 imperial gallon = 4.54609 l
|
||||
cf, /// 1 cubic foot = 28.316846592 l
|
||||
m3, /// 1 m3 = 1000 l
|
||||
|
||||
/// Flow
|
||||
lph, /// 1 liter/h
|
||||
m3ph, /// * 1 m3/h = 1000 l/h
|
||||
lph, /// 1 l/h = 0.001 m3/h
|
||||
lpm, /// 1 l/m = 60 l/h = 0.06 m3/h
|
||||
m3ph, /// * 1 m3/h
|
||||
lps, /// 1 liter/s = 3.6 m3/h
|
||||
USgalps, /// 1 US gallon per second = 13.627482408 m3/h
|
||||
m3pm, /// 1 m3/m = 60 m3/h
|
||||
cfs, /// 1 cubic foot per second = 101.9406477312 m3/h
|
||||
|
||||
/// Mass
|
||||
g, /// 0.001 kg
|
||||
lb, /// 0.45359237 kg
|
||||
kg, /// * 1 kilogram
|
||||
t, /// 1000 kg
|
||||
lb, /// 0.45359237 kg
|
||||
|
||||
/// Time
|
||||
ms, /// 1 ms = 0.001 s
|
||||
@ -47,6 +53,7 @@ namespace DataStreamInterface
|
||||
mbar, /// 1 mbar = 1 hPa = 100 Pa
|
||||
kPa, /// 1 kPa = 10 HPa
|
||||
inHg, /// 1 inHg = 33.864 hPa
|
||||
psi, /// 1 psi = 0.0689475729 bar
|
||||
bar, /// * 1 Bar = 1000 mbar = 0.1 MPa = 100000 Pa
|
||||
MPa, /// 1 MPa = 10000 hPa
|
||||
|
||||
@ -61,7 +68,9 @@ namespace DataStreamInterface
|
||||
mm, /// * 1 millimeter
|
||||
cm, /// 1 cm = 10 mm
|
||||
inch, /// 1 inch = 25.4 mm
|
||||
dm, /// 1 dm = 100 mm
|
||||
foot, /// 1 foot = 304.8 mm
|
||||
yard, /// 1 yard = 914.4 mm
|
||||
m, /// 1 m = 1000 mm
|
||||
|
||||
/// Density
|
||||
@ -76,20 +85,317 @@ namespace DataStreamInterface
|
||||
kWh, /// 1 kWh = 3600000 J
|
||||
MWh, /// 1 MWh = 3600000000 J
|
||||
|
||||
/// Electrical conductivity
|
||||
uSpcm, /// * 1 uS/cm
|
||||
mSpm, /// 1 mS/m = 10 uS/cm
|
||||
|
||||
/// 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
|
||||
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
|
||||
kWhpp, /// 1 kWh/pulse
|
||||
}
|
||||
|
||||
public enum Quantity
|
||||
{
|
||||
/// Quantities with units and conversions (double -> double)
|
||||
Volume,
|
||||
Flow,
|
||||
Mass,
|
||||
Time,
|
||||
Temperature,
|
||||
Pressure,
|
||||
Humidity,
|
||||
Error,
|
||||
Length,
|
||||
Density,
|
||||
Energy,
|
||||
Pulses,
|
||||
PulsePerLtr,
|
||||
PulsePerKWh,
|
||||
Conductivity,
|
||||
|
||||
/// Quantities without units and conversions
|
||||
Number,
|
||||
String,
|
||||
Boolean,
|
||||
DateTime,
|
||||
Enumerated,
|
||||
}
|
||||
|
||||
public static class Units
|
||||
{
|
||||
public static bool IsDefaultUnit(Unit unit)
|
||||
{
|
||||
return unit == Unit.l || unit == Unit.m3ph || unit == Unit.kg || unit == Unit.s || unit == Unit.C ||
|
||||
unit == Unit.bar || unit == Unit.RPct || unit == Unit.Pct || unit == Unit.mm || unit == Unit.kgpm3 ||
|
||||
unit == Unit.J || unit == Unit.uSpcm || unit == Unit.ppl || unit == Unit.ppkWh;
|
||||
}
|
||||
|
||||
public static Quantity GetQuantity(Unit units)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
case Unit.pulse:
|
||||
case Unit.degree:
|
||||
return Quantity.Pulses;
|
||||
|
||||
case Unit.ml:
|
||||
case Unit.l:
|
||||
case Unit.dm3:
|
||||
case Unit.USgal:
|
||||
case Unit.UKgal:
|
||||
case Unit.cf:
|
||||
case Unit.m3:
|
||||
return Quantity.Volume;
|
||||
|
||||
case Unit.lph:
|
||||
case Unit.lpm:
|
||||
case Unit.m3ph:
|
||||
case Unit.lps:
|
||||
case Unit.USgalps:
|
||||
case Unit.m3pm:
|
||||
case Unit.cfs:
|
||||
return Quantity.Flow;
|
||||
|
||||
case Unit.g:
|
||||
case Unit.lb:
|
||||
case Unit.kg:
|
||||
case Unit.t:
|
||||
return Quantity.Mass;
|
||||
|
||||
case Unit.ms:
|
||||
case Unit.s:
|
||||
case Unit.min:
|
||||
case Unit.hour:
|
||||
return Quantity.Time;
|
||||
|
||||
case Unit.C:
|
||||
case Unit.F:
|
||||
case Unit.K:
|
||||
return Quantity.Temperature;
|
||||
|
||||
case Unit.Pa:
|
||||
case Unit.hPa:
|
||||
case Unit.mbar:
|
||||
case Unit.kPa:
|
||||
case Unit.inHg:
|
||||
case Unit.psi:
|
||||
case Unit.bar:
|
||||
case Unit.MPa:
|
||||
return Quantity.Pressure;
|
||||
|
||||
case Unit.RPct:
|
||||
return Quantity.Humidity;
|
||||
|
||||
case Unit.Promile:
|
||||
case Unit.Pct:
|
||||
return Quantity.Error;
|
||||
|
||||
case Unit.mm:
|
||||
case Unit.cm:
|
||||
case Unit.inch:
|
||||
case Unit.dm:
|
||||
case Unit.foot:
|
||||
case Unit.yard:
|
||||
case Unit.m:
|
||||
return Quantity.Length;
|
||||
|
||||
case Unit.kgpm3:
|
||||
case Unit.kgpl:
|
||||
return Quantity.Density;
|
||||
|
||||
case Unit.J:
|
||||
case Unit.kJ:
|
||||
case Unit.MJ:
|
||||
case Unit.Wh:
|
||||
case Unit.kWh:
|
||||
case Unit.MWh:
|
||||
return Quantity.Energy;
|
||||
|
||||
case Unit.uSpcm:
|
||||
case Unit.mSpm:
|
||||
return Quantity.Conductivity;
|
||||
|
||||
case Unit.ppl:
|
||||
case Unit.ppdm3:
|
||||
case Unit.degpl:
|
||||
case Unit.degpdm3:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg:
|
||||
return Quantity.PulsePerLtr;
|
||||
|
||||
case Unit.ppkWh:
|
||||
case Unit.kWhpp:
|
||||
return Quantity.PulsePerKWh;
|
||||
|
||||
default:
|
||||
return Quantity.Number;
|
||||
}
|
||||
}
|
||||
|
||||
public static double ConvertTo(Unit units, double v)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.ml: return 1000 * v; /// 1 l = 1000 ml
|
||||
case Unit.USgal: return 0.26417205 * v; /// 1 gal(US) = 3.78541178 l
|
||||
case Unit.UKgal: return 0.21996925 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.cf: return 0.0353146667215 * v; /// 1 cubic foot = 28.316846592 l
|
||||
case Unit.m3: return 0.001 * v; /// 1 m3 = 1000 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 1000 * v; /// 1 l/h
|
||||
case Unit.lpm: return v / 0.06; /// 1 l/m
|
||||
case Unit.lps: return v / 3.6; /// 1 l/s
|
||||
case Unit.USgalps: return 0.0733811257326 * v; /// 1 US gallon per second
|
||||
case Unit.m3pm: return v / 60; /// 1 m3/m
|
||||
case Unit.cfs: return 0.009809629644858 * v; /// 1 cubic foot per second
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 1000 * v; /// 1 g = 0.001 kg
|
||||
case Unit.lb: return 2.2046226 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 0.001 * v; /// 1 t = 1000 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.ms: return 1000 * v;
|
||||
case Unit.min: return v / 60;
|
||||
case Unit.hour: return v / 3600;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.F: return 1.8 * v + 32; /// degree Fahrenheit
|
||||
case Unit.K: return v + 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 100000 * v;
|
||||
case Unit.hPa: return 1000 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 1000 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 100 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.inHg: return 29.53 * v; /// 1 inHg =
|
||||
case Unit.psi: return 14.5037738 * v; /// 1 psi =
|
||||
case Unit.MPa: return 0.1 * v; /// 1 MPa = 10000 hPa
|
||||
|
||||
/// Relative error: internal representation in %
|
||||
case Unit.Promile: return 10 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.cm: return 0.1 * v; /// 1 cm = 10 mm
|
||||
case Unit.inch: return v / 25.4; /// 1 inch = 25.4 mm
|
||||
case Unit.dm: return 0.01 * v; /// 1 dm = 100 mm
|
||||
case Unit.foot: return v / 304.8; /// 1 foot = 304.8 mm
|
||||
case Unit.yard: return v / 914.4; /// 1 yard = 914,4 mm
|
||||
case Unit.m: return 0.001 * v; /// 1 m = 1000 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpl: return 0.001 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.kJ: return 0.001 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 0.000001 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return v / 3600.0; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return v / 3600000.0; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return v / 3600000000.0; /// 1 MWh = 3600000000 J
|
||||
|
||||
/// Electrical conductivity
|
||||
case Unit.mSpm: return 0.1 * v;
|
||||
|
||||
/// Invert pulses
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return (v <= float.Epsilon) ? 0 : 1/v;
|
||||
|
||||
default: return v; /// Do not convert
|
||||
}
|
||||
}
|
||||
|
||||
public static double ConvertFrom(Unit units, double v)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
/// Volume: internal representation in l
|
||||
case Unit.ml: return 0.001 * v; /// 0.001 l
|
||||
case Unit.USgal: return 3.78541178 * v; /// 1 gal(US) = 3.78541178 l
|
||||
case Unit.UKgal: return 4.54609 * v; /// 1 gal(UK) = 4.54609 l
|
||||
case Unit.cf: return 28.316846592 * v; /// 1 cubic foot = 28.316846592 l
|
||||
case Unit.m3: return 1000 * v; /// 1000 l
|
||||
|
||||
/// Flow: internal representation in m3/h
|
||||
case Unit.lph: return 0.001 * v; /// 1 l/h
|
||||
case Unit.lpm: return 0.06 * v; /// 1 l/m
|
||||
case Unit.lps: return 3.6 * v; /// 1 l/s
|
||||
case Unit.USgalps: return 13.627482408 * v; /// 1 US gallon per second
|
||||
case Unit.m3pm: return 60 * v; /// 1 m3/m
|
||||
case Unit.cfs: return 101.9406477312 * v; /// 1 cubic foot per second
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 0.001 * v; /// 1 g = 0.001 kg
|
||||
case Unit.lb: return 0.45359237 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 1000 * v; /// 1 t = 1000 kg
|
||||
|
||||
/// Time or duration: internal representation in seconds [s]
|
||||
case Unit.ms: return 0.001 * v;
|
||||
case Unit.min: return 60 * v;
|
||||
case Unit.hour: return 3600 * v;
|
||||
|
||||
/// Temperature: internal representation in °C
|
||||
case Unit.F: return 5 * (v - 32) / 9; /// degree Fahrenheit
|
||||
case Unit.K: return v - 273.15; /// degree Kelvin
|
||||
|
||||
/// Pressure: internal representation in bar = 0.1 MPa
|
||||
case Unit.Pa: return 0.00001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.hPa: return 0.001 * v; /// 1 hPa = 100 Pa
|
||||
case Unit.mbar: return 0.001 * v; /// 1 mbar = 1 hPa = 100 Pa
|
||||
case Unit.kPa: return 0.01 * v; /// 1 kPa = 10 HPa
|
||||
case Unit.inHg: return 0.033864 * v; /// 1 inHg = 33.864 hPa
|
||||
case Unit.psi: return 0.0689475729 * v; /// 1 psi = 0.0689475729 bar
|
||||
case Unit.MPa: return 10 * v; /// 1 MPa = 10000 hPa
|
||||
|
||||
/// Relative error: internal representation in %
|
||||
case Unit.Promile: return 0.1 * v; /// 1 promile = 0.1 %
|
||||
|
||||
/// Diameter, length: internal representation in mm
|
||||
case Unit.cm: return 10 * v; /// 1 cm = 10 mm
|
||||
case Unit.inch: return 25.4 * v; /// 1 inch = 25.4 mm
|
||||
case Unit.dm: return 100 * v; /// 1 dm = 100 mm
|
||||
case Unit.foot: return 304.8 * v; /// 1 foot = 304.8 mm
|
||||
case Unit.yard: return 914.4 * v; /// 1 yard = 914,4 mm
|
||||
case Unit.m: return 1000 * v; /// 1 m = 1000 mm
|
||||
|
||||
/// Density: internal representation in kg/m3
|
||||
case Unit.kgpl: return 1000 * v;
|
||||
|
||||
/// Energy, internal representation in Joul
|
||||
case Unit.kJ: return 1000 * v; /// 1 kJ = 1000 J
|
||||
case Unit.MJ: return 1000000 * v; /// 1 kJ = 1000000 J
|
||||
case Unit.Wh: return 3600 * v; /// 1 Wh = 3600 J
|
||||
case Unit.kWh: return 3600000 * v; /// 1 kWh = 3600000 J
|
||||
case Unit.MWh: return 3600000000 * v; /// 1 kWh = 3600000000 J
|
||||
|
||||
/// Electrical conductivity
|
||||
case Unit.mSpm: return 10 * v;
|
||||
|
||||
/// Invert
|
||||
case Unit.kWhpp:
|
||||
case Unit.lpp:
|
||||
case Unit.dm3pp:
|
||||
case Unit.lpdeg:
|
||||
case Unit.dm3pdeg: return (v <= float.Epsilon) ? 0 : 1/v;
|
||||
|
||||
default: return v; /// Do not convert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,58 +2,82 @@
|
||||
/// 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>
|
||||
/// Returns count of water meters supported by the data stream component
|
||||
/// </summary>
|
||||
/// <returns>Water meters count</returns>
|
||||
int GetMetersCount();
|
||||
|
||||
/// <summary>
|
||||
/// Get state of the connected data stream meter
|
||||
/// </summary>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <param name="state">Current state of the meter</param>
|
||||
/// <param name="parameter">Current extra parameter of the meter</param>
|
||||
/// <returns>true when successful</returns>
|
||||
bool GetState(out int state, out string parameter);
|
||||
bool GetState(int meterIx, out int state, out string parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Set state of the connected data stream meter
|
||||
/// </summary>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <param name="state">Required state of the meter</param>
|
||||
/// <param name="parameter">Required extra parameter of the meter</param>
|
||||
/// <returns>true when successful</returns>
|
||||
bool SetState(int state, string parameter);
|
||||
bool SetState(int meterIx, int state, string parameter);
|
||||
|
||||
bool SetStateAll(int state, string parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Establish connection with a data stream meter
|
||||
/// </summary>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <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();
|
||||
bool OpenConnection(int meterIx, string connectionParameters, out string meterId);
|
||||
|
||||
/// <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>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <returns>true when successful</returns>
|
||||
bool StartMeasurement();
|
||||
bool StartMeasurement(int meterIx);
|
||||
|
||||
bool StartMeasurementAll();
|
||||
|
||||
/// <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>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <param name="storedFramesCount">Number of stored date frames</param>
|
||||
/// <returns>true when successful</returns>
|
||||
bool StopMeasurement(out UInt64 lastFrameID);
|
||||
bool StopMeasurement(int meterIx, out Int64 storedFramesCount);
|
||||
|
||||
bool StopMeasurementAll(out Int64[] storedFramesCounts);
|
||||
|
||||
/// <summary>
|
||||
/// Closes connection with the data stream meter
|
||||
/// </summary>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <returns>true when successful</returns>
|
||||
bool CloseConnection(int meterIx);
|
||||
|
||||
bool CloseConnectionAll();
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when TBF program is shutting down.
|
||||
/// </summary>
|
||||
/// <returns>true when successful</returns>
|
||||
bool Shutdown();
|
||||
|
||||
///------------------------------------------------
|
||||
/// Units of time, volume and optional quantities
|
||||
@ -70,7 +94,7 @@ namespace DataStreamInterface
|
||||
Unit GetVolumeUnits();
|
||||
|
||||
///-----------------------------------------------
|
||||
/// Ooptional quantities: count, units, captions
|
||||
/// Optional quantities: count, units, captions
|
||||
///-----------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
@ -83,13 +107,13 @@ namespace DataStreamInterface
|
||||
/// Returns units of the specified quantity
|
||||
/// </summary>
|
||||
/// <param name="quanityNr">Zero based quantity number 0 .. quantites count-1</param>
|
||||
Unit GetQuantityUnits(int quanityNr);
|
||||
Unit GetQuantityUnits(int quantityNr);
|
||||
|
||||
/// <summary>
|
||||
/// Returns caption of the specified quantity
|
||||
/// </summary>
|
||||
/// <param name="quanityNr">Zero based quantity number 0 .. quantites count-1</param>
|
||||
string GetQuantityCaption(int quanityNr);
|
||||
string GetQuantityCaption(int quantityNr);
|
||||
|
||||
///---------------------------
|
||||
/// Datastream data exchange
|
||||
@ -98,17 +122,19 @@ namespace DataStreamInterface
|
||||
/// <summary>
|
||||
/// Retuns 'count' data frames starting with data frame with ID = 'id'
|
||||
/// </summary>
|
||||
/// <param name="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <param name="id">First frame ID</param>
|
||||
/// <param name="count">Frames count</param>
|
||||
/// <returns>Selected data frames</returns>
|
||||
DataFrame[] GetFrames(UInt64 id, int count);
|
||||
DataFrame[] GetFrames(int meterIx, Int64 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="meterIx">Index of the meter in range 0 .. (GetMetersCount() - 1)</param>
|
||||
/// <param name="time">Time</param>
|
||||
/// <returns>ID of the data frame at or after the pecified time</returns>
|
||||
UInt64 GetID(double time);
|
||||
Int64 GetID(int meterIx, double time);
|
||||
}
|
||||
}
|
||||
|
||||
36
DataStreamInterfaceTest/ActivityLog.cs
Normal file
36
DataStreamInterfaceTest/ActivityLog.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public class ActivityLog
|
||||
{
|
||||
const int LinesCount = 50;
|
||||
|
||||
TextBox textBox;
|
||||
string[] lines;
|
||||
string activity;
|
||||
|
||||
public ActivityLog(TextBox textBox)
|
||||
{
|
||||
this.textBox = textBox;
|
||||
lines = new string[LinesCount];
|
||||
for (int i = 0; i < LinesCount; i++) lines[i] = string.Empty;
|
||||
}
|
||||
|
||||
public void Print(string log)
|
||||
{
|
||||
for (int i = LinesCount - 1; i > 0; i--) lines[i] = lines[i - 1];
|
||||
lines[0] = log;
|
||||
DisplayLines();
|
||||
}
|
||||
|
||||
private void DisplayLines()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var line in lines) sb.AppendLine(line);
|
||||
textBox.Text = sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
6
DataStreamInterfaceTest/App.config
Normal file
6
DataStreamInterfaceTest/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
134
DataStreamInterfaceTest/DataStreamInterfaceTest.csproj
Normal file
134
DataStreamInterfaceTest/DataStreamInterfaceTest.csproj
Normal file
@ -0,0 +1,134 @@
|
||||
<?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>{1D1EEF9C-7F41-43D3-BD09-5054D00F7A23}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataStreamInterfaceTest</RootNamespace>
|
||||
<AssemblyName>DataStreamInterfaceTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<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' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<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.ComponentModel.Composition" />
|
||||
<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.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActivityLog.cs" />
|
||||
<Compile Include="DemoMainWnd.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DemoMainWnd.Designer.cs">
|
||||
<DependentUpon>DemoMainWnd.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GetDblValueDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GetDblValueDlg.designer.cs">
|
||||
<DependentUpon>GetDblValueDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GetFrameBoundariesDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GetFrameBoundariesDlg.designer.cs">
|
||||
<DependentUpon>GetFrameBoundariesDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GetIntegerNumberDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GetIntegerNumberDlg.Designer.cs">
|
||||
<DependentUpon>GetIntegerNumberDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GetStateDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GetStateDlg.designer.cs">
|
||||
<DependentUpon>GetStateDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LviIDComparer.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="DemoMainWnd.resx">
|
||||
<DependentUpon>DemoMainWnd.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GetDblValueDlg.resx">
|
||||
<DependentUpon>GetDblValueDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GetFrameBoundariesDlg.resx">
|
||||
<DependentUpon>GetFrameBoundariesDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GetIntegerNumberDlg.resx">
|
||||
<DependentUpon>GetIntegerNumberDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GetStateDlg.resx">
|
||||
<DependentUpon>GetStateDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataStreamInterface\DataStreamInterface.csproj">
|
||||
<Project>{7ebeea14-91c4-48d7-af0a-7a4bc3ff9a28}</Project>
|
||||
<Name>DataStreamInterface</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
380
DataStreamInterfaceTest/DemoMainWnd.Designer.cs
generated
Normal file
380
DataStreamInterfaceTest/DemoMainWnd.Designer.cs
generated
Normal file
@ -0,0 +1,380 @@
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
partial class DemoMainWnd
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.getIDButton = new System.Windows.Forms.Button();
|
||||
this.getFramesButton = new System.Windows.Forms.Button();
|
||||
this.measurementLabel = new System.Windows.Forms.Label();
|
||||
this.stateLabel = new System.Windows.Forms.Label();
|
||||
this.capabilitiesLabel = new System.Windows.Forms.Label();
|
||||
this.getQuantityUnitsButton = new System.Windows.Forms.Button();
|
||||
this.getQuantityCaptionButton = new System.Windows.Forms.Button();
|
||||
this.getQuantitiesCountButton = new System.Windows.Forms.Button();
|
||||
this.getVolumeUnitsButton = new System.Windows.Forms.Button();
|
||||
this.getTimeUnitsButton = new System.Windows.Forms.Button();
|
||||
this.setStateButton = new System.Windows.Forms.Button();
|
||||
this.getStateButton = new System.Windows.Forms.Button();
|
||||
this.stopMeasurementButton = new System.Windows.Forms.Button();
|
||||
this.startMeasurementButton = new System.Windows.Forms.Button();
|
||||
this.closeConnectionButton = new System.Windows.Forms.Button();
|
||||
this.openConnectionButton = new System.Windows.Forms.Button();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.logsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dataTabControl = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.framesListView = new System.Windows.Forms.ListView();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
this.dataTabControl.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
|
||||
this.splitContainer1.IsSplitterFixed = true;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getIDButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getFramesButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.measurementLabel);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.stateLabel);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.capabilitiesLabel);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getQuantityUnitsButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getQuantityCaptionButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getQuantitiesCountButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getVolumeUnitsButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getTimeUnitsButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.setStateButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.getStateButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.stopMeasurementButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.startMeasurementButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.closeConnectionButton);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.openConnectionButton);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(826, 583);
|
||||
this.splitContainer1.SplitterDistance = 150;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// getIDButton
|
||||
//
|
||||
this.getIDButton.Location = new System.Drawing.Point(12, 480);
|
||||
this.getIDButton.Name = "getIDButton";
|
||||
this.getIDButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getIDButton.TabIndex = 12;
|
||||
this.getIDButton.Text = "Get ID";
|
||||
this.getIDButton.UseVisualStyleBackColor = true;
|
||||
this.getIDButton.Click += new System.EventHandler(this.getIDButton_Click);
|
||||
//
|
||||
// getFramesButton
|
||||
//
|
||||
this.getFramesButton.Location = new System.Drawing.Point(12, 450);
|
||||
this.getFramesButton.Name = "getFramesButton";
|
||||
this.getFramesButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getFramesButton.TabIndex = 11;
|
||||
this.getFramesButton.Text = "Get frames";
|
||||
this.getFramesButton.UseVisualStyleBackColor = true;
|
||||
this.getFramesButton.Click += new System.EventHandler(this.getFramesButton_Click);
|
||||
//
|
||||
// measurementLabel
|
||||
//
|
||||
this.measurementLabel.AutoSize = true;
|
||||
this.measurementLabel.Location = new System.Drawing.Point(12, 374);
|
||||
this.measurementLabel.Name = "measurementLabel";
|
||||
this.measurementLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.measurementLabel.TabIndex = 15;
|
||||
this.measurementLabel.Text = "Measurement:";
|
||||
//
|
||||
// stateLabel
|
||||
//
|
||||
this.stateLabel.AutoSize = true;
|
||||
this.stateLabel.Location = new System.Drawing.Point(12, 194);
|
||||
this.stateLabel.Name = "stateLabel";
|
||||
this.stateLabel.Size = new System.Drawing.Size(112, 13);
|
||||
this.stateLabel.TabIndex = 14;
|
||||
this.stateLabel.Text = "State and connection:";
|
||||
//
|
||||
// capabilitiesLabel
|
||||
//
|
||||
this.capabilitiesLabel.AutoSize = true;
|
||||
this.capabilitiesLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.capabilitiesLabel.Name = "capabilitiesLabel";
|
||||
this.capabilitiesLabel.Size = new System.Drawing.Size(63, 13);
|
||||
this.capabilitiesLabel.TabIndex = 13;
|
||||
this.capabilitiesLabel.Text = "Capabilities:";
|
||||
//
|
||||
// getQuantityUnitsButton
|
||||
//
|
||||
this.getQuantityUnitsButton.Location = new System.Drawing.Point(12, 145);
|
||||
this.getQuantityUnitsButton.Name = "getQuantityUnitsButton";
|
||||
this.getQuantityUnitsButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getQuantityUnitsButton.TabIndex = 4;
|
||||
this.getQuantityUnitsButton.Text = "Get quantity units";
|
||||
this.getQuantityUnitsButton.UseVisualStyleBackColor = true;
|
||||
this.getQuantityUnitsButton.Click += new System.EventHandler(this.getQuantityUnitsButton_Click);
|
||||
//
|
||||
// getQuantityCaptionButton
|
||||
//
|
||||
this.getQuantityCaptionButton.Location = new System.Drawing.Point(12, 115);
|
||||
this.getQuantityCaptionButton.Name = "getQuantityCaptionButton";
|
||||
this.getQuantityCaptionButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getQuantityCaptionButton.TabIndex = 3;
|
||||
this.getQuantityCaptionButton.Text = "Get quantity caption";
|
||||
this.getQuantityCaptionButton.UseVisualStyleBackColor = true;
|
||||
this.getQuantityCaptionButton.Click += new System.EventHandler(this.getQuantityCaptionButton_Click);
|
||||
//
|
||||
// getQuantitiesCountButton
|
||||
//
|
||||
this.getQuantitiesCountButton.Location = new System.Drawing.Point(12, 85);
|
||||
this.getQuantitiesCountButton.Name = "getQuantitiesCountButton";
|
||||
this.getQuantitiesCountButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getQuantitiesCountButton.TabIndex = 2;
|
||||
this.getQuantitiesCountButton.Text = "Get quantities count";
|
||||
this.getQuantitiesCountButton.UseVisualStyleBackColor = true;
|
||||
this.getQuantitiesCountButton.Click += new System.EventHandler(this.getQuantitiesCountButton_Click);
|
||||
//
|
||||
// getVolumeUnitsButton
|
||||
//
|
||||
this.getVolumeUnitsButton.Location = new System.Drawing.Point(12, 55);
|
||||
this.getVolumeUnitsButton.Name = "getVolumeUnitsButton";
|
||||
this.getVolumeUnitsButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getVolumeUnitsButton.TabIndex = 1;
|
||||
this.getVolumeUnitsButton.Text = "Get volume units";
|
||||
this.getVolumeUnitsButton.UseVisualStyleBackColor = true;
|
||||
this.getVolumeUnitsButton.Click += new System.EventHandler(this.getVolumeUnitsButton_Click);
|
||||
//
|
||||
// getTimeUnitsButton
|
||||
//
|
||||
this.getTimeUnitsButton.Location = new System.Drawing.Point(12, 25);
|
||||
this.getTimeUnitsButton.Name = "getTimeUnitsButton";
|
||||
this.getTimeUnitsButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getTimeUnitsButton.TabIndex = 0;
|
||||
this.getTimeUnitsButton.Text = "Get time units";
|
||||
this.getTimeUnitsButton.UseVisualStyleBackColor = true;
|
||||
this.getTimeUnitsButton.Click += new System.EventHandler(this.getTimeUnitsButton_Click);
|
||||
//
|
||||
// setStateButton
|
||||
//
|
||||
this.setStateButton.Location = new System.Drawing.Point(12, 315);
|
||||
this.setStateButton.Name = "setStateButton";
|
||||
this.setStateButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.setStateButton.TabIndex = 8;
|
||||
this.setStateButton.Text = "Set state";
|
||||
this.setStateButton.UseVisualStyleBackColor = true;
|
||||
this.setStateButton.Click += new System.EventHandler(this.setStateButton_Click);
|
||||
//
|
||||
// getStateButton
|
||||
//
|
||||
this.getStateButton.Location = new System.Drawing.Point(12, 285);
|
||||
this.getStateButton.Name = "getStateButton";
|
||||
this.getStateButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.getStateButton.TabIndex = 7;
|
||||
this.getStateButton.Text = "Get state";
|
||||
this.getStateButton.UseVisualStyleBackColor = true;
|
||||
this.getStateButton.Click += new System.EventHandler(this.getStateButton_Click);
|
||||
//
|
||||
// stopMeasurementButton
|
||||
//
|
||||
this.stopMeasurementButton.Location = new System.Drawing.Point(12, 420);
|
||||
this.stopMeasurementButton.Name = "stopMeasurementButton";
|
||||
this.stopMeasurementButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.stopMeasurementButton.TabIndex = 10;
|
||||
this.stopMeasurementButton.Text = "Stop measurement";
|
||||
this.stopMeasurementButton.UseVisualStyleBackColor = true;
|
||||
this.stopMeasurementButton.Click += new System.EventHandler(this.stopMeasurementButton_Click);
|
||||
//
|
||||
// startMeasurementButton
|
||||
//
|
||||
this.startMeasurementButton.Location = new System.Drawing.Point(12, 390);
|
||||
this.startMeasurementButton.Name = "startMeasurementButton";
|
||||
this.startMeasurementButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.startMeasurementButton.TabIndex = 9;
|
||||
this.startMeasurementButton.Text = "Start measurement";
|
||||
this.startMeasurementButton.UseVisualStyleBackColor = true;
|
||||
this.startMeasurementButton.Click += new System.EventHandler(this.startMeasurementButton_Click);
|
||||
//
|
||||
// closeConnectionButton
|
||||
//
|
||||
this.closeConnectionButton.Location = new System.Drawing.Point(12, 240);
|
||||
this.closeConnectionButton.Name = "closeConnectionButton";
|
||||
this.closeConnectionButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.closeConnectionButton.TabIndex = 6;
|
||||
this.closeConnectionButton.Text = "Close connection";
|
||||
this.closeConnectionButton.UseVisualStyleBackColor = true;
|
||||
this.closeConnectionButton.Click += new System.EventHandler(this.closeConnectionButton_Click);
|
||||
//
|
||||
// openConnectionButton
|
||||
//
|
||||
this.openConnectionButton.Location = new System.Drawing.Point(12, 210);
|
||||
this.openConnectionButton.Name = "openConnectionButton";
|
||||
this.openConnectionButton.Size = new System.Drawing.Size(128, 24);
|
||||
this.openConnectionButton.TabIndex = 5;
|
||||
this.openConnectionButton.Text = "Open connection";
|
||||
this.openConnectionButton.UseVisualStyleBackColor = true;
|
||||
this.openConnectionButton.Click += new System.EventHandler(this.openConnectionButton_Click);
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.Controls.Add(this.logsTextBox);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.dataTabControl);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(672, 583);
|
||||
this.splitContainer2.SplitterDistance = 222;
|
||||
this.splitContainer2.TabIndex = 0;
|
||||
//
|
||||
// logsTextBox
|
||||
//
|
||||
this.logsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.logsTextBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.logsTextBox.Multiline = true;
|
||||
this.logsTextBox.Name = "logsTextBox";
|
||||
this.logsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.logsTextBox.Size = new System.Drawing.Size(672, 222);
|
||||
this.logsTextBox.TabIndex = 0;
|
||||
//
|
||||
// dataTabControl
|
||||
//
|
||||
this.dataTabControl.Controls.Add(this.tabPage1);
|
||||
this.dataTabControl.Controls.Add(this.tabPage2);
|
||||
this.dataTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataTabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataTabControl.Name = "dataTabControl";
|
||||
this.dataTabControl.SelectedIndex = 0;
|
||||
this.dataTabControl.Size = new System.Drawing.Size(672, 357);
|
||||
this.dataTabControl.TabIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.framesListView);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(664, 331);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Transferred frames";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// framesListView
|
||||
//
|
||||
this.framesListView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.framesListView.GridLines = true;
|
||||
this.framesListView.Location = new System.Drawing.Point(3, 3);
|
||||
this.framesListView.Name = "framesListView";
|
||||
this.framesListView.Size = new System.Drawing.Size(658, 325);
|
||||
this.framesListView.TabIndex = 0;
|
||||
this.framesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.framesListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(664, 331);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Graph";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// DemoMainWnd
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(826, 583);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Name = "DemoMainWnd";
|
||||
this.Text = "Datastream interface test";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DemoMainWnd_FormClosing);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.PerformLayout();
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
this.dataTabControl.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.Button openConnectionButton;
|
||||
private System.Windows.Forms.Button closeConnectionButton;
|
||||
private System.Windows.Forms.Button stopMeasurementButton;
|
||||
private System.Windows.Forms.Button startMeasurementButton;
|
||||
private System.Windows.Forms.Button setStateButton;
|
||||
private System.Windows.Forms.Button getStateButton;
|
||||
private System.Windows.Forms.Button getQuantityUnitsButton;
|
||||
private System.Windows.Forms.Button getQuantityCaptionButton;
|
||||
private System.Windows.Forms.Button getQuantitiesCountButton;
|
||||
private System.Windows.Forms.Button getVolumeUnitsButton;
|
||||
private System.Windows.Forms.Button getTimeUnitsButton;
|
||||
private System.Windows.Forms.Label measurementLabel;
|
||||
private System.Windows.Forms.Label stateLabel;
|
||||
private System.Windows.Forms.Label capabilitiesLabel;
|
||||
private System.Windows.Forms.Button getIDButton;
|
||||
private System.Windows.Forms.Button getFramesButton;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.TextBox logsTextBox;
|
||||
private System.Windows.Forms.TabControl dataTabControl;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.ListView framesListView;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
}
|
||||
}
|
||||
|
||||
292
DataStreamInterfaceTest/DemoMainWnd.cs
Normal file
292
DataStreamInterfaceTest/DemoMainWnd.cs
Normal file
@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DataStreamInterface;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public partial class DemoMainWnd : Form
|
||||
{
|
||||
IDataStreamMeter dataStreamMeter;
|
||||
|
||||
ActivityLog activityLog;
|
||||
|
||||
Unit timeUnits;
|
||||
Unit volumeUnits;
|
||||
int quantitiesCount;
|
||||
string[] quantityCaption;
|
||||
Unit[] quantityUnit;
|
||||
|
||||
Int64 storedFramesCount;
|
||||
DataFrame[] transferredFrames;
|
||||
|
||||
public DemoMainWnd() : this(null) { }
|
||||
|
||||
public DemoMainWnd(IDataStreamMeter dataStreamMeter)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.dataStreamMeter = dataStreamMeter;
|
||||
activityLog = new ActivityLog(logsTextBox);
|
||||
|
||||
framesListView.Columns.Add("ID", 100);
|
||||
framesListView.Columns.Add("Time", 100);
|
||||
framesListView.Columns.Add("Volume", 100);
|
||||
framesListView.Columns.Add("Additional quantities", 300);
|
||||
framesListView.ListViewItemSorter = new LviIDComparer();
|
||||
}
|
||||
|
||||
void ShowNoMeterInterfaceMessage()
|
||||
{
|
||||
MessageBox.Show("No datastream meter interface");
|
||||
}
|
||||
|
||||
private void getTimeUnitsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
timeUnits = dataStreamMeter.GetTimeUnits();
|
||||
activityLog.Print(string.Format("Time units are {0}", timeUnits));
|
||||
}
|
||||
}
|
||||
|
||||
private void getVolumeUnitsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
volumeUnits = dataStreamMeter.GetVolumeUnits();
|
||||
activityLog.Print(string.Format("Volume units are {0}", volumeUnits));
|
||||
}
|
||||
}
|
||||
|
||||
private void getQuantitiesCountButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
int quantitesCountOri = quantitiesCount;
|
||||
quantitiesCount = dataStreamMeter.GetQuantitiesCount();
|
||||
activityLog.Print(string.Format("There are {0} additional quantites", quantitiesCount));
|
||||
|
||||
if (quantitesCountOri == 0)
|
||||
{
|
||||
quantityUnit = new Unit[quantitiesCount];
|
||||
quantityCaption = new string[quantitiesCount];
|
||||
for (int i = 0; i < quantitiesCount; i++) quantityCaption[i] = string.Empty;
|
||||
}
|
||||
else if (quantitiesCount != quantitesCountOri)
|
||||
{
|
||||
quantityUnit = new Unit[quantitiesCount];
|
||||
quantityCaption = new string[quantitiesCount];
|
||||
for (int i = 0; i < quantitiesCount; i++) quantityCaption[i] = string.Empty;
|
||||
|
||||
activityLog.Print(string.Format("Quantities count changed during operation"));
|
||||
MessageBox.Show("Quantities count changed during operation", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getQuantityCaptionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
GetIntegerNumberDlg dlg = new GetIntegerNumberDlg(string.Format("Enter index {0} .. {1}", 0, quantitiesCount - 1), 0, quantitiesCount - 1);
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
quantityCaption[dlg.Number] = dataStreamMeter.GetQuantityCaption(dlg.Number);
|
||||
activityLog.Print(string.Format("Caption of quantity #{0} is {1}", dlg.Number, quantityCaption[dlg.Number]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getQuantityUnitsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
GetIntegerNumberDlg dlg = new GetIntegerNumberDlg(string.Format("Enter index {0} .. {1}", 0, quantitiesCount - 1), 0, quantitiesCount - 1);
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
quantityUnit[dlg.Number] = dataStreamMeter.GetQuantityUnits(dlg.Number);
|
||||
activityLog.Print(string.Format("Units of quantity #{0} are {1}", dlg.Number, quantityUnit[dlg.Number]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openConnectionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
string meterId;
|
||||
if (dataStreamMeter.OpenConnection(0, "no connection parameters", out meterId))
|
||||
{
|
||||
activityLog.Print(string.Format("Connection established, meter ID is {0}", meterId));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print("Failed to establish a connection");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeConnectionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
if (dataStreamMeter.CloseConnection(0))
|
||||
{
|
||||
framesListView.Items.Clear();
|
||||
activityLog.Print("Connection closed");
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print("Failed to close the connection");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DemoMainWnd_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
{
|
||||
dataStreamMeter.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void getStateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
int state;
|
||||
string parameter;
|
||||
if (dataStreamMeter.GetState(0, out state, out parameter))
|
||||
{
|
||||
activityLog.Print(string.Format("Water meter state is {0} / {1}", state, parameter));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print("Failed to obtain the water meter state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
GetStateDlg dlg = new GetStateDlg();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (dataStreamMeter.SetState(0, dlg.State, dlg.Parameter))
|
||||
{
|
||||
activityLog.Print(string.Format("Water meter state set to {0} / {1}", dlg.State, dlg.Parameter));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print(string.Format("Failed to set the water meter state to {0} / {1}", dlg.State, dlg.Parameter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startMeasurementButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
if (dataStreamMeter.StartMeasurement(0))
|
||||
{
|
||||
framesListView.Items.Clear();
|
||||
activityLog.Print(string.Format("Measurement started"));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print("Failed to start a measurement");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stopMeasurementButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
if (dataStreamMeter.StopMeasurement(0, out storedFramesCount))
|
||||
{
|
||||
framesListView.Items.Clear();
|
||||
activityLog.Print(string.Format("Measurement sopped, {0} frames acquired", storedFramesCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityLog.Print("Failed to stop the measurement");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getFramesButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
GetFrameBoundariesDlg dlg = new GetFrameBoundariesDlg("Enter frames range boundaries", 0, storedFramesCount - 1);
|
||||
if (dlg.ShowDialog() != DialogResult.OK) return;
|
||||
DataFrame[] frames = dataStreamMeter.GetFrames(0, dlg.From, Convert.ToInt32(dlg.To - dlg.From + 1));
|
||||
{
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
if (frame != null) framesListView.Items.Add(GetListViewItem(frame));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getIDButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataStreamMeter == null)
|
||||
ShowNoMeterInterfaceMessage();
|
||||
else
|
||||
{
|
||||
GetDblValueDlg dlg = new GetDblValueDlg("Enter time in seconds");
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Int64 id = dataStreamMeter.GetID(0, dlg.DblValue);
|
||||
activityLog.Print(string.Format("GetID({0}) returned {1}", dlg.DblValue, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListViewItem GetListViewItem(DataFrame frame)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(frame.ID.ToString());
|
||||
lvi.SubItems.Add(frame.Time.ToString());
|
||||
lvi.SubItems.Add(frame.Volume.ToString());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var quantity in frame.Quantity)
|
||||
{
|
||||
sb.Append(quantity.ToString());
|
||||
sb.Append(" ");
|
||||
}
|
||||
lvi.SubItems.Add(sb.ToString());
|
||||
lvi.Tag = frame;
|
||||
return lvi;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
DataStreamInterfaceTest/GetDblValueDlg.Designer.cs
generated
Normal file
88
DataStreamInterfaceTest/GetDblValueDlg.Designer.cs
generated
Normal file
@ -0,0 +1,88 @@
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
partial class GetDblValueDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.valueTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// valueTextBox
|
||||
//
|
||||
this.valueTextBox.Location = new System.Drawing.Point(35, 20);
|
||||
this.valueTextBox.Name = "valueTextBox";
|
||||
this.valueTextBox.Size = new System.Drawing.Size(94, 20);
|
||||
this.valueTextBox.TabIndex = 0;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(216, 16);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(306, 16);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GetFlowDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(396, 58);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.valueTextBox);
|
||||
this.Name = "GetFlowDlg";
|
||||
this.Text = "Enter flow";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox valueTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
||||
59
DataStreamInterfaceTest/GetDblValueDlg.cs
Normal file
59
DataStreamInterfaceTest/GetDblValueDlg.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public partial class GetDblValueDlg : Form
|
||||
{
|
||||
public double DblValue;
|
||||
|
||||
double lowerLimit;
|
||||
double upperLimit;
|
||||
|
||||
|
||||
public GetDblValueDlg()
|
||||
: this("Enter flow in [m3/h] please")
|
||||
{
|
||||
}
|
||||
|
||||
public GetDblValueDlg(string title)
|
||||
: this(title, 0, 100.0)
|
||||
{
|
||||
}
|
||||
|
||||
public GetDblValueDlg(string title, double lowerLimit, double upperLimit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = title;
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
double val;
|
||||
if (TryParseUDouble(valueTextBox.Text, out val))
|
||||
{
|
||||
DblValue = val;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid value");
|
||||
DialogResult = DialogResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an unsigned double number
|
||||
/// </summary>
|
||||
bool TryParseUDouble(string text, out double result)
|
||||
{
|
||||
return double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out result) ||
|
||||
double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
|
||||
}
|
||||
}
|
||||
}
|
||||
126
DataStreamInterfaceTest/GetFrameBoundariesDlg.Designer.cs
generated
Normal file
126
DataStreamInterfaceTest/GetFrameBoundariesDlg.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
partial class GetFrameBoundariesDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.fromTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.toTextBox = new System.Windows.Forms.TextBox();
|
||||
this.fromLabel = new System.Windows.Forms.Label();
|
||||
this.toLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// fromTextBox
|
||||
//
|
||||
this.fromTextBox.Location = new System.Drawing.Point(89, 16);
|
||||
this.fromTextBox.Name = "fromTextBox";
|
||||
this.fromTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.fromTextBox.TabIndex = 0;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(225, 24);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(316, 24);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// toTextBox
|
||||
//
|
||||
this.toTextBox.Location = new System.Drawing.Point(89, 46);
|
||||
this.toTextBox.Name = "toTextBox";
|
||||
this.toTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.toTextBox.TabIndex = 3;
|
||||
//
|
||||
// fromLabel
|
||||
//
|
||||
this.fromLabel.AutoSize = true;
|
||||
this.fromLabel.Location = new System.Drawing.Point(12, 19);
|
||||
this.fromLabel.Name = "fromLabel";
|
||||
this.fromLabel.Size = new System.Drawing.Size(30, 13);
|
||||
this.fromLabel.TabIndex = 4;
|
||||
this.fromLabel.Text = "From";
|
||||
//
|
||||
// toLabel
|
||||
//
|
||||
this.toLabel.AutoSize = true;
|
||||
this.toLabel.Location = new System.Drawing.Point(12, 49);
|
||||
this.toLabel.Name = "toLabel";
|
||||
this.toLabel.Size = new System.Drawing.Size(20, 13);
|
||||
this.toLabel.TabIndex = 5;
|
||||
this.toLabel.Text = "To";
|
||||
//
|
||||
// GetFrameBoundariesDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(419, 79);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.toLabel);
|
||||
this.Controls.Add(this.fromLabel);
|
||||
this.Controls.Add(this.toTextBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.fromTextBox);
|
||||
this.Name = "GetFrameBoundariesDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Enter frames range boundaries";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox fromTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.TextBox toTextBox;
|
||||
private System.Windows.Forms.Label fromLabel;
|
||||
private System.Windows.Forms.Label toLabel;
|
||||
}
|
||||
}
|
||||
88
DataStreamInterfaceTest/GetFrameBoundariesDlg.cs
Normal file
88
DataStreamInterfaceTest/GetFrameBoundariesDlg.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public partial class GetFrameBoundariesDlg : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Integer number entered in this form
|
||||
/// </summary>
|
||||
public Int64 From;
|
||||
public Int64 To;
|
||||
|
||||
Int64 lowerLimit;
|
||||
Int64 upperLimit;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public GetFrameBoundariesDlg()
|
||||
: this("Enter state please")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
public GetFrameBoundariesDlg(string title)
|
||||
: this(title, Int64.MinValue, Int64.MaxValue)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title, limits and non-empty initial value.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
/// <param name="initialValue">Initial value</param>
|
||||
public GetFrameBoundariesDlg(string title, Int64 lowerLimit, Int64 upperLimit, int initialValue)
|
||||
: this(title, lowerLimit, upperLimit)
|
||||
{
|
||||
fromTextBox.Text = initialValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title and lower/upper limits.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
public GetFrameBoundariesDlg(string title, Int64 lowerLimit, Int64 upperLimit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = title;
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// OK button handler that verifies validity of the entered value.
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Int64 from;
|
||||
Int64 to;
|
||||
if (Int64.TryParse(fromTextBox.Text, out from) && from >= lowerLimit && from <= upperLimit &&
|
||||
Int64.TryParse(toTextBox.Text, out to) && to >= lowerLimit && to <= upperLimit &&
|
||||
to >= from && to < from + Int32.MaxValue)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = (lowerLimit != 0 || upperLimit != Int32.MaxValue)
|
||||
? string.Format("Invalid boundaries ({0}..{1})", lowerLimit, upperLimit)
|
||||
: "Invalid boundaries";
|
||||
MessageBox.Show(message);
|
||||
DialogResult = DialogResult.None; /// Prevent closing this window
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
90
DataStreamInterfaceTest/GetIntegerNumberDlg.Designer.cs
generated
Normal file
90
DataStreamInterfaceTest/GetIntegerNumberDlg.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
partial class GetIntegerNumberDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.numberTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// numberTextBox
|
||||
//
|
||||
this.numberTextBox.Location = new System.Drawing.Point(36, 16);
|
||||
this.numberTextBox.Name = "numberTextBox";
|
||||
this.numberTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.numberTextBox.TabIndex = 0;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(174, 7);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(265, 7);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GetIntegerNumberDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(363, 50);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.numberTextBox);
|
||||
this.Name = "GetIntegerNumberDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Enter integer number please";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox numberTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
||||
83
DataStreamInterfaceTest/GetIntegerNumberDlg.cs
Normal file
83
DataStreamInterfaceTest/GetIntegerNumberDlg.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public partial class GetIntegerNumberDlg : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Integer number entered in this form
|
||||
/// </summary>
|
||||
public int Number;
|
||||
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public GetIntegerNumberDlg()
|
||||
: this("Enter integer number please")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
public GetIntegerNumberDlg(string title)
|
||||
: this(title, Int32.MinValue, Int32.MaxValue)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title, limits and non-empty initial value.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
/// <param name="initialValue">Initial value</param>
|
||||
public GetIntegerNumberDlg(string title, int lowerLimit, int upperLimit, int initialValue)
|
||||
: this(title, lowerLimit, upperLimit)
|
||||
{
|
||||
numberTextBox.Text = initialValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title and lower/upper limits.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
public GetIntegerNumberDlg(string title, int lowerLimit, int upperLimit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = title;
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// OK button handler that verifies validity of the entered value.
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int number;
|
||||
if (int.TryParse(numberTextBox.Text, out number) && number >= lowerLimit && number <= upperLimit)
|
||||
{
|
||||
Number = number;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = (lowerLimit != Int32.MinValue || upperLimit != Int32.MaxValue)
|
||||
? string.Format("Invalid integer number ({0}..{1})", lowerLimit, upperLimit)
|
||||
: "Invalid integer number";
|
||||
MessageBox.Show(message);
|
||||
DialogResult = DialogResult.None; /// Prevent closing this window
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
126
DataStreamInterfaceTest/GetStateDlg.Designer.cs
generated
Normal file
126
DataStreamInterfaceTest/GetStateDlg.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
partial class GetStateDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.stateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.parameterTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stateLabel = new System.Windows.Forms.Label();
|
||||
this.parameterLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stateTextBox
|
||||
//
|
||||
this.stateTextBox.Location = new System.Drawing.Point(89, 16);
|
||||
this.stateTextBox.Name = "stateTextBox";
|
||||
this.stateTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.stateTextBox.TabIndex = 0;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(225, 24);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(316, 24);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 36);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// parameterTextBox
|
||||
//
|
||||
this.parameterTextBox.Location = new System.Drawing.Point(89, 46);
|
||||
this.parameterTextBox.Name = "parameterTextBox";
|
||||
this.parameterTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.parameterTextBox.TabIndex = 3;
|
||||
//
|
||||
// stateLabel
|
||||
//
|
||||
this.stateLabel.AutoSize = true;
|
||||
this.stateLabel.Location = new System.Drawing.Point(12, 19);
|
||||
this.stateLabel.Name = "stateLabel";
|
||||
this.stateLabel.Size = new System.Drawing.Size(32, 13);
|
||||
this.stateLabel.TabIndex = 4;
|
||||
this.stateLabel.Text = "State";
|
||||
//
|
||||
// parameterLabel
|
||||
//
|
||||
this.parameterLabel.AutoSize = true;
|
||||
this.parameterLabel.Location = new System.Drawing.Point(12, 49);
|
||||
this.parameterLabel.Name = "parameterLabel";
|
||||
this.parameterLabel.Size = new System.Drawing.Size(55, 13);
|
||||
this.parameterLabel.TabIndex = 5;
|
||||
this.parameterLabel.Text = "Parameter";
|
||||
//
|
||||
// GetStateDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(419, 79);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.parameterLabel);
|
||||
this.Controls.Add(this.stateLabel);
|
||||
this.Controls.Add(this.parameterTextBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.stateTextBox);
|
||||
this.Name = "GetStateDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Enter state please";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox stateTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.TextBox parameterTextBox;
|
||||
private System.Windows.Forms.Label stateLabel;
|
||||
private System.Windows.Forms.Label parameterLabel;
|
||||
}
|
||||
}
|
||||
85
DataStreamInterfaceTest/GetStateDlg.cs
Normal file
85
DataStreamInterfaceTest/GetStateDlg.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public partial class GetStateDlg : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Integer number entered in this form
|
||||
/// </summary>
|
||||
public int State;
|
||||
public string Parameter;
|
||||
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public GetStateDlg()
|
||||
: this("Enter state please")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
public GetStateDlg(string title)
|
||||
: this(title, Int32.MinValue, Int32.MaxValue)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title, limits and non-empty initial value.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
/// <param name="initialValue">Initial value</param>
|
||||
public GetStateDlg(string title, int lowerLimit, int upperLimit, int initialValue)
|
||||
: this(title, lowerLimit, upperLimit)
|
||||
{
|
||||
stateTextBox.Text = initialValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with a custom window title and lower/upper limits.
|
||||
/// </summary>
|
||||
/// <param name="title">Window title</param>
|
||||
/// <param name="lowerLimit">Lower limit</param>
|
||||
/// <param name="upperLimit">Upper limit</param>
|
||||
public GetStateDlg(string title, int lowerLimit, int upperLimit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = title;
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// OK button handler that verifies validity of the entered value.
|
||||
/// </summary>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
int number;
|
||||
if (int.TryParse(stateTextBox.Text, out number) && number >= lowerLimit && number <= upperLimit)
|
||||
{
|
||||
State = number;
|
||||
Parameter = parameterTextBox.Text;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = (lowerLimit != Int32.MinValue || upperLimit != Int32.MaxValue)
|
||||
? string.Format("Invalid state ({0}..{1})", lowerLimit, upperLimit)
|
||||
: "Invalid state";
|
||||
MessageBox.Show(message);
|
||||
DialogResult = DialogResult.None; /// Prevent closing this window
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
DataStreamInterfaceTest/LviIDComparer.cs
Normal file
39
DataStreamInterfaceTest/LviIDComparer.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
public class LviIDComparer : IComparer
|
||||
{
|
||||
int column;
|
||||
SortOrder order;
|
||||
|
||||
public LviIDComparer()
|
||||
{
|
||||
column = 0;
|
||||
order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
public LviIDComparer(int column, SortOrder order)
|
||||
{
|
||||
this.column = column;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
Int64 valX = Int64.Parse(((ListViewItem)x).SubItems[column].Text);
|
||||
Int64 valY = Int64.Parse(((ListViewItem)y).SubItems[column].Text);
|
||||
|
||||
if (order == SortOrder.Ascending)
|
||||
{
|
||||
return valX > valY ? 1 : valX == valY ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return valX < valY ? 1 : valX == valY ? 0 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
DataStreamInterfaceTest/Program.cs
Normal file
55
DataStreamInterfaceTest/Program.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.ComponentModel.Composition.Hosting;
|
||||
using System.Windows.Forms;
|
||||
using DataStreamInterface;
|
||||
|
||||
namespace DataStreamInterfaceTest
|
||||
{
|
||||
class Program
|
||||
{
|
||||
#if DEBUG
|
||||
const string CatalogDir = "..\\..\\..\\DataStreamMeter\\bin\\Debug";
|
||||
#else
|
||||
const string CatalogDir = "..\\..\\..\\DataStreamMeter\\bin\\Release";
|
||||
#endif
|
||||
|
||||
[Import(typeof(IDataStreamMeter))]
|
||||
IDataStreamMeter dataStreamMeter;
|
||||
|
||||
private Program()
|
||||
{
|
||||
Console.WriteLine("Components found:");
|
||||
foreach (var file in Directory.EnumerateFiles(CatalogDir))
|
||||
{
|
||||
Console.WriteLine(file);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var catalog = new AggregateCatalog();
|
||||
catalog.Catalogs.Add(new AssemblyCatalog(typeof(DataStreamInterface.IDataStreamMeter).Assembly));
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(CatalogDir));
|
||||
(new CompositionContainer(catalog)).ComposeParts(this);
|
||||
}
|
||||
catch (CompositionException compositionException)
|
||||
{
|
||||
Console.WriteLine(compositionException.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Program p = new Program();
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new DemoMainWnd(p.dataStreamMeter));
|
||||
}
|
||||
}
|
||||
}
|
||||
36
DataStreamInterfaceTest/Properties/AssemblyInfo.cs
Normal file
36
DataStreamInterfaceTest/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 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("DataStreamInterfaceTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DataStreamInterfaceTest")]
|
||||
[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("429fdea9-ec3a-47d8-88b3-5df11de8b4c8")]
|
||||
|
||||
// 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")]
|
||||
71
DataStreamInterfaceTest/Properties/Resources.Designer.cs
generated
Normal file
71
DataStreamInterfaceTest/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DataStreamInterfaceTest.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataStreamMainDemo.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
DataStreamInterfaceTest/Properties/Resources.resx
Normal file
117
DataStreamInterfaceTest/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
DataStreamInterfaceTest/Properties/Settings.Designer.cs
generated
Normal file
30
DataStreamInterfaceTest/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DataStreamInterfaceTest.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
DataStreamInterfaceTest/Properties/Settings.settings
Normal file
7
DataStreamInterfaceTest/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
85
DataStreamMeter/DataStreamMeter.csproj
Normal file
85
DataStreamMeter/DataStreamMeter.csproj
Normal file
@ -0,0 +1,85 @@
|
||||
<?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>{E6925701-57A6-4167-B5C4-BF670F1DE310}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataStreamMeter</RootNamespace>
|
||||
<AssemblyName>DataStreamMeter</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</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.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<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="GetDblValueDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GetDblValueDlg.Designer.cs">
|
||||
<DependentUpon>GetDblValueDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MeterDataEventArgs.cs" />
|
||||
<Compile Include="MeterSimulationDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MeterSimulationDlg.Designer.cs">
|
||||
<DependentUpon>MeterSimulationDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MeterSimulation.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Sample.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataStreamInterface\DataStreamInterface.csproj">
|
||||
<Project>{7ebeea14-91c4-48d7-af0a-7a4bc3ff9a28}</Project>
|
||||
<Name>DataStreamInterface</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GetDblValueDlg.resx">
|
||||
<DependentUpon>GetDblValueDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MeterSimulationDlg.resx">
|
||||
<DependentUpon>MeterSimulationDlg.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</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>
|
||||
88
DataStreamMeter/GetDblValueDlg.Designer.cs
generated
Normal file
88
DataStreamMeter/GetDblValueDlg.Designer.cs
generated
Normal file
@ -0,0 +1,88 @@
|
||||
namespace DataStreamMeter
|
||||
{
|
||||
partial class GetDblValueDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.valueTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// valueTextBox
|
||||
//
|
||||
this.valueTextBox.Location = new System.Drawing.Point(35, 20);
|
||||
this.valueTextBox.Name = "valueTextBox";
|
||||
this.valueTextBox.Size = new System.Drawing.Size(94, 20);
|
||||
this.valueTextBox.TabIndex = 0;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.Location = new System.Drawing.Point(216, 16);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.okButton.TabIndex = 1;
|
||||
this.okButton.Text = "OK";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(306, 16);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 29);
|
||||
this.cancelButton.TabIndex = 2;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GetFlowDlg
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(396, 58);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.valueTextBox);
|
||||
this.Name = "GetFlowDlg";
|
||||
this.Text = "Enter flow";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox valueTextBox;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
||||
59
DataStreamMeter/GetDblValueDlg.cs
Normal file
59
DataStreamMeter/GetDblValueDlg.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataStreamMeter
|
||||
{
|
||||
public partial class GetDblValueDlg : Form
|
||||
{
|
||||
public double DblValue;
|
||||
|
||||
double lowerLimit;
|
||||
double upperLimit;
|
||||
|
||||
|
||||
public GetDblValueDlg()
|
||||
: this("Enter flow in [m3/h] please")
|
||||
{
|
||||
}
|
||||
|
||||
public GetDblValueDlg(string title)
|
||||
: this(title, 0, 100.0)
|
||||
{
|
||||
}
|
||||
|
||||
public GetDblValueDlg(string title, double lowerLimit, double upperLimit)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Text = title;
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
double val;
|
||||
if (TryParseUDouble(valueTextBox.Text, out val))
|
||||
{
|
||||
DblValue = val;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid value");
|
||||
DialogResult = DialogResult.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an unsigned double number
|
||||
/// </summary>
|
||||
bool TryParseUDouble(string text, out double result)
|
||||
{
|
||||
return double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out result) ||
|
||||
double.TryParse(text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user