Compare commits
632
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ebebffffc | ||
|
|
96bb0a8a9c | ||
|
|
30d525e0b1 | ||
|
|
0186ac443f | ||
|
|
bfa506911c | ||
|
|
a2432927ee | ||
|
|
126a0e2663 | ||
|
|
f3f6ad4291 | ||
|
|
ffc70efaf4 | ||
|
|
951a62ad06 | ||
|
|
d8d8f24843 | ||
|
|
c75e88c871 | ||
|
|
47af8c11d3 | ||
|
|
6c85732748 | ||
|
|
8cd3b6a7b0 | ||
|
|
d1ef582349 | ||
|
|
6d47789708 | ||
|
|
66a31fc1e9 | ||
|
|
d84c3ca4d8 | ||
|
|
98c8b0e7a8 | ||
|
|
68c4bf5956 | ||
|
|
b131ba01a8 | ||
|
|
f5642a2676 | ||
|
|
1585066b57 | ||
|
|
1ee5724082 | ||
|
|
511d86a186 | ||
|
|
d91ca4b56b | ||
|
|
e14dc37060 | ||
|
|
1e058726d4 | ||
|
|
26982a5729 | ||
|
|
494c6edf76 | ||
|
|
61bfa51fa7 | ||
|
|
81fe244c23 | ||
|
|
98f74fa971 | ||
|
|
bb260426c9 | ||
|
|
02b31634f8 | ||
|
|
35c449bd0c | ||
|
|
2b7f6a8dac | ||
|
|
2a4eeb2d77 | ||
|
|
a08be1ee73 | ||
|
|
21390eaba6 | ||
|
|
5f0c56b19f | ||
|
|
714780d0b6 | ||
|
|
d852e390b3 | ||
|
|
bb2087c002 | ||
|
|
15ac3608c4 | ||
|
|
e4e8c97cfd | ||
|
|
3ef8674caf | ||
|
|
58a2be10aa | ||
|
|
bcae594b3f | ||
|
|
763acec379 | ||
|
|
12bd4e80dd | ||
|
|
4f456e0c40 | ||
|
|
c6ef378bc9 | ||
|
|
9689080387 | ||
|
|
6ecddf07f6 | ||
|
|
89ecf478ba | ||
|
|
d9e7efa15a | ||
|
|
6e6edde77f | ||
|
|
b2c944f9b1 | ||
|
|
852ffd0602 | ||
|
|
a06fe00440 | ||
|
|
8c1c5ed4f0 | ||
|
|
123187aa8a | ||
|
|
644c26355c | ||
|
|
432b288c34 | ||
|
|
f6cec9d769 | ||
|
|
29ece2f91c | ||
|
|
e3aa3f6721 | ||
|
|
b1ccdcb5c1 | ||
|
|
a541ac4945 | ||
|
|
38cbcb6430 | ||
|
|
c593ed903e | ||
|
|
d488f62648 | ||
|
|
aefbcdb2a0 | ||
|
|
c1bdb53a4d | ||
|
|
38dc09af7f | ||
|
|
d83b497fa0 | ||
|
|
5b31a94b74 | ||
|
|
ee1afaa78b | ||
|
|
910d5d58dc | ||
|
|
6dfba78dbf | ||
|
|
cd98f30ad2 | ||
|
|
893b7af55a | ||
|
|
3bb8cb2ab7 | ||
|
|
22b1fbca90 | ||
|
|
ddcfa71273 | ||
|
|
8d123d306f | ||
|
|
a380a68855 | ||
|
|
39d0a73e39 | ||
|
|
a01f99fa7e | ||
|
|
8a0411bd92 | ||
|
|
8cd4f12de3 | ||
|
|
4a528dafb8 | ||
|
|
b3a9302f53 | ||
|
|
575b17a919 | ||
|
|
41433329da | ||
|
|
e52f9ea9e7 | ||
|
|
1892f9de9f | ||
|
|
db0c850d70 | ||
|
|
060aba08a9 | ||
|
|
5ac7572a3d | ||
|
|
c9e2742745 | ||
|
|
5a77c5f660 | ||
|
|
1301db3af4 | ||
|
|
2cd877fb17 | ||
|
|
9dc3759f99 | ||
|
|
66f1bfa14b | ||
|
|
d7c262c87a | ||
|
|
02da6ae134 | ||
|
|
3336454719 | ||
|
|
5967db86a1 | ||
|
|
2acd67707e | ||
|
|
70f38e9352 | ||
|
|
687e843e5f | ||
|
|
43eaa61007 | ||
|
|
518d87afe1 | ||
|
|
f2676993b1 | ||
|
|
786485f566 | ||
|
|
e3df943946 | ||
|
|
bdd2f5f89d | ||
|
|
6318ce7700 | ||
|
|
5e9f9e7425 | ||
|
|
7ca07d78c6 | ||
|
|
69a51908c2 | ||
|
|
656ef27a3b | ||
|
|
72754ebe10 | ||
|
|
d7e6a69ca9 | ||
|
|
2985338d7e | ||
|
|
120c1cc39d | ||
|
|
f203c56e8b | ||
|
|
b3dc49e8b7 | ||
|
|
8c796eaeee | ||
|
|
c45f8298ac | ||
|
|
4a35215be9 | ||
|
|
62cd81b5f7 | ||
|
|
7afb780d5b | ||
|
|
cdb8304287 | ||
|
|
ebda3f5127 | ||
|
|
06c46785f6 | ||
|
|
e230ce02bf | ||
|
|
2a0fbca1e0 | ||
|
|
2845cf20f5 | ||
|
|
e9440411bc | ||
|
|
d041cd1d20 | ||
|
|
264830a36b | ||
|
|
558f000198 | ||
|
|
cb4833664c | ||
|
|
d5cb6ca71b | ||
|
|
7827fa4e5b | ||
|
|
d1944753b3 | ||
|
|
c6007d3b6a | ||
|
|
91a4ca3760 | ||
|
|
36e0c177c7 | ||
|
|
e13b553ab5 | ||
|
|
2799522a22 | ||
|
|
3e86aa99cb | ||
|
|
ebbc0528c6 | ||
|
|
1d8156e4d7 | ||
|
|
fcf4f6bdcf | ||
|
|
08aed03cef | ||
|
|
da01b1fe61 | ||
|
|
d4399c23ca | ||
|
|
31fc49485a | ||
|
|
217ceffa67 | ||
|
|
6b10e67c17 | ||
|
|
76b9f64029 | ||
|
|
cabee1f06e | ||
|
|
421474b990 | ||
|
|
6a7e1e5052 | ||
|
|
f24cd89928 | ||
|
|
2b8f5ebec3 | ||
|
|
f3dabcbcc1 | ||
|
|
d390705df8 | ||
|
|
f75138eced | ||
|
|
46b17fddc8 | ||
|
|
5d00bcf456 | ||
|
|
db8598579d | ||
|
|
be1344034e | ||
|
|
a0c3ffd01a | ||
|
|
4faf6b5d69 | ||
|
|
2e04076b30 | ||
|
|
20762b7fde | ||
|
|
440199b3bc | ||
|
|
3647740d4a | ||
|
|
b8d9e1aa12 | ||
|
|
3ebeb4a0dc | ||
|
|
33963ec8cf | ||
|
|
fa6b99b980 | ||
|
|
22c652ad24 | ||
|
|
c376e67eab | ||
|
|
e349d6811d | ||
|
|
7b134f7ba5 | ||
|
|
7f46e64a0d | ||
|
|
ed4afff0b2 | ||
|
|
713fd9d0ae | ||
|
|
5db53ca6e3 | ||
|
|
752bfd98b1 | ||
|
|
e302cb9335 | ||
|
|
a6aa6739ad | ||
|
|
ee044e3dd7 | ||
|
|
68a038d321 | ||
|
|
a0cf76112d | ||
|
|
5f5ac87f42 | ||
|
|
f85fbd0b55 | ||
|
|
90cfda893c | ||
|
|
1bf987a6cd | ||
|
|
4166bf8d87 | ||
|
|
bf376b4ff0 | ||
|
|
7e28381df5 | ||
|
|
289e06ce65 | ||
|
|
faeb940134 | ||
|
|
343c04061e | ||
|
|
6440a8950c | ||
|
|
e569a80ec2 | ||
|
|
40a43e46b4 | ||
|
|
7c1b713780 | ||
|
|
52c5679c00 | ||
|
|
5997a494bd | ||
|
|
3665f4d5d0 | ||
|
|
f2da177517 | ||
|
|
6ecae88518 | ||
|
|
769bb5a9bc | ||
|
|
083cfd0efd | ||
|
|
064de08d4b | ||
|
|
f924e72088 | ||
|
|
81e6feded3 | ||
|
|
a85af2bec8 | ||
|
|
95c05078de | ||
|
|
563141fbbe | ||
|
|
cca505fc2c | ||
|
|
dd2e117f32 | ||
|
|
d323a4983e | ||
|
|
212d675514 | ||
|
|
58f872c6f4 | ||
|
|
46272b2d77 | ||
|
|
c981707d91 | ||
|
|
5292088622 | ||
|
|
7b52921730 | ||
|
|
c6bef8c699 | ||
|
|
c957e28c00 | ||
|
|
55f42bb6cb | ||
|
|
46118e91e5 | ||
|
|
a9f9769824 | ||
|
|
234c76367e | ||
|
|
e13b43586d | ||
|
|
7b902e8ca3 | ||
|
|
9c99799694 | ||
|
|
10694609b3 | ||
|
|
0cea24246c | ||
|
|
01118ae924 | ||
|
|
245e338452 | ||
|
|
02c235d164 | ||
|
|
38c4073632 | ||
|
|
ca78f36f8f | ||
|
|
7fe7fafe1f | ||
|
|
c3e4d1b317 | ||
|
|
150777dafc | ||
|
|
4fc9bab96b | ||
|
|
06d55b287d | ||
|
|
2b72e855f1 | ||
|
|
2d64f91c9a | ||
|
|
79d819a501 | ||
|
|
bfc7d5b438 | ||
|
|
376367d0b2 | ||
|
|
8fff9e86c5 | ||
|
|
ea9a4a3953 | ||
|
|
c8afb2d87b | ||
|
|
1e0e3efd5a | ||
|
|
e2dfa05233 | ||
|
|
b2fc829fa9 | ||
|
|
7828de80fb | ||
|
|
f7ed0e09f1 | ||
|
|
d7363c773f | ||
|
|
7831e510d8 | ||
|
|
09254b7065 | ||
|
|
4910f384ba | ||
|
|
9be43c9f0c | ||
|
|
f35c7447d4 | ||
|
|
4d81a40ddf | ||
|
|
8de40fbf41 | ||
|
|
04196fde2f | ||
|
|
cbda254731 | ||
|
|
edf35edfba | ||
|
|
edb6d5e8b6 | ||
|
|
49f6aaf670 | ||
|
|
ae3f3bb762 | ||
|
|
d2b76cc58d | ||
|
|
e94b4f2655 | ||
|
|
8afd487e87 | ||
|
|
8d7797f6fd | ||
|
|
6a80357c39 | ||
|
|
31dc55ac35 | ||
|
|
a1668dc5dd | ||
|
|
4cdf471c68 | ||
|
|
0d1b1423c4 | ||
|
|
3274b04983 | ||
|
|
07bd998291 | ||
|
|
ca4a205fd4 | ||
|
|
3701731de8 | ||
|
|
ceb3de90bf | ||
|
|
18ee69f0db | ||
|
|
bd56ccb570 | ||
|
|
7fcc52412f | ||
|
|
cd9042a648 | ||
|
|
6690ad65ca | ||
|
|
28c3aa21f3 | ||
|
|
52f4775ee2 | ||
|
|
387ef7ecb2 | ||
|
|
abfec8960d | ||
|
|
4ca1be21a9 | ||
|
|
791a5ea640 | ||
|
|
047ad0402e | ||
|
|
4f104560ea | ||
|
|
95e3eea080 | ||
|
|
44cae54788 | ||
|
|
e45be1243d | ||
|
|
52fedb1e53 | ||
|
|
5f95737d56 | ||
|
|
9af74237cd | ||
|
|
843437a3b1 | ||
|
|
247c8d7b49 | ||
|
|
2fdd8be0a9 | ||
|
|
9ceea42656 | ||
|
|
5066c78c08 | ||
|
|
ab112e3e04 | ||
|
|
85184e5eab | ||
|
|
8f3f3b0bea | ||
|
|
d45da29ef7 | ||
|
|
21d0adb089 | ||
|
|
724537bd93 | ||
|
|
09f89e050a | ||
|
|
b54f71b3e6 | ||
|
|
fb4005afb7 | ||
|
|
85c29f4eef | ||
|
|
c15aaaf64f | ||
|
|
c01657ec30 | ||
|
|
49e58ee789 | ||
|
|
f37cb57427 | ||
|
|
e124f3f406 | ||
|
|
eb7acef8ae | ||
|
|
94f7298088 | ||
|
|
aac432eb4e | ||
|
|
aeca225246 | ||
|
|
305bbe9c6c | ||
|
|
6a11980d69 | ||
|
|
b7bc5659e6 | ||
|
|
d5102fafc7 | ||
|
|
8391f22f64 | ||
|
|
64a7355e9a | ||
|
|
cea32b7a59 | ||
|
|
32a3282d5d | ||
|
|
39eb2cfd57 | ||
|
|
221669283d | ||
|
|
7a7933274e | ||
|
|
6ac22ac4a3 | ||
|
|
ec865d3b7c | ||
|
|
ac12c441fc | ||
|
|
86919a14f7 | ||
|
|
57378a9b0d | ||
|
|
c72f5652bd | ||
|
|
dcfdb00c19 | ||
|
|
7ff2a98ccf | ||
|
|
d1987d968e | ||
|
|
7b6c23f3b2 | ||
|
|
502ba1ec6e | ||
|
|
1c81600ae1 | ||
|
|
74712a3384 | ||
|
|
f73863f758 | ||
|
|
55c5722629 | ||
|
|
2b2cc0f6f8 | ||
|
|
63b4004d85 | ||
|
|
754bcd3dc6 | ||
|
|
cd18d6498a | ||
|
|
7f059d9c6f | ||
|
|
f84f3f1f0e | ||
|
|
be78bb5ce0 | ||
|
|
854a2e90c1 | ||
|
|
5822a073df | ||
|
|
274ab79cb7 | ||
|
|
1698a923bf | ||
|
|
f33c8af02a | ||
|
|
92c9c81dd6 | ||
|
|
b60661303e | ||
|
|
110f8d5e29 | ||
|
|
2133df002b | ||
|
|
c6a92ae399 | ||
|
|
1d6c923782 | ||
|
|
b46f1d0405 | ||
|
|
7914306c3a | ||
|
|
e222c8432d | ||
|
|
45100be397 | ||
|
|
f989868fdf | ||
|
|
bf9c9e8017 | ||
|
|
7db683ba34 | ||
|
|
2168454d7d | ||
|
|
1c69e3e0b1 | ||
|
|
8b77f4ce68 | ||
|
|
acd64bb427 | ||
|
|
545677dc7a | ||
|
|
847862a554 | ||
|
|
0323efe57c | ||
|
|
c85b65c2e1 | ||
|
|
21edd0d628 | ||
|
|
ca0ee444c7 | ||
|
|
cd1b449585 | ||
|
|
5075bd6068 | ||
|
|
6b897537d9 | ||
|
|
a26c90f217 | ||
|
|
4342e7a8b2 | ||
|
|
3b1f0129ba | ||
|
|
4f0ec7eb68 | ||
|
|
1e63ded8e1 | ||
|
|
23d5e6d19d | ||
|
|
7dce565e4f | ||
|
|
f524186b70 | ||
|
|
dc9577eaa0 | ||
|
|
d1e9537610 | ||
|
|
2902f36332 | ||
|
|
1c46002aaa | ||
|
|
4dfa98ff89 | ||
|
|
3c7b3ad0b8 | ||
|
|
b761cea5f2 | ||
|
|
6305c42f8b | ||
|
|
82d5e7df05 | ||
|
|
c2bccda07f | ||
|
|
e772823572 | ||
|
|
a387e8c70f | ||
|
|
fb1ddad3b8 | ||
|
|
9e28856229 | ||
|
|
c005a5cb26 | ||
|
|
fc30e160fc | ||
|
|
9fa72109da | ||
|
|
82a72670a6 | ||
|
|
08e53c090e | ||
|
|
286bd13eb8 | ||
|
|
371b4a9fbb | ||
|
|
6aa63e8277 | ||
|
|
b07c7c5c9d | ||
|
|
93fd6a4f42 | ||
|
|
abd636b137 | ||
|
|
5e4eec4d70 | ||
|
|
1dbbe31eae | ||
|
|
fbdd937302 | ||
|
|
2ca36374e6 | ||
|
|
50cd1c5d4f | ||
|
|
6eb384283a | ||
|
|
1f590a71f5 | ||
|
|
558cfb8c6e | ||
|
|
0b5d342dfc | ||
|
|
338a1f2d49 | ||
|
|
64253e1985 | ||
|
|
5806a65a0c | ||
|
|
ab8aa61a29 | ||
|
|
0c9408ff64 | ||
|
|
94aa744fd4 | ||
|
|
9876297953 | ||
|
|
d3a07bff44 | ||
|
|
9bd5fba6dc | ||
|
|
3e48e4c50c | ||
|
|
3b66d4c4f7 | ||
|
|
e1756f692c | ||
|
|
376056fb1a | ||
|
|
56a9a7cf1b | ||
|
|
ce6214f631 | ||
|
|
57a7510d05 | ||
|
|
7e8dfd472d | ||
|
|
6dbff5978a | ||
|
|
806f4efe6a | ||
|
|
0238a96975 | ||
|
|
ae5abde1e6 | ||
|
|
8009774c20 | ||
|
|
efa14c6ebb | ||
|
|
0c4da37e85 | ||
|
|
5653628bf7 | ||
|
|
94accbf58b | ||
|
|
cca60e56ff | ||
|
|
508f47cb6b | ||
|
|
6a3e3e7682 | ||
|
|
545cce6d11 | ||
|
|
85bb34030a | ||
|
|
0b7c6a0fed | ||
|
|
c89549a0ae | ||
|
|
8aa9ed9f21 | ||
|
|
c3f64215f1 | ||
|
|
5cf5fe5eba | ||
|
|
dc57c1464b | ||
|
|
3393827653 | ||
|
|
ad665e5f0b | ||
|
|
cfd812eab6 | ||
|
|
bd1eb31f37 | ||
|
|
d3532a2796 | ||
|
|
a0fb8000f0 | ||
|
|
b1c9e0d3b5 | ||
|
|
e07cf3c5d3 | ||
|
|
6e75926d0b | ||
|
|
8b392016c2 | ||
|
|
ade156be5c | ||
|
|
2b6b569dee | ||
|
|
5a2d7f09ce | ||
|
|
bb31cdae56 | ||
|
|
44b1f77b70 | ||
|
|
11bdb1b2f1 | ||
|
|
49a004d7fe | ||
|
|
a697b7a4dc | ||
|
|
9c1db2778e | ||
|
|
1c3c90e171 | ||
|
|
5a4df5593a | ||
|
|
00b937553c | ||
|
|
1f489a481c | ||
|
|
4ad79d54b0 | ||
|
|
f2b4bfe39d | ||
|
|
42fbc501a9 | ||
|
|
45eb5ac524 | ||
|
|
de7a04d689 | ||
|
|
aa1413bc83 | ||
|
|
34dc592e59 | ||
|
|
0829655880 | ||
|
|
222887f97d | ||
|
|
747eb87de9 | ||
|
|
766a3cb2b2 | ||
|
|
d1cb0a4f43 | ||
|
|
b79ae4b1aa | ||
|
|
5a0c01688a | ||
|
|
11f8343a1d | ||
|
|
b8fb6ba12c | ||
|
|
a86ad864e1 | ||
|
|
9fb462b087 | ||
|
|
cd4e894652 | ||
|
|
580d4330e3 | ||
|
|
035416b785 | ||
|
|
de90a4638a | ||
|
|
0160dc965d | ||
|
|
d9b1bc8b4a | ||
|
|
f2005bbf56 | ||
|
|
94de991bf6 | ||
|
|
752719bd62 | ||
|
|
13f151b39a | ||
|
|
42c2f88597 | ||
|
|
0ac7ba05d6 | ||
|
|
8ef0cea1ff | ||
|
|
7472040cbc | ||
|
|
4794000f75 | ||
|
|
6d6b322fb5 | ||
|
|
0808351b7a | ||
|
|
89ae1bb52f | ||
|
|
1afd6870c3 | ||
|
|
ea6c9818cf | ||
|
|
42c255e40e | ||
|
|
415adba8cf | ||
|
|
6aada39d97 | ||
|
|
b1743662f4 | ||
|
|
54595c9ebd | ||
|
|
930db8c379 | ||
|
|
b6bbad66e7 | ||
|
|
deb6b90332 | ||
|
|
1c34946a6b | ||
|
|
26620f1fd1 | ||
|
|
9868c41640 | ||
|
|
09affdb1dd | ||
|
|
fcea95d403 | ||
|
|
5bfc348c72 | ||
|
|
2f6f24e281 | ||
|
|
c3bfe5223b | ||
|
|
15ab22362e | ||
|
|
b1f7730b96 | ||
|
|
54ef1e1216 | ||
|
|
a79be1e07a | ||
|
|
c187dc9abf | ||
|
|
a919a3e9d6 | ||
|
|
3559ab0ab3 | ||
|
|
fcfdfeca41 | ||
|
|
c3050863a6 | ||
|
|
d0ebb62ab3 | ||
|
|
4db4c6e905 | ||
|
|
354c13853f | ||
|
|
d14cb175a6 | ||
|
|
cc2a24cee5 | ||
|
|
4953290eb3 | ||
|
|
c0d81297f5 | ||
|
|
9223483115 | ||
|
|
6eee83042b | ||
|
|
d98762aaf8 | ||
|
|
46861530a8 | ||
|
|
99377ce3b9 | ||
|
|
f9d2c43d57 | ||
|
|
b8faca784e | ||
|
|
fcd44e7a1a | ||
|
|
36f2842b01 | ||
|
|
a6f5b287c9 | ||
|
|
ef8284586e | ||
|
|
87f42ba291 | ||
|
|
6933442e76 | ||
|
|
74a6800f9e | ||
|
|
1d098f7893 | ||
|
|
51530bd088 | ||
|
|
f01a0d84fe | ||
|
|
8ff05bcccf | ||
|
|
229564750f | ||
|
|
b4a59518c0 | ||
|
|
08468e60d6 | ||
|
|
c767512fad | ||
|
|
ea59dd0932 | ||
|
|
596667a67e | ||
|
|
e128784bb8 | ||
|
|
c56848958e | ||
|
|
f4e7c7e88d | ||
|
|
38a88e841b | ||
|
|
d177a4f892 | ||
|
|
7cdfad0738 | ||
|
|
ffb4d5afb6 | ||
|
|
ae09afef59 | ||
|
|
5302aee2a1 | ||
|
|
ea31fc31fe | ||
|
|
a597da1e18 | ||
|
|
fd2db3e229 | ||
|
|
836daaa5a1 | ||
|
|
66feec63de | ||
|
|
9a9a09f16d | ||
|
|
26b2c1f1a9 | ||
|
|
4bcffdc3a9 | ||
|
|
8c83965315 | ||
|
|
019e85066f | ||
|
|
7261d44728 | ||
|
|
805e66d537 | ||
|
|
16228800d4 | ||
|
|
a4b2c157a1 | ||
|
|
f968ac8a3f | ||
|
|
73d2a22f31 | ||
|
|
aa3e19a76c | ||
|
|
efc6d22dad | ||
|
|
175a92f633 |
+13
-7
@@ -1,7 +1,13 @@
|
||||
bin/
|
||||
obj/
|
||||
.vs/
|
||||
*.suo
|
||||
*.bak
|
||||
*.pdb
|
||||
|
||||
Config/bin/
|
||||
Config/obj/
|
||||
Results/bin/
|
||||
Results/obj/
|
||||
ResultsBrowser/bin/
|
||||
ResultsBrowser/obj/
|
||||
TestBenchFramework/bin/
|
||||
TestBenchFramework/obj/
|
||||
TBFSetup/Debug/
|
||||
TBFSetup/Release/
|
||||
Doc/
|
||||
*.suo
|
||||
*.bak
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{743DF7DB-C7B6-42EB-986D-0F485E5588E4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Config</RootNamespace>
|
||||
<AssemblyName>Config</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</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>TRACE;DEBUG;IPERLST</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;IPERLST</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentNHibernate">
|
||||
<HintPath>..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections">
|
||||
<HintPath>..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.6.6.5\lib\net20\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite">
|
||||
<HintPath>..\packages\System.Data.SQLite.1.0.90.0\lib\net40\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SQLite.Linq">
|
||||
<HintPath>..\packages\System.Data.SQLite.1.0.90.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<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="Data.cs" />
|
||||
<Compile Include="DatabaseSettings.cs" />
|
||||
<Compile Include="DBSettings.cs" />
|
||||
<Compile Include="Entities\BenchPath.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\IHasItemNr.cs" />
|
||||
<Compile Include="Entities\IHasValves.cs" />
|
||||
<Compile Include="Entities\MeasurementCorrection.cs" />
|
||||
<Compile Include="Entities\MetersPath.cs" />
|
||||
<Compile Include="Entities\MeterTestResult.cs" />
|
||||
<Compile Include="Entities\OutputPath.cs" />
|
||||
<Compile Include="Entities\Procedure.cs" />
|
||||
<Compile Include="Entities\ProcedureHistory.cs" />
|
||||
<Compile Include="Entities\Test.cs" />
|
||||
<Compile Include="Entities\TestResult.cs" />
|
||||
<Compile Include="Entities\TransitionSequence.cs" />
|
||||
<Compile Include="Entities\TransitionStep.cs" />
|
||||
<Compile Include="Entities\User.cs" />
|
||||
<Compile Include="Entities\VirtualBenchSequence.cs" />
|
||||
<Compile Include="Entities\VirtualBenchStep.cs" />
|
||||
<Compile Include="Entities\Watermeter.cs" />
|
||||
<Compile Include="Entities\WMType.cs" />
|
||||
<Compile Include="FluentCommon.cs" />
|
||||
<Compile Include="Grp.cs" />
|
||||
<Compile Include="Mappings\BenchPathMap.cs" />
|
||||
<Compile Include="Mappings\ComponentMap.cs" />
|
||||
<Compile Include="Mappings\ComponentProcedureMap.cs" />
|
||||
<Compile Include="Mappings\ComponentTestMap.cs" />
|
||||
<Compile Include="Mappings\FeedingPathMap.cs" />
|
||||
<Compile Include="Mappings\GroupMap.cs" />
|
||||
<Compile Include="Mappings\MeasurementCorrectionMap.cs" />
|
||||
<Compile Include="Mappings\MetersPathMap.cs" />
|
||||
<Compile Include="Mappings\MeterTestResultMap.cs" />
|
||||
<Compile Include="Mappings\OutputPathMap.cs" />
|
||||
<Compile Include="Mappings\ProcedureMap.cs" />
|
||||
<Compile Include="Mappings\TestMap.cs" />
|
||||
<Compile Include="Mappings\TestResultMap.cs" />
|
||||
<Compile Include="Mappings\TransitionSequenceMap.cs" />
|
||||
<Compile Include="Mappings\TransitionStepMap.cs" />
|
||||
<Compile Include="Mappings\UserMap.cs" />
|
||||
<Compile Include="Mappings\VirtualBenchSequenceMap.cs" />
|
||||
<Compile Include="Mappings\VirtualBenchStepMap.cs" />
|
||||
<Compile Include="Mappings\WatermeterMap.cs" />
|
||||
<Compile Include="Mappings\WMTypeMap.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\Strings.Designer.cs" />
|
||||
<Compile Include="ResultItemSpec.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Strings.resx">
|
||||
<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>
|
||||
@@ -0,0 +1,31 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Database settings required to make a connection
|
||||
/// </summary>
|
||||
public class DBSettings : ICloneable
|
||||
{
|
||||
public Entities.DBType DbType;
|
||||
public string ConnectionString;
|
||||
|
||||
public DBSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public DBSettings(Entities.DBType dbType, string connectionString)
|
||||
{
|
||||
this.DbType = dbType;
|
||||
this.ConnectionString = connectionString;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new DBSettings(DbType, ConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
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 = 1;
|
||||
public const int CompoundWMsCount = 1;
|
||||
#elif DN100 || BADGER_VELKA_TRAT
|
||||
public const int WMsCount = 3;
|
||||
public const int LineSize = 3;
|
||||
public const int CompoundWMsCount = 1;
|
||||
#elif FUZHOU300 || FUZHOU150 || PT200IL
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 3;
|
||||
#elif TORINO50 || BADGER_MALA_TRAT
|
||||
public const int WMsCount = 6;
|
||||
public const int LineSize = 6;
|
||||
public const int CompoundWMsCount = 1;
|
||||
#elif TORUN_PT50_2015 || CEVAK_PT40_272 || MURES_PT40 || FUZHOU_40
|
||||
public const int WMsCount = 20;
|
||||
public const int LineSize = 10;
|
||||
public const int CompoundWMsCount = 1;
|
||||
#elif IPERLST
|
||||
public const int WMsCount = 40;
|
||||
public const int LineSize = 20;
|
||||
public const int CompoundWMsCount = 1;
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Database related: This object reference is set after a successful user login
|
||||
///
|
||||
public static DatabaseSettings CurrentBench;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
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 DBSettings ProceduresDBSettings; /// Config database settings
|
||||
public DBSettings WaterMetersDBSettings; /// Results database settings
|
||||
|
||||
// Constructor
|
||||
public DatabaseSettings()
|
||||
{
|
||||
BenchName = String.Empty; /// Empty string to avoid null
|
||||
IsRealBench = false;
|
||||
ProceduresDBSettings = new DBSettings(Entities.DBType.MySql, "SERVER=localhost; DATABASE=tbf_procedures; UID=root; PASSWORD=;");
|
||||
WaterMetersDBSettings = new DBSettings(Entities.DBType.MySql, "SERVER=localhost; DATABASE=tbf_watermeters; UID=root; PASSWORD=;");
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
DatabaseSettings result = new DatabaseSettings();
|
||||
|
||||
result.BenchName = BenchName;
|
||||
result.IsRealBench = IsRealBench;
|
||||
result.ProceduresDBSettings = (DBSettings)ProceduresDBSettings.Clone();
|
||||
result.WaterMetersDBSettings = (DBSettings)WaterMetersDBSettings.Clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} conn.str.={1}", BenchName, ProceduresDBSettings.ConnectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class BenchPath : IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual string TempIn { get; set; }
|
||||
public virtual string TempOut { get; set; }
|
||||
public virtual string PressIn { get; set; }
|
||||
public virtual string PressOut { get; set; }
|
||||
|
||||
/// Valves
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public BenchPath()
|
||||
{
|
||||
ValvesOpen = string.Empty;
|
||||
ValvesClose = string.Empty;
|
||||
}
|
||||
|
||||
public BenchPath(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual BenchPath Clone(string name, int itemNr)
|
||||
{
|
||||
BenchPath result = new BenchPath(name, itemNr);
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.TempIn = TempIn;
|
||||
result.TempOut = TempOut;
|
||||
result.PressIn = PressIn;
|
||||
result.PressOut = PressOut;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class Component : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string ClassName { get; set; }
|
||||
public virtual string ParentName { get; set; }
|
||||
public virtual DebugMode Mode { get; set; }
|
||||
public virtual LogLevel Logging { get; set; }
|
||||
public virtual string Parameters { get; set; }
|
||||
public virtual IList<MeasurementCorrection> Corrections { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public Component()
|
||||
{
|
||||
Corrections = new List<MeasurementCorrection>();
|
||||
}
|
||||
|
||||
public static Component CreateFromCfg(string name, string className, string parentName, int itemNr,
|
||||
DebugMode debugLevel, LogLevel logLevel, string parameters)
|
||||
{
|
||||
Component result = new Component();
|
||||
result.ItemNr = itemNr;
|
||||
result.Name = name;
|
||||
result.ClassName = className;
|
||||
result.ParentName = parentName;
|
||||
result.Mode = debugLevel;
|
||||
result.Logging = logLevel;
|
||||
result.Parameters = parameters;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Makes a new copy of this object (not just a reference)
|
||||
public virtual Component Clone()
|
||||
{
|
||||
Component result = new Component();
|
||||
result.ItemNr = ItemNr;
|
||||
result.Name = Name;
|
||||
result.ClassName = ClassName;
|
||||
result.ParentName = ParentName;
|
||||
result.Mode = Mode;
|
||||
result.Logging = Logging;
|
||||
result.Parameters = Parameters;
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual string ToString(string indent)
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
result += indent + "ItemNr = " + (ItemNr + 1).ToString() + Environment.NewLine;
|
||||
result += indent + "Name = " + Name + Environment.NewLine;
|
||||
result += indent + "ClassName = " + ClassName + Environment.NewLine;
|
||||
if (ParentName != null)
|
||||
{
|
||||
result += indent + "ParentName = " + ParentName + Environment.NewLine;
|
||||
}
|
||||
result += indent + "DebugLevel = " + Mode.ToString() + Environment.NewLine;
|
||||
result += indent + "LogLevel = " + Logging.ToString() + Environment.NewLine;
|
||||
result += indent + "Parameters = " + Parameters + Environment.NewLine;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class ComponentProcedure
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string CmpntName { get; set; } /// Component name
|
||||
public virtual string Parameters { get; set; }
|
||||
public virtual Procedure Procedure { get; set; }
|
||||
|
||||
public virtual ComponentProcedure Clone()
|
||||
{
|
||||
ComponentProcedure result = new ComponentProcedure();
|
||||
result.CmpntName = CmpntName;
|
||||
result.Parameters = Parameters;
|
||||
result.Procedure = Procedure;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class ComponentTest
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string CmpntName { get; set; } /// Component name
|
||||
public virtual string Parameters { get; set; }
|
||||
public virtual Test Test { get; set; }
|
||||
|
||||
public virtual ComponentTest Clone()
|
||||
{
|
||||
ComponentTest result = new ComponentTest();
|
||||
result.CmpntName = CmpntName;
|
||||
result.Parameters = Parameters;
|
||||
result.Test = Test;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class to assign descriptions to enum values
|
||||
/// </summary>
|
||||
public class Description : Attribute
|
||||
{
|
||||
public string Text;
|
||||
public Description(string t)
|
||||
{
|
||||
Text = t;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetDescription
|
||||
{
|
||||
/// Extension method for enum-s
|
||||
public static string ToDescription(this Enum en)
|
||||
{
|
||||
Type type = en.GetType();
|
||||
MemberInfo[] memInfo = type.GetMember(en.ToString());
|
||||
|
||||
if (memInfo != null && memInfo.Length > 0)
|
||||
{
|
||||
object[] attrs = memInfo[0].GetCustomAttributes(typeof(Description), false);
|
||||
if (attrs != null && attrs.Length > 0)
|
||||
return ((Description)attrs[0]).Text;
|
||||
}
|
||||
|
||||
return en.ToString(); /// Return ToString() value in case there is no description
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Identifies the type of a database </summary>
|
||||
public enum DBType
|
||||
{
|
||||
MySql, /// MySQL database
|
||||
SQLite, /// SQLite
|
||||
DbTypesCount,
|
||||
}
|
||||
|
||||
/// <summary> Identifies the database based on the content </summary>
|
||||
public enum DBKind
|
||||
{
|
||||
Config,
|
||||
Results,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum ProcedureState
|
||||
{
|
||||
Active,
|
||||
History,
|
||||
Template,
|
||||
Count,
|
||||
}
|
||||
|
||||
/// <summary> Kind of meters for the procedure / test </summary>
|
||||
public enum MetersKind
|
||||
{
|
||||
Single,
|
||||
Combined,
|
||||
HeatMeter,
|
||||
}
|
||||
|
||||
public enum CompoundMeterId : byte
|
||||
{
|
||||
Single,
|
||||
CompoundMain,
|
||||
CompoundAux,
|
||||
Compound,
|
||||
}
|
||||
|
||||
public enum Medium
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
ColdWater,
|
||||
HotWater,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Mounting
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
[Description("H")] H, /// horizontal
|
||||
[Description("V")] V, /// vertical
|
||||
[Description("S")] S, /// steig
|
||||
[Description("F")] F, /// fall
|
||||
Count
|
||||
}
|
||||
|
||||
public enum TemperatureClass
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
[Description("T30")] T30,
|
||||
[Description("T50")] T50,
|
||||
[Description("T70")] T70,
|
||||
[Description("T90")] T90,
|
||||
[Description("T130")] T130,
|
||||
[Description("T180")] T180,
|
||||
[Description("T30/70")] T30_70,
|
||||
[Description("T30/90")] T30_90,
|
||||
[Description("T30/130")] T30_130,
|
||||
[Description("T30/180")] T30_180,
|
||||
[Description("30")] t30,
|
||||
[Description("50")] t50,
|
||||
[Description("70")] t70,
|
||||
[Description("90")] t90,
|
||||
[Description("130")] t130,
|
||||
[Description("180")] t180,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum FlowProfileSensitivityClass
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
[Description("U0")] U0, /// ?
|
||||
[Description("D0")] D0, /// ?
|
||||
Count
|
||||
}
|
||||
|
||||
public enum PressureLossClass
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
[Description("dp63")] dp63, /// 0.063 MPa = 0.63 bar, TODO: Change to "Δp63"
|
||||
[Description("dp40")] dp40, /// 0.040 MPa = 0.40 bar
|
||||
[Description("dp25")] dp25, /// 0.025 MPa = 0.25 bar
|
||||
[Description("dp16")] dp16, /// 0.016 MPa = 0.16 bar
|
||||
[Description("dp10")] dp10, /// 0.010 MPa = 0.10 bar
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary> Maximum Admissible Pressure </summary>
|
||||
public enum MaxAdmissiblePressure
|
||||
{
|
||||
[Description("")] NotSpecified,
|
||||
[Description("MAP6")] MAP6,
|
||||
[Description("MAP10")] MAP10,
|
||||
[Description("MAP16")] MAP16,
|
||||
[Description("MAP25")] MAP25,
|
||||
[Description("MAP40")] MAP40,
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary> Transition step is finished when this condition is fulfilled </summary>
|
||||
public enum StepCondition
|
||||
{
|
||||
None,
|
||||
Scale1Empty,
|
||||
Scale2Empty,
|
||||
Scale3Empty,
|
||||
AllScalesEmpty,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum Publish : sbyte
|
||||
{
|
||||
#if MUNICH
|
||||
/// nemecky
|
||||
[Description("nie")] Never = 0,
|
||||
[Description("immer")] Always = 1,
|
||||
[Description("Bildschirm")] OnScreen = 2,
|
||||
[Description("intern")] Internal = 3,
|
||||
#elif CEVAK || BADGER_MALA_TRAT || BADGER_VELKA_TRAT
|
||||
/// cesky
|
||||
[Description("nikdy")] Never = 0,
|
||||
[Description("vždy")] Always = 1,
|
||||
[Description("na obrazovku")] OnScreen = 2,
|
||||
[Description("interně")] Internal = 3,
|
||||
#elif IPERLST || IPERLST_SPECIAL || SLM_50
|
||||
/// slovensky
|
||||
[Description("nikdy")] Never = 0,
|
||||
[Description("vždy")] Always = 1,
|
||||
[Description("na obrazovku")] OnScreen = 2,
|
||||
[Description("interne")] Internal = 3,
|
||||
#else
|
||||
[Description("Never")] Never = 0,
|
||||
[Description("Always")] Always = 1,
|
||||
[Description("On screen")] OnScreen = 2,
|
||||
[Description("Internal")] Internal = 3,
|
||||
#endif
|
||||
Count
|
||||
}
|
||||
|
||||
public enum TestRedType
|
||||
{
|
||||
Fix,
|
||||
/// etc.
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum FQC1
|
||||
{
|
||||
FQC1,
|
||||
FQP1,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum Progress
|
||||
{
|
||||
JustStarted,
|
||||
TransitionBefore,
|
||||
SwitchingFlowDetection,
|
||||
FlowSetting,
|
||||
Test,
|
||||
TransitionAfter,
|
||||
Completed,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum Device
|
||||
{
|
||||
Screen,
|
||||
Printer,
|
||||
Disk,
|
||||
}
|
||||
|
||||
public enum PageOrientation
|
||||
{
|
||||
Portrait,
|
||||
Landscape,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum UnitsVolume
|
||||
{
|
||||
Liter,
|
||||
CubicMtr,
|
||||
}
|
||||
|
||||
/// <summary> Possible modes of operation of components and devices. </summary>
|
||||
public enum DebugMode
|
||||
{
|
||||
DetectedOff = -2,
|
||||
DetectedOn = -1,
|
||||
Normal = 0, /// Normal operation
|
||||
AutoDetect, /// The component (device) will be auto-detected
|
||||
FailureDuringOperation, /// Failure during operation -> disabled
|
||||
Off, /// The component is off
|
||||
Record,
|
||||
Reply,
|
||||
Simulate, /// Test bench simulation, this mode does not require any hardware
|
||||
Inherit,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
Off,
|
||||
Fatal,
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
All,
|
||||
Count,
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Arrangement of tests </summary>
|
||||
public enum TestsArrangement
|
||||
{
|
||||
Rows,
|
||||
Columns,
|
||||
}
|
||||
|
||||
/// <summary> Arrangement of meters </summary>
|
||||
public enum MetersArrangement
|
||||
{
|
||||
Vertically,
|
||||
Horizontally,
|
||||
}
|
||||
|
||||
public enum Alignment
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right,
|
||||
Justified,
|
||||
Count
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class FeedingPath : IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
public virtual string Pump { get; set; }
|
||||
|
||||
/// Valves
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public FeedingPath()
|
||||
{
|
||||
ValvesOpen = string.Empty;
|
||||
ValvesClose = string.Empty;
|
||||
}
|
||||
|
||||
public FeedingPath(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual FeedingPath Clone(string name, int itemNr)
|
||||
{
|
||||
FeedingPath result = new FeedingPath(name, itemNr);
|
||||
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.Pump = Pump;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class Group
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int Gid { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace Config.Entities
|
||||
{
|
||||
public interface IHasItemNr
|
||||
{
|
||||
int Id { get; }
|
||||
int ItemNr { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
namespace Config.Entities
|
||||
{
|
||||
public interface IHasValves
|
||||
{
|
||||
string ValvesOpen { get; set; } /// List of valves to be opened
|
||||
string ValvesClose { get; set; } /// List of valves to be closed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class MeasurementCorrection
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual float Measurement { get; set; }
|
||||
public virtual float Correction { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class MeterTestResult
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual TestResult TestResult { get; set; } /// reference to the TestResult entity
|
||||
|
||||
public virtual bool Disabled { get; set; } /// true = this meter was disabled and the results should be disregarded
|
||||
public virtual string SerialNr { get; set; }
|
||||
public virtual string EndState { get; set; }
|
||||
public virtual float VolumeStart { get; set; } /// liter
|
||||
public virtual float VolumeEnd { get; set; } /// liter
|
||||
public virtual float VolumeMeter { get; set; } /// liter
|
||||
public virtual float VolumeRef { get; set; } /// liter
|
||||
public virtual float VolumeErrorPct { get; set; } /// %
|
||||
public virtual float PulsesMeter { get; set; } /// # of pulses
|
||||
public virtual float PulsesPerLiter { get; set; } /// Pulses per liter
|
||||
public virtual float PulsesMaster { get; set; }
|
||||
public virtual float Time { get; set; } /// sec.
|
||||
public virtual float TimeStart { get; set; } /// sec. - Not mapped to DB !!!
|
||||
public virtual float TimeEnd { get; set; } /// sec. - Not mapped to DB !!!
|
||||
public virtual int CalibFactor { get; set; } /// iPerl calibration factor used during the test - Not mapped to DB !!!
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test - Not mapped to DB !!!
|
||||
public virtual bool Passed { get; set; } /// true=test passed - Not mapped to DB !!!
|
||||
|
||||
public MeterTestResult()
|
||||
{
|
||||
PulsesPerLiter = 1.0f;
|
||||
}
|
||||
|
||||
public MeterTestResult(TestResult testResult)
|
||||
: this()
|
||||
{
|
||||
TestResult = testResult;
|
||||
}
|
||||
|
||||
public virtual MeterTestResult Clone(TestResult testResult)
|
||||
{
|
||||
MeterTestResult result = new MeterTestResult(testResult);
|
||||
|
||||
result.Disabled = Disabled;
|
||||
result.SerialNr = SerialNr;
|
||||
result.EndState = EndState;
|
||||
result.VolumeStart = VolumeStart;
|
||||
result.VolumeEnd = VolumeEnd;
|
||||
result.VolumeMeter = VolumeMeter;
|
||||
result.VolumeRef = VolumeRef;
|
||||
result.VolumeErrorPct = VolumeErrorPct;
|
||||
result.PulsesMeter = PulsesMeter;
|
||||
result.PulsesPerLiter = PulsesPerLiter;
|
||||
result.PulsesMaster = PulsesMaster;
|
||||
result.Time = Time;
|
||||
result.TimeStart = TimeStart;
|
||||
result.TimeEnd = TimeEnd;
|
||||
result.CalibFactor = CalibFactor;
|
||||
result.Q2Correction = Q2Correction;
|
||||
result.Passed = Passed;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class MetersPath : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
|
||||
/// Sensors
|
||||
public virtual string Sensor1 { get; set; }
|
||||
public virtual string Sensor2 { get; set; }
|
||||
public virtual string Sensor3 { get; set; }
|
||||
public virtual string Sensor4 { get; set; }
|
||||
public virtual string Sensor5 { get; set; }
|
||||
public virtual string Sensor6 { get; set; }
|
||||
public virtual string Sensor7 { get; set; }
|
||||
public virtual string Sensor8 { get; set; }
|
||||
public virtual string Sensor9 { get; set; }
|
||||
public virtual string Sensor10 { get; set; }
|
||||
public virtual string Sensor11 { get; set; }
|
||||
public virtual string Sensor12 { get; set; }
|
||||
public virtual string Sensor13 { get; set; }
|
||||
public virtual string Sensor14 { get; set; }
|
||||
public virtual string Sensor15 { get; set; }
|
||||
public virtual string Sensor16 { get; set; }
|
||||
public virtual string Sensor17 { get; set; }
|
||||
public virtual string Sensor18 { get; set; }
|
||||
public virtual string Sensor19 { get; set; }
|
||||
public virtual string Sensor20 { get; set; }
|
||||
#if IPERLST
|
||||
public virtual string Sensor21 { get; set; }
|
||||
public virtual string Sensor22 { get; set; }
|
||||
public virtual string Sensor23 { get; set; }
|
||||
public virtual string Sensor24 { get; set; }
|
||||
public virtual string Sensor25 { get; set; }
|
||||
public virtual string Sensor26 { get; set; }
|
||||
public virtual string Sensor27 { get; set; }
|
||||
public virtual string Sensor28 { get; set; }
|
||||
public virtual string Sensor29 { get; set; }
|
||||
public virtual string Sensor30 { get; set; }
|
||||
public virtual string Sensor31 { get; set; }
|
||||
public virtual string Sensor32 { get; set; }
|
||||
public virtual string Sensor33 { get; set; }
|
||||
public virtual string Sensor34 { get; set; }
|
||||
public virtual string Sensor35 { get; set; }
|
||||
public virtual string Sensor36 { get; set; }
|
||||
public virtual string Sensor37 { get; set; }
|
||||
public virtual string Sensor38 { get; set; }
|
||||
public virtual string Sensor39 { get; set; }
|
||||
public virtual string Sensor40 { get; set; }
|
||||
#endif
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public MetersPath()
|
||||
{
|
||||
}
|
||||
|
||||
public MetersPath(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual MetersPath Clone(string name, int itemNr)
|
||||
{
|
||||
MetersPath result = new MetersPath(name, itemNr);
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.Sensor1 = Sensor1;
|
||||
result.Sensor2 = Sensor2;
|
||||
result.Sensor3 = Sensor3;
|
||||
result.Sensor4 = Sensor4;
|
||||
result.Sensor5 = Sensor5;
|
||||
result.Sensor6 = Sensor6;
|
||||
result.Sensor7 = Sensor7;
|
||||
result.Sensor8 = Sensor8;
|
||||
result.Sensor9 = Sensor9;
|
||||
result.Sensor10 = Sensor10;
|
||||
result.Sensor11 = Sensor11;
|
||||
result.Sensor12 = Sensor12;
|
||||
result.Sensor13 = Sensor13;
|
||||
result.Sensor14 = Sensor14;
|
||||
result.Sensor15 = Sensor15;
|
||||
result.Sensor16 = Sensor16;
|
||||
result.Sensor17 = Sensor17;
|
||||
result.Sensor18 = Sensor18;
|
||||
result.Sensor19 = Sensor19;
|
||||
result.Sensor20 = Sensor20;
|
||||
#if IPERLST
|
||||
result.Sensor21 = Sensor21;
|
||||
result.Sensor22 = Sensor22;
|
||||
result.Sensor23 = Sensor23;
|
||||
result.Sensor24 = Sensor24;
|
||||
result.Sensor25 = Sensor25;
|
||||
result.Sensor26 = Sensor26;
|
||||
result.Sensor27 = Sensor27;
|
||||
result.Sensor28 = Sensor28;
|
||||
result.Sensor29 = Sensor29;
|
||||
result.Sensor30 = Sensor30;
|
||||
result.Sensor31 = Sensor31;
|
||||
result.Sensor32 = Sensor32;
|
||||
result.Sensor33 = Sensor33;
|
||||
result.Sensor34 = Sensor34;
|
||||
result.Sensor35 = Sensor35;
|
||||
result.Sensor36 = Sensor36;
|
||||
result.Sensor37 = Sensor37;
|
||||
result.Sensor38 = Sensor38;
|
||||
result.Sensor39 = Sensor39;
|
||||
result.Sensor40 = Sensor40;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Returns the component name
|
||||
public virtual string GetSensor(int i)
|
||||
{
|
||||
if (i == 0) return Sensor1;
|
||||
else if (i == 1) return Sensor2;
|
||||
else if (i == 2) return Sensor3;
|
||||
else if (i == 3) return Sensor4;
|
||||
else if (i == 4) return Sensor5;
|
||||
else if (i == 5) return Sensor6;
|
||||
else if (i == 6) return Sensor7;
|
||||
else if (i == 7) return Sensor8;
|
||||
else if (i == 8) return Sensor9;
|
||||
else if (i == 9) return Sensor10;
|
||||
else if (i == 10) return Sensor11;
|
||||
else if (i == 11) return Sensor12;
|
||||
else if (i == 12) return Sensor13;
|
||||
else if (i == 13) return Sensor14;
|
||||
else if (i == 14) return Sensor15;
|
||||
else if (i == 15) return Sensor16;
|
||||
else if (i == 16) return Sensor17;
|
||||
else if (i == 17) return Sensor18;
|
||||
else if (i == 18) return Sensor19;
|
||||
else if (i == 19) return Sensor20;
|
||||
#if IPERLST
|
||||
else if (i == 20) return Sensor21;
|
||||
else if (i == 21) return Sensor22;
|
||||
else if (i == 22) return Sensor23;
|
||||
else if (i == 23) return Sensor24;
|
||||
else if (i == 24) return Sensor25;
|
||||
else if (i == 25) return Sensor26;
|
||||
else if (i == 26) return Sensor27;
|
||||
else if (i == 27) return Sensor28;
|
||||
else if (i == 28) return Sensor29;
|
||||
else if (i == 29) return Sensor30;
|
||||
else if (i == 30) return Sensor31;
|
||||
else if (i == 31) return Sensor32;
|
||||
else if (i == 32) return Sensor33;
|
||||
else if (i == 33) return Sensor34;
|
||||
else if (i == 34) return Sensor35;
|
||||
else if (i == 35) return Sensor36;
|
||||
else if (i == 36) return Sensor37;
|
||||
else if (i == 37) return Sensor38;
|
||||
else if (i == 38) return Sensor39;
|
||||
else if (i == 39) return Sensor40;
|
||||
#endif
|
||||
else return null;
|
||||
}
|
||||
|
||||
/// Sets the component name
|
||||
public virtual void SetSensor(int i, string cmpntName)
|
||||
{
|
||||
if (i == 0) Sensor1 = cmpntName;
|
||||
else if (i == 1) Sensor2 = cmpntName;
|
||||
else if (i == 2) Sensor3 = cmpntName;
|
||||
else if (i == 3) Sensor4 = cmpntName;
|
||||
else if (i == 4) Sensor5 = cmpntName;
|
||||
else if (i == 5) Sensor6 = cmpntName;
|
||||
else if (i == 6) Sensor7 = cmpntName;
|
||||
else if (i == 7) Sensor8 = cmpntName;
|
||||
else if (i == 8) Sensor9 = cmpntName;
|
||||
else if (i == 9) Sensor10 = cmpntName;
|
||||
else if (i == 10) Sensor11 = cmpntName;
|
||||
else if (i == 11) Sensor12 = cmpntName;
|
||||
else if (i == 12) Sensor13 = cmpntName;
|
||||
else if (i == 13) Sensor14 = cmpntName;
|
||||
else if (i == 14) Sensor15 = cmpntName;
|
||||
else if (i == 15) Sensor16 = cmpntName;
|
||||
else if (i == 16) Sensor17 = cmpntName;
|
||||
else if (i == 17) Sensor18 = cmpntName;
|
||||
else if (i == 18) Sensor19 = cmpntName;
|
||||
else if (i == 19) Sensor20 = cmpntName;
|
||||
#if IPERLST
|
||||
else if (i == 20) Sensor21 = cmpntName;
|
||||
else if (i == 21) Sensor22 = cmpntName;
|
||||
else if (i == 22) Sensor23 = cmpntName;
|
||||
else if (i == 23) Sensor24 = cmpntName;
|
||||
else if (i == 24) Sensor25 = cmpntName;
|
||||
else if (i == 25) Sensor26 = cmpntName;
|
||||
else if (i == 26) Sensor27 = cmpntName;
|
||||
else if (i == 27) Sensor28 = cmpntName;
|
||||
else if (i == 28) Sensor29 = cmpntName;
|
||||
else if (i == 29) Sensor30 = cmpntName;
|
||||
else if (i == 30) Sensor31 = cmpntName;
|
||||
else if (i == 31) Sensor32 = cmpntName;
|
||||
else if (i == 32) Sensor33 = cmpntName;
|
||||
else if (i == 33) Sensor34 = cmpntName;
|
||||
else if (i == 34) Sensor35 = cmpntName;
|
||||
else if (i == 35) Sensor36 = cmpntName;
|
||||
else if (i == 36) Sensor37 = cmpntName;
|
||||
else if (i == 37) Sensor38 = cmpntName;
|
||||
else if (i == 38) Sensor39 = cmpntName;
|
||||
else if (i == 39) Sensor40 = cmpntName;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class OutputPath : IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual float Qfrom { get; set; } /// Water flow in [m3/h]
|
||||
public virtual float Qto { get; set; } /// Water flow in [m3/h]
|
||||
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 string StartValve { get; set; }
|
||||
public virtual string Diverter { get; set; }
|
||||
public virtual string TempDiv { get; set; }
|
||||
public virtual string Balance { get; set; }
|
||||
public virtual string EmptyTankValve { get; set; }
|
||||
|
||||
/// Valves
|
||||
public virtual string ValvesOpen { get; set; }
|
||||
public virtual string ValvesClose { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public OutputPath()
|
||||
{
|
||||
ValvesOpen = string.Empty;
|
||||
ValvesClose = string.Empty;
|
||||
}
|
||||
|
||||
public OutputPath(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual OutputPath Clone(string name, int itemNr)
|
||||
{
|
||||
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.Balance = Balance;
|
||||
result.EmptyTankValve = EmptyTankValve;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores one test procedure, supports revisions and history log
|
||||
/// </summary>
|
||||
public class Procedure : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
public virtual string Description { get; set; } /// Short description
|
||||
public virtual string CreationUser { get; set; } /// Name of the user who has created or changed this procedure
|
||||
public virtual DateTime CreationTime { get; set; } /// Date and time of the creation or change
|
||||
public virtual string LastChgUser { get; set; } /// Name of the user who has created or changed this procedure
|
||||
public virtual DateTime LastChgTime { get; set; } /// Date and time of the creation or change
|
||||
public virtual string LongDescription { get; set; } /// Long description (notes)
|
||||
|
||||
public virtual ProcedureState ProcedureState { get; set; }
|
||||
public virtual int Revision { get; set; }
|
||||
public virtual int PredecessorId { get; set; }
|
||||
public virtual bool ObtainedByCopy { get; set; }
|
||||
///
|
||||
public virtual MetersKind MetersKind { get; set; }
|
||||
public virtual string Watermeters { get; set; } /// Water meter name or Id
|
||||
public virtual string ProtocolTitle { get; set; } /// Title of the printed and saved protocol
|
||||
|
||||
public virtual string DataEntry { get; set; } /// Component to use for data entry
|
||||
public virtual string ResultsPrinter { get; set; } /// Component to use for printing the results
|
||||
public virtual string ResultsWriter { get; set; } /// Component to use for saving the results into the file
|
||||
public virtual string TransitionStart { get; set; }
|
||||
public virtual string TransitionEnd { get; set; }
|
||||
|
||||
public virtual IList<ComponentProcedure> MoreParams { get; set; }
|
||||
public virtual IList<Test> Tests { get; set; }
|
||||
|
||||
////public virtual string MetrologicalClass { get; set; }
|
||||
////public virtual IList<WMType> WMTypes { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public Procedure()
|
||||
{
|
||||
MoreParams = new List<ComponentProcedure>();
|
||||
Tests = new List<Test>();
|
||||
|
||||
///
|
||||
/// Default values
|
||||
///
|
||||
CreationUser = (User.CurrentUser != null) ? User.CurrentUser.Name : null;
|
||||
CreationTime = DateTime.Now;
|
||||
LastChgUser = CreationUser;
|
||||
LastChgTime = CreationTime;
|
||||
MetersKind = Entities.MetersKind.Single;
|
||||
ProtocolTitle = "Watermeter test protocol";
|
||||
}
|
||||
|
||||
public Procedure(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual Procedure Clone()
|
||||
{
|
||||
Procedure result = new Procedure();
|
||||
|
||||
result.Name = Name;
|
||||
result.MetersKind = MetersKind;
|
||||
result.Description = Description;
|
||||
result.CreationUser = CreationUser;
|
||||
result.CreationTime = CreationTime;
|
||||
result.LastChgUser = LastChgUser;
|
||||
result.LastChgTime = LastChgTime;
|
||||
result.LongDescription = LongDescription;
|
||||
|
||||
result.ProcedureState = ProcedureState.Active;
|
||||
result.PredecessorId = Id;
|
||||
|
||||
result.Watermeters = Watermeters;
|
||||
result.DataEntry = DataEntry;
|
||||
result.ResultsPrinter = ResultsPrinter;
|
||||
result.ResultsWriter = ResultsWriter;
|
||||
result.TransitionStart = TransitionStart;
|
||||
result.TransitionEnd = TransitionEnd;
|
||||
|
||||
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
|
||||
foreach (var test in Tests) { result.Tests.Add(test.Clone()); }
|
||||
|
||||
//result.MetrologicalClass = MetrologicalClass;
|
||||
//result.WMType = WMType.Clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}, rev.{1}", Name, Revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class ProcedureHistory
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual Procedure Current { get; set; }
|
||||
public virtual IList<Procedure> OldProcedures { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public ProcedureHistory()
|
||||
{
|
||||
Current = new Procedure();
|
||||
OldProcedures = new List<Procedure>();
|
||||
}
|
||||
|
||||
public virtual ProcedureHistory Clone()
|
||||
{
|
||||
ProcedureHistory result = new ProcedureHistory();
|
||||
result.Current = Current.Clone();
|
||||
foreach (Procedure p in OldProcedures) result.OldProcedures.Add(p.Clone());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajik
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Test, consisting of one or more repetitions of the test 'SingleTest'.
|
||||
/// </summary>
|
||||
public class Test : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual int Part { get; set; } /// Part=0 ... test of all WM-s
|
||||
/// Part>0 ... part of a set of tests with the same Name: subset of WM-s is given by MetersPath
|
||||
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 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 string Method { get; set; }
|
||||
public virtual float ErrLimLo { get; set; } /// in [%] (usually < 0)
|
||||
public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0)
|
||||
public virtual float Uncertainty { get; set; } /// int [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
||||
public virtual int Repeats { get; set; }
|
||||
public virtual bool Emptying { get; set; }
|
||||
public virtual bool Zeroing { get; set; }
|
||||
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 bool MassMethod { get; set; } /// method of mass. measurement at the beginning/end of test: false=slow (precise), true=fast (immediate)
|
||||
public virtual int TimeBeforeFlow { get; set; } /// Delay time before the start of flow control in [s]
|
||||
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 TestRedType RedType { get; set; }
|
||||
public virtual string FeedingPath { get; set; }
|
||||
public virtual string BenchPath { get; set; }
|
||||
public virtual string OutputPath { get; set; }
|
||||
public virtual string MetersPath { get; set; }
|
||||
#if HEAT_METERS_SUPPORT
|
||||
public virtual string HeatMetersPath { get; set; }
|
||||
#endif
|
||||
public virtual string RelTransBefore { get; set; }
|
||||
public virtual string RelTransBetween { get; set; }
|
||||
public virtual string RelTransAfter { get; set; }
|
||||
public virtual string TransitionAfter { get; set; }
|
||||
|
||||
public virtual IList<ComponentTest> MoreParams { get; set; }
|
||||
|
||||
public virtual Procedure Procedure { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public Test()
|
||||
{
|
||||
MoreParams = new List<ComponentTest>();
|
||||
|
||||
///
|
||||
/// Default values
|
||||
///
|
||||
Publish = (sbyte)Config.Entities.Publish.Always;
|
||||
Evaluate = true;
|
||||
Repeats = 1;
|
||||
Emptying = false;
|
||||
Zeroing = false;
|
||||
ErrLimLo = -2.0f; /// [%] lower error limit
|
||||
ErrLimHi = 2.0f; /// [%] upper error limit
|
||||
Uncertainty = 0;
|
||||
PumpPower = 60.0f; /// [%]
|
||||
MassRepeats = 0; /// default
|
||||
MassSpread = 0; /// default
|
||||
MassMethod = false; /// 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;
|
||||
RelTransAfter = string.Empty;
|
||||
TransitionAfter = string.Empty;
|
||||
}
|
||||
|
||||
public Test(string name, int itemNr, Procedure procedure)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
Procedure = procedure;
|
||||
}
|
||||
|
||||
// Makes a new copy of this object (not just a reference)
|
||||
public virtual Test Clone()
|
||||
{
|
||||
Test result = new Test(Name, ItemNr, Procedure);
|
||||
|
||||
result.Part = Part;
|
||||
result.Publish = Publish;
|
||||
result.Evaluate = Evaluate;
|
||||
result.Qfrom = Qfrom;
|
||||
result.Qto = Qto;
|
||||
result.Volume = Volume;
|
||||
result.TstTime = TstTime;
|
||||
result.Repeats = Repeats;
|
||||
result.Emptying = Emptying;
|
||||
result.Zeroing = Zeroing;
|
||||
result.PumpPower = PumpPower;
|
||||
result.MassRepeats = MassRepeats;
|
||||
result.MassSpread = MassSpread;
|
||||
result.MassMethod = MassMethod;
|
||||
result.TimeBeforeFlow = TimeBeforeFlow;
|
||||
result.TimeFlow2Mass = TimeFlow2Mass;
|
||||
result.TimePump2StartV = TimePump2StartV;
|
||||
result.TimeStop2Mass = TimeStop2Mass;
|
||||
result.Method = Method;
|
||||
result.ErrLimLo = ErrLimLo;
|
||||
result.ErrLimHi = ErrLimHi;
|
||||
result.Uncertainty = Uncertainty;
|
||||
result.TolerRed = TolerRed;
|
||||
result.RedType = RedType;
|
||||
result.FeedingPath = FeedingPath;
|
||||
result.BenchPath = BenchPath;
|
||||
result.OutputPath = OutputPath;
|
||||
result.MetersPath = MetersPath;
|
||||
#if HEAT_METERS_SUPPORT
|
||||
result.HeatMetersPath = HeatMetersPath;
|
||||
#endif
|
||||
result.RelTransBefore = RelTransBefore;
|
||||
result.RelTransBetween = RelTransBetween;
|
||||
result.RelTransAfter = RelTransAfter;
|
||||
result.TransitionAfter = TransitionAfter;
|
||||
foreach (var prms in MoreParams) { result.MoreParams.Add(prms.Clone()); }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string partStr = (Part > 0) ? string.Format(", part {0}", Part) : string.Empty;
|
||||
|
||||
return string.Format("{0}(P.{1},{2}){3}", Name, ((Publish)Publish).ToString(), Evaluate ? "E" : "-", partStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class TestResult
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual int BatchNr { get; set; }
|
||||
public virtual string PurchaseOrder { get; set; }
|
||||
public virtual MetersKind MetersKind { get; set; }
|
||||
public virtual IList<MeterTestResult> Meters { get; set; }
|
||||
public virtual IList<MeterTestResult> CombinedMeters { get; set; }
|
||||
|
||||
/// Value copied from the procedure (Entities.Procedure)
|
||||
public virtual string ProcedureName { get; set; }
|
||||
public virtual string ProtocolTitle { get; set; }
|
||||
|
||||
/// Values copied from the test (Entities.Test)
|
||||
public virtual int TestId { get; set; } /// Test entity ID to distinguish between tests with the same name
|
||||
public virtual string TestName { get; set; }
|
||||
public virtual int Part { get; set; }
|
||||
public virtual bool DoNotEvaluate { get; set; } /// Not mapped to the database
|
||||
public virtual bool DoNotPublish { get; set; } /// Not mapped to the database
|
||||
public virtual float Qfrom { get; set; } /// [m3/h] Water flow low limit
|
||||
public virtual float Qto { get; set; } /// [m3/h] Water flow high limit
|
||||
public virtual float Volume { get; set; } /// [l] Target test volume
|
||||
public virtual float TstTime { get; set; } /// [s] Test time estimate
|
||||
public virtual int Repeats { get; set; }
|
||||
public virtual bool Emptying { get; set; }
|
||||
public virtual bool Zeroing { get; set; }
|
||||
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 Time2MassMsrmt { get; set; }
|
||||
public virtual string Method { get; set; }
|
||||
public virtual float ErrLimLo { get; set; } /// [%] Lower error limit (usually < 0)
|
||||
public virtual float ErrLimHi { get; set; } /// [%] Upper error limit (usually > 0)
|
||||
public virtual float Uncertainty { get; set; } /// [%] Makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
||||
|
||||
/// To be replaced by the virtual bench component parameters
|
||||
public virtual string FeedingPath { get; set; }
|
||||
public virtual string BenchPath { get; set; }
|
||||
public virtual string OutputPath { get; set; }
|
||||
public virtual string MetersPath { get; set; }
|
||||
|
||||
/// Results
|
||||
public virtual DateTime TimeStart { get; set; } /// Date and time of the test start
|
||||
public virtual DateTime TimeEnd { get; set; } /// Date and time of the test end
|
||||
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
|
||||
public virtual float AmbientTempAve { get; set; } /// [deg.C] Average ambient air temperature
|
||||
public virtual float AmbientPressAve { get; set; } /// Average ambient air pressure
|
||||
public virtual float AmbientHumiAve { get; set; } /// [%] Average ambient air relative humidity
|
||||
public virtual float PressInAvrg { get; set; } /// [Bar] Input water pressure (average)
|
||||
public virtual float PressInStart { get; set; } /// [Bar]
|
||||
public virtual float PressInEnd { get; set; } /// [Bar]
|
||||
public virtual float PressOutAvrg { get; set; } /// [Bar]
|
||||
public virtual float PressOutStart { get; set; } /// [Bar]
|
||||
public virtual float PressOutEnd { get; set; } /// [Bar]
|
||||
public virtual float TempInAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempInStart { get; set; } /// [deg.C]
|
||||
public virtual float TempInEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempOutAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempOutStart { get; set; } /// [deg.C]
|
||||
public virtual float TempOutEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempDivAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempDivStart { get; set; } /// [deg.C]
|
||||
public virtual float TempDivEnd { get; set; } /// [deg.C]
|
||||
public virtual float MassStartRaw { get; set; } /// [kg]
|
||||
public virtual float MassStart { get; set; } /// [kg]
|
||||
public virtual float MassEndRaw { get; set; } /// [kg]
|
||||
public virtual float MassEnd { get; set; } /// [kg]
|
||||
public virtual float MassDiff { get; set; } /// [kg]
|
||||
public virtual float DensityIn { get; set; } /// [kg/m3]
|
||||
public virtual float DensityOut { get; set; } /// [kg/m3]
|
||||
public virtual float DensityDiv { get; set; } /// [kg/m3]
|
||||
public virtual float Buoyancy { get; set; } ///TODO -> map
|
||||
public virtual float FlowMass { get; set; } /// [kg/h] calculated from conventional true value
|
||||
public virtual float FlowVolume { get; set; } /// [l/h] calculated from conventional true value
|
||||
public virtual float VolumeCTV { get; set; } /// [l] Volume conventional true value
|
||||
public virtual float VolumeMaster { get; set; } /// [l] Volume from the master flow meter
|
||||
public virtual float Time { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual float ErrorMaster { get; set; } /// [%]
|
||||
public virtual float PulsesMaster { get; set; }
|
||||
public virtual float ConstMaster { get; set; } /// [pls/l] Pulses per liter master flow meter
|
||||
public virtual float QRise { get; set; } /// Detected Q_rise of a composed meter
|
||||
public virtual float QFall { get; set; } /// Detected Q_fall of a composed meter
|
||||
public virtual float TimeDivStart0 { get; set; }
|
||||
public virtual float TimeDivStart1 { get; set; }
|
||||
public virtual float TimeDivStart2 { get; set; }
|
||||
public virtual float TimeDivStart3 { get; set; }
|
||||
public virtual float TimeDivStart4 { get; set; }
|
||||
public virtual float TimeDivStart5 { get; set; }
|
||||
public virtual float TimeDivEnd0 { get; set; }
|
||||
public virtual float TimeDivEnd1 { get; set; }
|
||||
public virtual float TimeDivEnd2 { get; set; }
|
||||
public virtual float TimeDivEnd3 { get; set; }
|
||||
public virtual float TimeDivEnd4 { get; set; }
|
||||
public virtual float TimeDivEnd5 { get; set; }
|
||||
|
||||
public TestResult()
|
||||
{
|
||||
Meters = new List<MeterTestResult>();
|
||||
CombinedMeters = new List<MeterTestResult>();
|
||||
}
|
||||
|
||||
public TestResult(MetersKind kind)
|
||||
: this()
|
||||
{
|
||||
MetersKind = kind;
|
||||
|
||||
if (kind == MetersKind.Single)
|
||||
{
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++) Meters.Add(new MeterTestResult(this));
|
||||
}
|
||||
else if (kind == MetersKind.Combined)
|
||||
{
|
||||
for (int i = 0; i < 2 * Config.Data.CompoundWMsCount; i++) Meters.Add(new MeterTestResult(this));
|
||||
for (int i = 0; i < Config.Data.CompoundWMsCount; i++) CombinedMeters.Add(new MeterTestResult(this));
|
||||
}
|
||||
}
|
||||
|
||||
public TestResult(Test test, int repetitionNr, MetersKind kind)
|
||||
: this(kind)
|
||||
{
|
||||
if (test.Repeats == 1)
|
||||
{
|
||||
Name = test.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = string.Format("{0} ({1}/{2})", test.Name, repetitionNr, test.Repeats);
|
||||
}
|
||||
RepetitionNr = repetitionNr;
|
||||
|
||||
/// Copy test parameters from Entities.Procedure object
|
||||
ProcedureName = test.Procedure.Name;
|
||||
ProtocolTitle = test.Procedure.ProtocolTitle;
|
||||
|
||||
/// Copy test parameters from Entities.Test object
|
||||
TestId = test.Id;
|
||||
TestName = test.Name;
|
||||
Part = test.Part;
|
||||
Qfrom = test.Qfrom;
|
||||
Qto = test.Qto;
|
||||
Volume = test.Volume;
|
||||
TstTime = test.TstTime;
|
||||
Repeats = test.Repeats;
|
||||
Emptying = test.Emptying;
|
||||
Zeroing = test.Zeroing;
|
||||
PumpPower = PumpPower;
|
||||
Time2MassMsrmt = test.TimeStop2Mass;
|
||||
Method = test.Method;
|
||||
ErrLimLo = test.ErrLimLo;
|
||||
ErrLimHi = test.ErrLimHi;
|
||||
Uncertainty = test.Uncertainty;
|
||||
|
||||
FeedingPath = test.FeedingPath;
|
||||
BenchPath = test.BenchPath;
|
||||
OutputPath = test.OutputPath;
|
||||
MetersPath = test.MetersPath;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", BatchNr, ProcedureName, TestName, TimeStart.ToShortDateString(), TimeStart.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores one transition sequence containing a list of transition steps
|
||||
/// </summary>
|
||||
public class TransitionSequence : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Description { get; set; } /// Short description
|
||||
public virtual IList<TransitionStep> TransitionSteps { get; set; }
|
||||
|
||||
public TransitionSequence()
|
||||
{
|
||||
TransitionSteps = new List<TransitionStep>();
|
||||
}
|
||||
|
||||
public TransitionSequence(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual TransitionSequence Clone()
|
||||
{
|
||||
TransitionSequence result = new TransitionSequence();
|
||||
result.Name = Name;
|
||||
result.Description = Description;
|
||||
foreach (var step in TransitionSteps) { result.TransitionSteps.Add(step.Clone()); }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class TransitionStep : IHasItemNr, IHasValves
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; } /// Order of the preparation step
|
||||
public virtual int Duration { get; set; } /// Duration in seconds
|
||||
public virtual string Message { get; set; } /// Message
|
||||
public virtual StepCondition EndCondition { get; set; } /// Condition when transition step is finished (next to the duration)
|
||||
public virtual string ValvesOpen { get; set; } /// List of valves to be opened
|
||||
public virtual string ValvesClose { get; set; } /// List of valves to be closed
|
||||
public virtual string RegulValvesPct { get; set; } /// Positions of regulation valves in % separated by ';'
|
||||
public virtual string PumpWithFMPcts { get; set; } /// Power of FM controlled pumps in % separated by ';'
|
||||
|
||||
public virtual TransitionSequence TransitionSequence { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public TransitionStep()
|
||||
{
|
||||
Duration = 5; /// sec.
|
||||
EndCondition = (int)StepCondition.None;
|
||||
}
|
||||
|
||||
public TransitionStep(int itemNr, TransitionSequence sequence)
|
||||
: this()
|
||||
{
|
||||
ItemNr = itemNr;
|
||||
TransitionSequence = sequence;
|
||||
}
|
||||
|
||||
public virtual TransitionStep Clone()
|
||||
{
|
||||
TransitionStep result = new TransitionStep(ItemNr, TransitionSequence);
|
||||
result.Duration = Duration;
|
||||
result.Message = Message;
|
||||
result.EndCondition = EndCondition;
|
||||
result.ValvesOpen = ValvesOpen;
|
||||
result.ValvesClose = ValvesClose;
|
||||
result.RegulValvesPct = RegulValvesPct;
|
||||
result.PumpWithFMPcts = PumpWithFMPcts;
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual string ToString(string indent)
|
||||
{
|
||||
string result = "";
|
||||
result += indent + "ItemNr = " + ItemNr.ToString() + ", ";
|
||||
result += indent + "Duration = " + Duration.ToString() + ", ";
|
||||
result += indent + "Message = " + Message + ", ";
|
||||
result += indent + "EndCondition = " + EndCondition.ToString() + ", ";
|
||||
result += indent + "ValvesOpen = " + ValvesOpen.ToString() + ", ";
|
||||
result += indent + "ValvesClose = " + ValvesClose.ToString() + ", ";
|
||||
result += indent + "RegulValvesPct = " + RegulValvesPct.ToString() + ", ";
|
||||
result += indent + "PumpsWithFMPct = " + RegulValvesPct.ToString() + Environment.NewLine;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using Config.Resources;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Password { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual DateTime LastPwChange { get; set; }
|
||||
public virtual IList<Group> Groups { get; set; } //User can be a member of a list of groups
|
||||
|
||||
private bool powerUser; /// Set to tue for built-in users, power users have full access even with empty Groups
|
||||
|
||||
public User()
|
||||
{
|
||||
this.powerUser = false;
|
||||
Groups = new List<Group>();
|
||||
}
|
||||
|
||||
public virtual void AddGroup(Group group)
|
||||
{
|
||||
Groups.Add(group);
|
||||
}
|
||||
|
||||
|
||||
public User(string name)
|
||||
{
|
||||
this.powerUser = true;
|
||||
Name = name;
|
||||
Groups = new List<Group>();
|
||||
Description = "Power user";
|
||||
}
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
///
|
||||
/// Authorized user (static)
|
||||
///
|
||||
private static User currentUser = null; /// Updated by instance methods Authorize, Unauthorize
|
||||
public static User CurrentUser
|
||||
{
|
||||
get { return currentUser; }
|
||||
set { currentUser = value; }
|
||||
}
|
||||
|
||||
private static DateTime lastAuthorization = DateTime.Now;
|
||||
public static DateTime LastAuthorization { get { return lastAuthorization; } }
|
||||
|
||||
/// <summary>
|
||||
/// Check whether user is a member of a group.
|
||||
/// </summary>
|
||||
/// <param name="groupId">Group GID</param>
|
||||
/// <returns>true is user is a member of the specified group</returns>
|
||||
public virtual bool IsMemberOf(Grp.GID groupId)
|
||||
{
|
||||
if (groupId == Grp.GID.None || powerUser)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (groupId >= 0 && (int)groupId < Grp.Count)
|
||||
{
|
||||
// for all group elements in User.groups
|
||||
for (int i = 0; i < Groups.Count; ++i)
|
||||
{
|
||||
// element GID = parameter GroupId ?
|
||||
if (((Group)Groups[i]).Gid == (int)groupId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets users password. It then will be encrypted.
|
||||
/// </summary>
|
||||
/// <param name="password">Password</param>
|
||||
public virtual void SetPassword(string password)
|
||||
{
|
||||
this.Password = EncryptedPassword(password);
|
||||
LastPwChange = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
public virtual string EncryptedPassword(string password)
|
||||
{
|
||||
return getHash(password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies users password. Used by static bool Authorisation(...)
|
||||
/// </summary>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true if password is correct</returns>
|
||||
public virtual bool CheckPassword(string password)
|
||||
{
|
||||
return (Password == EncryptedPassword(password));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The FIRST of TWO possible user authorization method to be used
|
||||
/// when a specific group membership is required (you can use Grp.GID.None).
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGrupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password, Grp.GID requiredGroupMembership)
|
||||
{
|
||||
if (Entities.User.IsPowerUser(userName, password))
|
||||
{
|
||||
currentUser = this;
|
||||
lastAuthorization = DateTime.Now;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Name.ToLower() == userName.ToLower())
|
||||
{
|
||||
if (IsMemberOf(requiredGroupMembership) && CheckPassword(password))
|
||||
{
|
||||
currentUser = this;
|
||||
lastAuthorization = DateTime.Now;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SECOND of TWO possible user authorization method to be used when
|
||||
/// no specific group membership is required.
|
||||
/// If the user is not authorized, the current user remains to be a current user
|
||||
/// (i.e. the access rights were not risen to a higher level).
|
||||
/// If you require different behavior, use Unauthorize() before calling Authorize().
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="requiredGroupMembership"></param>
|
||||
/// <returns>true = authorized</returns>
|
||||
public virtual bool Authorize(string userName, string password)
|
||||
{
|
||||
return Authorize(userName, password, Grp.GID.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from a database.
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User AuthorizeDummyUser(string username)
|
||||
{
|
||||
User user = new User();
|
||||
user.Name = username;
|
||||
currentUser = user;
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from an ARBITRARY database.
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username, DBSettings dbSettings)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSessionFactory(DBKind.Config, dbSettings, false)
|
||||
.OpenSession()
|
||||
.CreateQuery("FROM User WHERE LOWER(Name) = :username")
|
||||
.SetParameter("username", username.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 'User' with a given username from the users database.
|
||||
/// </summary>
|
||||
/// <param name="username">User name for the query</param>
|
||||
/// <returns>reference to a 'User' (if it exists) or null</returns>
|
||||
public static User LoadUserByName(string username)
|
||||
{
|
||||
IList<User> listOfUsers = FluentCommon.CreateSession(DBKind.Config)
|
||||
.CreateQuery("FROM User WHERE LOWER(Name) = :username")
|
||||
.SetParameter("username", username.ToLower())
|
||||
.List<User>();
|
||||
if (listOfUsers.Count > 0) return listOfUsers[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns an IList of all Users
|
||||
/// </summary>
|
||||
public static IList<User> GetAllUsers()
|
||||
{
|
||||
return FluentCommon.CreateSession(DBKind.Config)
|
||||
.CreateQuery("FROM User")
|
||||
.List<User>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unauthorize, abandon current users authorization.
|
||||
/// </summary>
|
||||
public static void Unauthorize()
|
||||
{
|
||||
currentUser = null;
|
||||
lastAuthorization = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// getHash encrypts a string
|
||||
/// </summary>
|
||||
/// <param name="text">the string to encrypt</param>
|
||||
/// <returns></returns>
|
||||
public static string getHash(string text)
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(text);
|
||||
SHA512Managed hashstring = new SHA512Managed();
|
||||
byte[] hash = hashstring.ComputeHash(bytes);
|
||||
string hashString = string.Empty;
|
||||
foreach (byte x in hash)
|
||||
{
|
||||
hashString += String.Format("{0:x2}", x);
|
||||
}
|
||||
return hashString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns 'true' when authentication data are valid for a power user.
|
||||
/// </summary>
|
||||
/// <param name="userName">User name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <returns>true = authenticated, false = refused</returns>
|
||||
public static bool IsPowerUser(string userName, string password)
|
||||
{
|
||||
return (userName.Equals("milan") && password.Equals("napajedla")) ||
|
||||
(userName.Equals("igor") && password.Equals("ronko4")) ||
|
||||
(userName.Equals("janb") && password.Equals("sen345bnaj21")) ||
|
||||
(userName.Equals("vlado") && password.Equals("luskovica.430"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class VirtualBenchSequence : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Description { get; set; } /// Short description
|
||||
public virtual IList<VirtualBenchStep> VirtualBenchSteps { get; set; }
|
||||
|
||||
public VirtualBenchSequence()
|
||||
{
|
||||
VirtualBenchSteps = new List<VirtualBenchStep>();
|
||||
}
|
||||
|
||||
public VirtualBenchSequence(string name, int itemNr)
|
||||
: this()
|
||||
{
|
||||
Name = name;
|
||||
ItemNr = itemNr;
|
||||
}
|
||||
|
||||
public virtual VirtualBenchSequence Clone()
|
||||
{
|
||||
VirtualBenchSequence result = new VirtualBenchSequence();
|
||||
result.Name = Name;
|
||||
result.Description = Description;
|
||||
foreach (var step in VirtualBenchSteps) { result.VirtualBenchSteps.Add(step.Clone()); }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class VirtualBenchStep : IHasItemNr
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int ItemNr { get; set; } /// Order of the preparation step
|
||||
public virtual int Duration { get; set; } /// Duration in seconds
|
||||
///
|
||||
|
||||
public virtual VirtualBenchSequence VirtualBenchSequence { get; set; }
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public VirtualBenchStep()
|
||||
{
|
||||
Duration = 5; /// sec.
|
||||
}
|
||||
|
||||
public VirtualBenchStep(int itemNr, VirtualBenchSequence sequence)
|
||||
: this()
|
||||
{
|
||||
ItemNr = itemNr;
|
||||
VirtualBenchSequence = sequence;
|
||||
}
|
||||
|
||||
public virtual VirtualBenchStep Clone()
|
||||
{
|
||||
VirtualBenchStep result = new VirtualBenchStep(ItemNr, VirtualBenchSequence);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/// This class holds the watermeter type specific data
|
||||
/// that have all watermaters of the same type in common
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class WMType
|
||||
{
|
||||
// mapped
|
||||
public virtual int Id { get; protected set; } /// primary key
|
||||
public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change
|
||||
public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure
|
||||
public virtual string CreateDescription { get; set; } /// Description\
|
||||
|
||||
public virtual string Name { get; set; } /// type name
|
||||
public virtual float PulseRate { get; set; } /// Pulses per Liter
|
||||
|
||||
// not yet mapped
|
||||
public virtual int IdentNr { get; protected set; } /// identification number of watermeter tzpe
|
||||
public virtual int Diameter { get; set; } /// nominal diameter
|
||||
public virtual int Pressure { get; set; } /// nominal pressure
|
||||
public virtual int Length { get; set; } /// construction length
|
||||
public virtual int Temperatur { get; set; } /// nominal temperature in C
|
||||
public virtual float NominalFlow { get; set; } /// nominal flow Qn
|
||||
|
||||
/// ------------- Additional stuff not mapped into the database -------------
|
||||
|
||||
public WMType()
|
||||
{
|
||||
}
|
||||
|
||||
public static WMType DefaultWMType()
|
||||
{
|
||||
WMType procedure = new WMType()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
CreateUserName = User.CurrentUser.Name,
|
||||
CreateDescription = "A default water meter created.",
|
||||
Name = "Watermeter",
|
||||
PulseRate = 1000,
|
||||
};
|
||||
return procedure;
|
||||
}
|
||||
|
||||
public virtual WMType Clone()
|
||||
{
|
||||
WMType result = new WMType();
|
||||
|
||||
result.CreateTime = CreateTime;
|
||||
result.CreateUserName = CreateUserName;
|
||||
result.CreateDescription = CreateDescription;
|
||||
result.Name = Name;
|
||||
result.PulseRate = PulseRate;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = "";
|
||||
result += "WMTpe: " + Environment.NewLine;
|
||||
result += " Name = " + Name + Environment.NewLine;
|
||||
result += " Created by = " + CreateUserName + Environment.NewLine;
|
||||
result += " Created on = " + CreateTime.ToString() + Environment.NewLine;
|
||||
result += " Description = " + CreateDescription + Environment.NewLine;
|
||||
result += " Pulse rate = " + PulseRate.ToString() + Environment.NewLine;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using NHibernate;
|
||||
using FluentNHibernate;
|
||||
|
||||
namespace Config.Entities
|
||||
{
|
||||
public class Watermeter
|
||||
{
|
||||
public virtual int Id { get; protected set; } /// primary key
|
||||
|
||||
public virtual DateTime CreateTime { get; set; } /// Date and time of the creation or change
|
||||
public virtual string CreateUserName { get; set; } /// Name of the user who has created or changed this procedure
|
||||
public virtual string CreateDescription { get; set; } /// Description
|
||||
|
||||
/// mapped
|
||||
public virtual string Serial { get; set; } /// serial number
|
||||
public virtual WMType WMType { get; set; } /// type of watermeter
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// Load a watermeter from the database
|
||||
/// </summary>
|
||||
public static Watermeter LoadBySerialnr(string SerialNr)
|
||||
{
|
||||
IList<Watermeter> ListOfWatermeters = FluentCommon.CreateSession(DBKind.Results)
|
||||
.CreateQuery("FROM Watermeter WHERE Serial = :SerialNrParameter")
|
||||
.SetParameter("SerialNrParameter", SerialNr)
|
||||
.List<Watermeter>();
|
||||
if (ListOfWatermeters.Count > 0) return ListOfWatermeters.ElementAt(0);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
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)Entities.DBKind.Count];
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
static ISessionFactory CreateSessionFactory(Entities.DBKind database)
|
||||
{
|
||||
Entities.DBType dbType;
|
||||
string connectionString;
|
||||
|
||||
switch (database)
|
||||
{
|
||||
default:
|
||||
case Entities.DBKind.Config:
|
||||
dbType = Data.CurrentBench.ProceduresDBSettings.DbType;
|
||||
connectionString = Data.CurrentBench.ProceduresDBSettings.ConnectionString;
|
||||
break;
|
||||
case Entities.DBKind.Results:
|
||||
dbType = Data.CurrentBench.WaterMetersDBSettings.DbType;
|
||||
connectionString = Data.CurrentBench.WaterMetersDBSettings.ConnectionString;
|
||||
break;
|
||||
}
|
||||
|
||||
return CreateSessionFactory(database, new DBSettings(dbType, connectionString), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
public static ISessionFactory CreateSessionFactory(Entities.DBKind database, DBSettings dbSettings, bool createDB)
|
||||
{
|
||||
try
|
||||
{
|
||||
FluentConfiguration cfg = Fluently.Configure();
|
||||
|
||||
switch (dbSettings.DbType)
|
||||
{
|
||||
default:
|
||||
case Entities.DBType.SQLite:
|
||||
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(dbSettings.ConnectionString));
|
||||
break;
|
||||
case Entities.DBType.MySql:
|
||||
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(dbSettings.ConnectionString));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (database)
|
||||
{
|
||||
default:
|
||||
case Entities.DBKind.Config:
|
||||
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Data>());
|
||||
break;
|
||||
case 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("Cannot open database.\r\nReason:\r\n{0}", exc.Message),
|
||||
"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(Entities.DBKind database)
|
||||
{
|
||||
int ix = (int)database;
|
||||
if (ix < 0 || ix >= (int)Entities.DBKind.Count) return null;
|
||||
|
||||
if (SessionFactories[ix] == null) SessionFactories[ix] = CreateSessionFactory(database);
|
||||
|
||||
return SessionFactories[ix].OpenSession();
|
||||
}
|
||||
|
||||
public static void SaveToDb(Entities.DBKind database, object obj)
|
||||
{
|
||||
SaveToDb(CreateSession(database), obj);
|
||||
}
|
||||
|
||||
public static void SaveToDb(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.SaveOrUpdate(obj);
|
||||
try { transaction.Commit(); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteFromDb(Entities.DBKind database, object obj)
|
||||
{
|
||||
DeleteFromDb(CreateSession(database), obj);
|
||||
}
|
||||
|
||||
public static void DeleteFromDb(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.Delete(obj);
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <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(DBSettings dbSettings)
|
||||
{
|
||||
ISessionFactory sessionFactory = CreateSessionFactory(Entities.DBKind.Config, dbSettings, true);
|
||||
if (sessionFactory == null) return false;
|
||||
|
||||
/// Populate the database
|
||||
using (var session = sessionFactory.OpenSession())
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
///
|
||||
/// Prepare all groups
|
||||
///
|
||||
var testers = new Entities.Group { Gid = (int)Grp.GID.Testers, Name = Strings.Tester };
|
||||
var testingSpecialists = new Entities.Group { Gid = (int)Grp.GID.TestingSpecialists, Name = Strings.Testing_Specialist };
|
||||
var headOfLab = new Entities.Group { Gid = (int)Grp.GID.HeadOfLab, Name = Strings.Head_of_Lab };
|
||||
var maintenanceSpecialists = new Entities.Group { Gid = (int)Grp.GID.MaintenanceSpecialists, Name = Strings.Maintenance_Specialist };
|
||||
var metrologists = new Entities.Group { Gid = (int)Grp.GID.Metrologists, Name = Strings.Metrologist };
|
||||
var calibrationSpecialists = new Entities.Group { Gid = (int)Grp.GID.CalibrationSpecialists, Name = Strings.Calibration_Specialist };
|
||||
var administrators = new Entities.Group { Gid = (int)Grp.GID.Administrators, Name = Strings.Administrator };
|
||||
|
||||
/// Create the user 'admin' add his groups
|
||||
var admin = new Entities.User
|
||||
{
|
||||
Name = Data.AdminUsername,
|
||||
Description = "Administrator",
|
||||
LastPwChange = DateTime.Now
|
||||
};
|
||||
admin.SetPassword(Data.AdminPassword);
|
||||
admin.AddGroup(testers);
|
||||
admin.AddGroup(testingSpecialists);
|
||||
admin.AddGroup(headOfLab);
|
||||
admin.AddGroup(maintenanceSpecialists);
|
||||
admin.AddGroup(metrologists);
|
||||
admin.AddGroup(calibrationSpecialists);
|
||||
admin.AddGroup(administrators);
|
||||
|
||||
session.SaveOrUpdate(admin);
|
||||
|
||||
///// Create the control board component
|
||||
//var cmpnt = (new BenchControl.Elde.ControlBoardCfg(new BenchControl.Elde.ControlBoardFactory())).CreateDbEntity();
|
||||
//session.SaveOrUpdate(cmpnt);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an empty water meters database
|
||||
/// </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 CreateEmptyResultsDB(DBSettings dbSettings)
|
||||
{
|
||||
ISessionFactory sessionFactory = CreateSessionFactory(Entities.DBKind.Results, dbSettings, true);
|
||||
if (sessionFactory == null) return false;
|
||||
|
||||
/// Populate the database
|
||||
//using (var session = sessionFactory.OpenSession())
|
||||
//{
|
||||
// using (var transaction = session.BeginTransaction())
|
||||
// {
|
||||
// /// Create one component
|
||||
// var cmpnt = (new BenchControl.Elde.ControlBoardCfg("CB", 1)).CreateDbEntity();
|
||||
// session.SaveOrUpdate(cmpnt);
|
||||
// transaction.Commit();
|
||||
// }
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Config.Entities;
|
||||
using NHibernate;
|
||||
using FluentNHibernate;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum Grp.GID specifies GID-s of user groups.
|
||||
/// An instance of this class represenst a group, which contains a list of its members (users).
|
||||
/// Static private array 'groups' of this class, accesible through indexer, contains all groups.
|
||||
/// </summary>
|
||||
public class Grp
|
||||
{
|
||||
/// <summary>
|
||||
/// GID-s of user groups, each user is member of one or more groups.
|
||||
/// </summary>
|
||||
public enum GID
|
||||
{
|
||||
// The first NrOfGroups items are GroupID-s (0..NrOfGroups-1)
|
||||
Testers = 0,
|
||||
TestingSpecialists,
|
||||
HeadOfLab,
|
||||
MaintenanceSpecialists,
|
||||
Metrologists,
|
||||
CalibrationSpecialists,
|
||||
Administrators, // application / network / database administrator
|
||||
Custom1,
|
||||
Custom2,
|
||||
Custom3,
|
||||
NrOfGroups, // Number of groups (this is not a GroupID)
|
||||
None, // Not a GroupID, can be used to indicate no group membership is required
|
||||
Invalid = -1, // Not a GroupID, indicates a variable has not been properly set so far
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of groups.
|
||||
/// </summary>
|
||||
public const int Count = (int)GID.NrOfGroups;
|
||||
|
||||
// Static array of all groups.
|
||||
static Grp[] groups;
|
||||
|
||||
/// <summary>
|
||||
/// Static constructor, creates all groups with no members.
|
||||
/// </summary>
|
||||
static Grp()
|
||||
{
|
||||
groups = new Grp[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
groups[i] = new Grp((GID)i);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a Group from Id.
|
||||
/// </summary>
|
||||
/// <param name="id">Group Gid</param>
|
||||
/// <returns>Entities.Group object reference</returns>
|
||||
public static Entities.Group FromId(GID gid)
|
||||
{
|
||||
int i = (int)gid;
|
||||
|
||||
if (i >= 0 && i < Count)
|
||||
{
|
||||
return groups[i].group;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////// ^ static ^ ///////////////////// v instance v /////////////////////
|
||||
|
||||
/// Public properties
|
||||
public GID Gid { get { return (GID)group.Gid; } }
|
||||
public string Name { get { return group.Name; } set { group.Name = value; } }
|
||||
|
||||
/// Private fields
|
||||
Entities.Group group;
|
||||
|
||||
/// <summary>
|
||||
/// Instance constructor.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public Grp(GID gid)
|
||||
{
|
||||
group = new Entities.Group();
|
||||
this.group.Gid = (int)gid;
|
||||
this.group.Name = gid.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class BenchPathMap : ClassMap<BenchPath>
|
||||
{
|
||||
public BenchPathMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.TempIn);
|
||||
Map(x => x.TempOut);
|
||||
Map(x => x.PressIn);
|
||||
Map(x => x.PressOut);
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
Map(x => x.ValvesClose)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class ComponentMap : ClassMap<Component>
|
||||
{
|
||||
public ComponentMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.ClassName);
|
||||
Map(x => x.ParentName);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Mode);
|
||||
Map(x => x.Logging);
|
||||
Map(x => x.Parameters)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
HasMany(x => x.Corrections)
|
||||
.OrderBy("Measurement")
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class ComponentProcedureMap : ClassMap<ComponentProcedure>
|
||||
{
|
||||
public ComponentProcedureMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.CmpntName);
|
||||
Map(x => x.Parameters)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
|
||||
References(x => x.Procedure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class ComponentTestMap : ClassMap<ComponentTest>
|
||||
{
|
||||
public ComponentTestMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.CmpntName);
|
||||
Map(x => x.Parameters)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
|
||||
References(x => x.Test);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class FeedingPathMap : ClassMap<FeedingPath>
|
||||
{
|
||||
public FeedingPathMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Pump);
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
Map(x => x.ValvesClose)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class GroupMap : ClassMap<Entities.Group>
|
||||
{
|
||||
public GroupMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Gid);
|
||||
Map(x => x.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class MeasurementCorrectionMap : ClassMap<MeasurementCorrection>
|
||||
{
|
||||
public MeasurementCorrectionMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Measurement);
|
||||
Map(x => x.Correction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class MeterTestResultMap : ClassMap<MeterTestResult>
|
||||
{
|
||||
public MeterTestResultMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
References(x => x.TestResult);
|
||||
Map(x => x.Disabled);
|
||||
Map(x => x.SerialNr);
|
||||
Map(x => x.EndState);
|
||||
Map(x => x.VolumeStart);
|
||||
Map(x => x.VolumeEnd);
|
||||
Map(x => x.VolumeMeter);
|
||||
Map(x => x.VolumeRef);
|
||||
Map(x => x.VolumeErrorPct);
|
||||
Map(x => x.PulsesMeter);
|
||||
Map(x => x.PulsesPerLiter);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.Time);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class MetersPathMap : ClassMap<MetersPath>
|
||||
{
|
||||
public MetersPathMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Sensor1);
|
||||
#pragma warning disable
|
||||
if (Config.Data.WMsCount >= 2) Map(x => x.Sensor2);
|
||||
if (Config.Data.WMsCount >= 3) Map(x => x.Sensor3);
|
||||
if (Config.Data.WMsCount >= 4) Map(x => x.Sensor4);
|
||||
if (Config.Data.WMsCount >= 5) Map(x => x.Sensor5);
|
||||
if (Config.Data.WMsCount >= 6) Map(x => x.Sensor6);
|
||||
if (Config.Data.WMsCount >= 7) Map(x => x.Sensor7);
|
||||
if (Config.Data.WMsCount >= 8) Map(x => x.Sensor8);
|
||||
if (Config.Data.WMsCount >= 9) Map(x => x.Sensor9);
|
||||
if (Config.Data.WMsCount >= 10) Map(x => x.Sensor10);
|
||||
if (Config.Data.WMsCount >= 11) Map(x => x.Sensor11);
|
||||
if (Config.Data.WMsCount >= 12) Map(x => x.Sensor12);
|
||||
if (Config.Data.WMsCount >= 13) Map(x => x.Sensor13);
|
||||
if (Config.Data.WMsCount >= 14) Map(x => x.Sensor14);
|
||||
if (Config.Data.WMsCount >= 15) Map(x => x.Sensor15);
|
||||
if (Config.Data.WMsCount >= 16) Map(x => x.Sensor16);
|
||||
if (Config.Data.WMsCount >= 17) Map(x => x.Sensor17);
|
||||
if (Config.Data.WMsCount >= 18) Map(x => x.Sensor18);
|
||||
if (Config.Data.WMsCount >= 19) Map(x => x.Sensor19);
|
||||
if (Config.Data.WMsCount >= 20) Map(x => x.Sensor20);
|
||||
#if IPERLST
|
||||
if (Config.Data.WMsCount >= 21) Map(x => x.Sensor21);
|
||||
if (Config.Data.WMsCount >= 22) Map(x => x.Sensor22);
|
||||
if (Config.Data.WMsCount >= 23) Map(x => x.Sensor23);
|
||||
if (Config.Data.WMsCount >= 24) Map(x => x.Sensor24);
|
||||
if (Config.Data.WMsCount >= 25) Map(x => x.Sensor25);
|
||||
if (Config.Data.WMsCount >= 26) Map(x => x.Sensor26);
|
||||
if (Config.Data.WMsCount >= 27) Map(x => x.Sensor27);
|
||||
if (Config.Data.WMsCount >= 28) Map(x => x.Sensor28);
|
||||
if (Config.Data.WMsCount >= 29) Map(x => x.Sensor29);
|
||||
if (Config.Data.WMsCount >= 30) Map(x => x.Sensor30);
|
||||
if (Config.Data.WMsCount >= 31) Map(x => x.Sensor31);
|
||||
if (Config.Data.WMsCount >= 32) Map(x => x.Sensor32);
|
||||
if (Config.Data.WMsCount >= 33) Map(x => x.Sensor33);
|
||||
if (Config.Data.WMsCount >= 34) Map(x => x.Sensor34);
|
||||
if (Config.Data.WMsCount >= 35) Map(x => x.Sensor35);
|
||||
if (Config.Data.WMsCount >= 36) Map(x => x.Sensor36);
|
||||
if (Config.Data.WMsCount >= 37) Map(x => x.Sensor37);
|
||||
if (Config.Data.WMsCount >= 38) Map(x => x.Sensor38);
|
||||
if (Config.Data.WMsCount >= 39) Map(x => x.Sensor39);
|
||||
if (Config.Data.WMsCount >= 40) Map(x => x.Sensor40);
|
||||
#endif
|
||||
#pragma warning restore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class OutputPathMap : ClassMap<OutputPath>
|
||||
{
|
||||
public OutputPathMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.RegulValve);
|
||||
Map(x => x.FlowMeter);
|
||||
Map(x => x.PidCoef);
|
||||
Map(x => x.StartValve);
|
||||
Map(x => x.Diverter);
|
||||
Map(x => x.TempDiv);
|
||||
Map(x => x.Balance);
|
||||
Map(x => x.EmptyTankValve);
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
Map(x => x.ValvesClose)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class ProcedureMap : ClassMap<Procedure>
|
||||
{
|
||||
public ProcedureMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
|
||||
Map(x => x.Description);
|
||||
Map(x => x.CreationUser);
|
||||
Map(x => x.CreationTime);
|
||||
Map(x => x.LastChgUser);
|
||||
Map(x => x.LastChgTime);
|
||||
Map(x => x.LongDescription);
|
||||
|
||||
Map(x => x.ProcedureState);
|
||||
Map(x => x.Revision);
|
||||
Map(x => x.PredecessorId);
|
||||
Map(x => x.ObtainedByCopy);
|
||||
|
||||
Map(x => x.MetersKind);
|
||||
Map(x => x.Watermeters);
|
||||
Map(x => x.ProtocolTitle);
|
||||
Map(x => x.DataEntry);
|
||||
Map(x => x.ResultsPrinter);
|
||||
Map(x => x.ResultsWriter);
|
||||
Map(x => x.TransitionStart);
|
||||
Map(x => x.TransitionEnd);
|
||||
////Map(x => x.MetrologicalClass);
|
||||
////HasOne(x => x.WMType);
|
||||
HasMany(x => x.MoreParams)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.Tests)
|
||||
.OrderBy("ItemNr")
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajik
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class TestMap : ClassMap<Test>
|
||||
{
|
||||
public TestMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Part);
|
||||
Map(x => x.Publish);
|
||||
Map(x => x.Evaluate);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Volume);
|
||||
Map(x => x.TstTime);
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.Emptying);
|
||||
Map(x => x.Zeroing);
|
||||
Map(x => x.PumpPower);
|
||||
Map(x => x.MassRepeats);
|
||||
Map(x => x.MassSpread);
|
||||
Map(x => x.MassMethod);
|
||||
Map(x => x.TimeBeforeFlow);
|
||||
Map(x => x.TimeFlow2Mass);
|
||||
Map(x => x.TimePump2StartV)
|
||||
.Column("TimeMass2Start");
|
||||
Map(x => x.TimeStop2Mass);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
Map(x => x.TolerRed)
|
||||
.Column("TolerRed"); /// ???
|
||||
Map(x => x.RedType); /// ???
|
||||
Map(x => x.FeedingPath);
|
||||
Map(x => x.BenchPath);
|
||||
Map(x => x.OutputPath);
|
||||
Map(x => x.MetersPath);
|
||||
#if HEAT_METERS_SUPPORT
|
||||
Map(x => x.HeatMetersPath);
|
||||
#endif
|
||||
Map(x => x.RelTransBefore);
|
||||
Map(x => x.RelTransBetween);
|
||||
Map(x => x.RelTransAfter);
|
||||
Map(x => x.TransitionAfter);
|
||||
HasMany(x => x.MoreParams)
|
||||
.Cascade.All();
|
||||
References(x => x.Procedure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class TestResultMap : ClassMap<TestResult>
|
||||
{
|
||||
public TestResultMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.BatchNr);
|
||||
Map(x => x.PurchaseOrder);
|
||||
Map(x => x.MetersKind);
|
||||
HasMany(x => x.Meters)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.CombinedMeters)
|
||||
.Cascade.All();
|
||||
|
||||
Map(x => x.ProcedureName);
|
||||
Map(x => x.ProtocolTitle);
|
||||
|
||||
Map(x => x.TestId);
|
||||
Map(x => x.TestName);
|
||||
Map(x => x.Part);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.Volume);
|
||||
Map(x => x.TstTime);
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.Emptying);
|
||||
Map(x => x.Zeroing);
|
||||
Map(x => x.PumpPower);
|
||||
Map(x => x.Time2MassMsrmt);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
|
||||
Map(x => x.FeedingPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.BenchPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.OutputPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
Map(x => x.MetersPath)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(4000)");
|
||||
|
||||
Map(x => x.TimeStart);
|
||||
Map(x => x.TimeEnd);
|
||||
Map(x => x.RepetitionNr);
|
||||
Map(x => x.AmbientTempAve);
|
||||
Map(x => x.AmbientPressAve);
|
||||
Map(x => x.AmbientHumiAve);
|
||||
Map(x => x.PressInAvrg);
|
||||
Map(x => x.PressInStart);
|
||||
Map(x => x.PressInEnd);
|
||||
Map(x => x.PressOutAvrg);
|
||||
Map(x => x.PressOutStart);
|
||||
Map(x => x.PressOutEnd);
|
||||
Map(x => x.TempInAvrg);
|
||||
Map(x => x.TempInStart);
|
||||
Map(x => x.TempInEnd);
|
||||
Map(x => x.TempOutAvrg);
|
||||
Map(x => x.TempOutStart);
|
||||
Map(x => x.TempOutEnd);
|
||||
Map(x => x.TempDivAvrg);
|
||||
Map(x => x.TempDivStart);
|
||||
Map(x => x.TempDivEnd);
|
||||
Map(x => x.MassStartRaw);
|
||||
Map(x => x.MassStart);
|
||||
Map(x => x.MassEndRaw);
|
||||
Map(x => x.MassEnd);
|
||||
Map(x => x.MassDiff);
|
||||
Map(x => x.DensityIn);
|
||||
Map(x => x.DensityOut);
|
||||
Map(x => x.DensityDiv);
|
||||
Map(x => x.FlowMass); /// from conventional true value
|
||||
Map(x => x.FlowVolume); /// from conventional true value
|
||||
Map(x => x.VolumeCTV); /// volume conventional true value
|
||||
Map(x => x.VolumeMaster); /// volume from the master flow meter
|
||||
Map(x => x.Time); /// measurement time in seconds
|
||||
Map(x => x.ErrorMaster);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.ConstMaster); /// Pulses per liter master flow meter
|
||||
Map(x => x.QRise);
|
||||
Map(x => x.QFall);
|
||||
Map(x => x.TimeDivStart0);
|
||||
Map(x => x.TimeDivStart1);
|
||||
Map(x => x.TimeDivStart2);
|
||||
Map(x => x.TimeDivStart3);
|
||||
Map(x => x.TimeDivStart4);
|
||||
Map(x => x.TimeDivStart5);
|
||||
Map(x => x.TimeDivEnd0);
|
||||
Map(x => x.TimeDivEnd1);
|
||||
Map(x => x.TimeDivEnd2);
|
||||
Map(x => x.TimeDivEnd3);
|
||||
Map(x => x.TimeDivEnd4);
|
||||
Map(x => x.TimeDivEnd5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class TransitionSequenceMap : ClassMap<TransitionSequence>
|
||||
{
|
||||
public TransitionSequenceMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Description);
|
||||
HasMany(x => x.TransitionSteps)
|
||||
.OrderBy("ItemNr")
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class TransitionStepMap : ClassMap<TransitionStep>
|
||||
{
|
||||
public TransitionStepMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Duration);
|
||||
Map(x => x.Message);
|
||||
Map(x => x.EndCondition);
|
||||
Map(x => x.ValvesOpen)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
Map(x => x.ValvesClose)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(8000)");
|
||||
Map(x => x.RegulValvesPct);
|
||||
Map(x => x.PumpWithFMPcts);
|
||||
|
||||
References(x => x.TransitionSequence);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class UserMap : ClassMap<Entities.User>
|
||||
{
|
||||
public UserMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Password);
|
||||
Map(x => x.Description);
|
||||
Map(x => x.LastPwChange);
|
||||
HasMany(x => x.Groups)
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class VirtualBenchSequenceMap : ClassMap<VirtualBenchSequence>
|
||||
{
|
||||
public VirtualBenchSequenceMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Description);
|
||||
HasMany(x => x.VirtualBenchSteps)
|
||||
.OrderBy("ItemNr")
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class VirtualBenchStepMap : ClassMap<VirtualBenchStep>
|
||||
{
|
||||
public VirtualBenchStepMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ItemNr);
|
||||
Map(x => x.Duration);
|
||||
|
||||
References(x => x.VirtualBenchSequence);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class WMTypeMap : ClassMap<Entities.WMType>
|
||||
{
|
||||
public WMTypeMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.CreateTime);
|
||||
Map(x => x.CreateUserName);
|
||||
Map(x => x.CreateDescription);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.PulseRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
|
||||
namespace Config.Mappings
|
||||
{
|
||||
class WatermeterMap : ClassMap<Entities.Watermeter>
|
||||
{
|
||||
public WatermeterMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Serial);
|
||||
// HasOne(x => x.WMType)
|
||||
// .Cascade.All();
|
||||
References(x => x.WMType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("Config")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Sensus")]
|
||||
[assembly: AssemblyProduct("Config")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013 - 2016 Sensus Slovensko a.s.")]
|
||||
[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("3fc3ff67-7386-4aff-9855-bef33d5fa0d3")]
|
||||
|
||||
// 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("2.9.329.0")]
|
||||
[assembly: AssemblyFileVersion("2.9.329.0")]
|
||||
Generated
+3168
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,241 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Config.Entities;
|
||||
using Config.Resources;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
public class ResultItemSpec
|
||||
{
|
||||
///
|
||||
/// Public fields
|
||||
///
|
||||
public readonly string Name; /// Name-s of all items must be unique
|
||||
public readonly string ClmnHeaderText; /// Text printed in the column header
|
||||
|
||||
|
||||
///
|
||||
/// Function to pick a MeterTestResult field and convert it into a string
|
||||
///
|
||||
public delegate string PrintDlgt(MeterTestResult meterTestResult);
|
||||
|
||||
private readonly PrintDlgt printDlgt;
|
||||
|
||||
public bool CanPrintSingle { get { return (printDlgt != null); } }
|
||||
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string Print(MeterTestResult meterTestResult)
|
||||
{
|
||||
string str = printDlgt(meterTestResult);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Function to pick a MeterTestResult field and convert it into a string
|
||||
///
|
||||
public delegate string PrintCombinedDlgt(MeterTestResult largeMeterTestResult,
|
||||
MeterTestResult smallMeterTestResult,
|
||||
MeterTestResult combinedMeterTestResult);
|
||||
private readonly PrintCombinedDlgt printCombinedDlgt;
|
||||
|
||||
public bool CanPrintCombined { get { return (printCombinedDlgt != null); } }
|
||||
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string PrintCombined(MeterTestResult largeMeterTestResult,
|
||||
MeterTestResult smallMeterTestResult,
|
||||
MeterTestResult combinedMeterTestResult)
|
||||
{
|
||||
string str = printCombinedDlgt(largeMeterTestResult, smallMeterTestResult, combinedMeterTestResult);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Public constructor
|
||||
///
|
||||
public ResultItemSpec(string name, string clmnHeaderText, PrintDlgt printDlgt, PrintCombinedDlgt printCombinedDlgt)
|
||||
{
|
||||
Name = name;
|
||||
ClmnHeaderText = clmnHeaderText;
|
||||
this.printDlgt = printDlgt;
|
||||
this.printCombinedDlgt = printCombinedDlgt;
|
||||
}
|
||||
|
||||
|
||||
/// Static list of all available items
|
||||
public static readonly IList<ResultItemSpec> AllItems;
|
||||
|
||||
/// Static constructor that initializes the list of all items
|
||||
static ResultItemSpec()
|
||||
{
|
||||
AllItems = new List<ResultItemSpec>();
|
||||
|
||||
/// Common
|
||||
|
||||
//AllItems.Add(new ResultItemSpec("Bench ID", "Bench ID", x => x.TestResult.BenchID,
|
||||
// (x, y, z) => x.TestResult.BenchID));
|
||||
AllItems.Add(new ResultItemSpec("Test name", "Test", x => x.TestResult.TestName,
|
||||
(x, y, z) => x.TestResult.TestName));
|
||||
AllItems.Add(new ResultItemSpec("Procedure name", "Procedure", x => x.TestResult.ProcedureName,
|
||||
(x, y, z) => x.TestResult.ProcedureName));
|
||||
AllItems.Add(new ResultItemSpec("Batch number", "Batch nr.", x => x.TestResult.BatchNr.ToString(),
|
||||
(x, y, z) => x.TestResult.BatchNr.ToString()));
|
||||
AllItems.Add(new ResultItemSpec("Test method", "Test method", x => x.TestResult.Method,
|
||||
(x, y, z) => x.TestResult.Method));
|
||||
AllItems.Add(new ResultItemSpec("Density", "Density", x => x.TestResult.DensityOut.ToString("F1"),
|
||||
(x, y, z) => x.TestResult.DensityOut.ToString("F1"))); /// [kg/m3]
|
||||
|
||||
/// Target values
|
||||
AllItems.Add(new ResultItemSpec("Q from", "Q from [l/h]", x => x.TestResult.Qfrom.ToString("F3"),
|
||||
(x, y, z) => x.TestResult.Qfrom.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Q to", "Q to [l/h]", x => x.TestResult.Qto.ToString("F3"),
|
||||
(x, y, z) => x.TestResult.Qto.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Test volume", "Test vol. [l]", x => x.TestResult.Volume.ToString("F1"),
|
||||
(x, y, z) => x.TestResult.Volume.ToString("F1")));
|
||||
AllItems.Add(new ResultItemSpec("Error limit Lo", "Err.Lim.Lo [%]", x => x.TestResult.ErrLimLo.ToString("F1"),
|
||||
(x, y, z) => x.TestResult.ErrLimLo.ToString("F1")));
|
||||
AllItems.Add(new ResultItemSpec("Error limit Hi", "Err.Lim.Hi [%]", x => x.TestResult.ErrLimHi.ToString("F1"),
|
||||
(x, y, z) => x.TestResult.ErrLimHi.ToString("F1")));
|
||||
AllItems.Add(new ResultItemSpec("Error limit sum", "Err.Lim.Sum [%]", x => (x.TestResult.ErrLimHi - x.TestResult.ErrLimLo).ToString("F1"),
|
||||
(x, y, z) => (x.TestResult.ErrLimHi - x.TestResult.ErrLimLo).ToString("F1")));
|
||||
AllItems.Add(new ResultItemSpec("Uncertainty", "Uncertainty [%]", x => x.TestResult.Uncertainty.ToString("F2"),
|
||||
(x, y, z) => x.TestResult.Uncertainty.ToString("F2")));
|
||||
|
||||
/// Test results
|
||||
AllItems.Add(new ResultItemSpec("Start time", "T start", x => x.TestResult.TimeStart.ToShortTimeString(),
|
||||
(x, y, z) => z.TestResult.TimeStart.ToShortTimeString()));
|
||||
AllItems.Add(new ResultItemSpec("End time", "T end", x => x.TestResult.TimeEnd.ToShortTimeString(),
|
||||
(x, y, z) => z.TestResult.TimeEnd.ToShortTimeString()));
|
||||
AllItems.Add(new ResultItemSpec("Test time", "T [s]", x => x.TestResult.Time.ToString("F2"),
|
||||
(x, y, z) => z.TestResult.Time.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("Flow", "Flow [m3/h]", x => FloatToStr(x.TestResult.FlowVolume / 1000.0f, 4),
|
||||
(x, y, z) => FloatToStr(z.TestResult.FlowVolume / 1000.0f, 4)));
|
||||
AllItems.Add(new ResultItemSpec("T in", "T in", x => x.TestResult.TempInAvrg.ToString("F2"),
|
||||
(x, y, z) => z.TestResult.TempInAvrg.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("T out", "T out", x => x.TestResult.TempOutAvrg.ToString("F2"),
|
||||
(x, y, z) => z.TestResult.TempOutAvrg.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("T div", "T div", x => x.TestResult.TempDivAvrg.ToString("F2"),
|
||||
(x, y, z) => z.TestResult.TempDivAvrg.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("P up", "P up", x => x.TestResult.PressInAvrg.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressInAvrg.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("P up start", "P up start", x => x.TestResult.PressInStart.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressInStart.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("P up end", "P up end", x => x.TestResult.PressInEnd.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressInEnd.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("P down", "P down", x => x.TestResult.PressOutAvrg.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressOutAvrg.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("P down start", "P down start", x => x.TestResult.PressOutStart.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressOutStart.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("P down end", "P down end", x => x.TestResult.PressOutEnd.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.PressOutEnd.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Reference error", "Err.ref. [%]", x => x.TestResult.ErrorMaster.ToString("F3"),
|
||||
(x, y, z) => z.TestResult.ErrorMaster.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Ambient temperature", "T amb", x => x.TestResult.AmbientTempAve.ToString("F1"),
|
||||
(x, y, z) => z.TestResult.AmbientTempAve.ToString("F1")));
|
||||
AllItems.Add(new ResultItemSpec("Ambient pressure", "P amb", x => x.TestResult.AmbientPressAve.ToString("F0"),
|
||||
(x, y, z) => z.TestResult.AmbientPressAve.ToString("F0")));
|
||||
AllItems.Add(new ResultItemSpec("Ambient humidity", "H amb [%]", x => x.TestResult.AmbientHumiAve.ToString("F1"),
|
||||
(x, y, z) => z.TestResult.AmbientHumiAve.ToString("F1")));
|
||||
|
||||
/// Single and combined meter results
|
||||
AllItems.Add(new ResultItemSpec("Volume", "Volume [l]", x => x.VolumeMeter.ToString("F3"),
|
||||
(x, y, z) => z.VolumeMeter.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Reference volume", "Vol.ref. [l]", x => x.VolumeRef.ToString("F3"),
|
||||
(x, y, z) => z.VolumeRef.ToString("F3")));
|
||||
AllItems.Add(new ResultItemSpec("Error", "Error [%]", x => x.VolumeErrorPct.ToString("F2"),
|
||||
(x, y, z) => z.VolumeErrorPct.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("Passed", "Result", x => (x.Passed ? Strings.Passed + "|Green" : Strings.Failed + "|Red"),
|
||||
(x, y, z) => (z.Passed ? Strings.Passed + "|Green" : Strings.Failed + "|Red")));
|
||||
|
||||
/// Single water meters only results
|
||||
AllItems.Add(new ResultItemSpec("Serial Nr", "s/n", x => x.SerialNr, null));
|
||||
AllItems.Add(new ResultItemSpec("End state", "End state", x => x.EndState, null));
|
||||
AllItems.Add(new ResultItemSpec("Pulses", "Pulses", x => x.PulsesMeter.ToString(), null));
|
||||
AllItems.Add(new ResultItemSpec("Pulses/liter", "Pulses/liter", x => x.PulsesPerLiter.ToString(), null));
|
||||
AllItems.Add(new ResultItemSpec("Reference pulses", "Ref.pulses", x => x.PulsesMaster.ToString(), null));
|
||||
|
||||
/// Combined water meters only results
|
||||
AllItems.Add(new ResultItemSpec("Q rise", "Q rise [m3/h]", null, (x, y, z) => (x.TestResult.QRise == 0) ? "-" : FloatToStr(x.TestResult.QRise, 4)));
|
||||
AllItems.Add(new ResultItemSpec("Q fall", "Q fall [m3/h]", null, (x, y, z) => (x.TestResult.QFall == 0) ? "-" : FloatToStr(x.TestResult.QFall, 4)));
|
||||
AllItems.Add(new ResultItemSpec("Error large WM", "Error-L [%]", null, (x, y, z) => x.VolumeErrorPct.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("Error small WM", "Error-S [%]", null, (x, y, z) => y.VolumeErrorPct.ToString("F2")));
|
||||
AllItems.Add(new ResultItemSpec("Serial Nr large WM", "s/n", null, (x, y, z) => x.SerialNr));
|
||||
AllItems.Add(new ResultItemSpec("Serial Nr small WM", "s/n", null, (x, y, z) => y.SerialNr));
|
||||
AllItems.Add(new ResultItemSpec("End state large WM", "End state", null, (x, y, z) => x.EndState));
|
||||
AllItems.Add(new ResultItemSpec("End state small WM", "End state", null, (x, y, z) => y.EndState));
|
||||
}
|
||||
|
||||
public static ResultItemSpec GetItem(string name)
|
||||
{
|
||||
foreach (var item in AllItems) if (item.Name.Equals(name)) return item;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string[] ToStrArray(IList<ResultItemSpec> items)
|
||||
{
|
||||
int count = (items != null) ? items.Count : 0;
|
||||
string[] result = new string[count];
|
||||
for (int i = 0; i < count; i++) result[i] = items[i].Name;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IList<ResultItemSpec> FromStrArray(string[] strArray)
|
||||
{
|
||||
IList<ResultItemSpec> result = new List<ResultItemSpec>();
|
||||
if (strArray != null)
|
||||
{
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
ResultItemSpec item = GetItem(strArray[i]);
|
||||
if (item != null) result.Add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts float number to a string with the specified number of valid digits
|
||||
/// </summary>
|
||||
/// <param name="value">Float value to be converted to a string</param>
|
||||
/// <param name="validDigits">Number of valid digits: 4, 3, or 2 (otherwise a full precision number is printed)</param>
|
||||
/// <returns>String representation of the float number</returns>
|
||||
public static string FloatToStr(float value, int validDigits)
|
||||
{
|
||||
if (validDigits == 4)
|
||||
{
|
||||
if (value >= 999.5 || value < -999.5) return value.ToString("F0");
|
||||
else if (value >= 99.95 || value < -99.95) return value.ToString("F1");
|
||||
else if (value >= 9.995 || value < -9.995) return value.ToString("F2");
|
||||
else if (value >= 0.9995 || value < -0.9995) return value.ToString("F3");
|
||||
else if (value >= 0.09995 || value < -0.09995) return value.ToString("F4");
|
||||
else if (value >= 0.009995 || value < -0.009995) return value.ToString("F5");
|
||||
else return value.ToString("F6");
|
||||
}
|
||||
else if (validDigits == 3)
|
||||
{
|
||||
if (value >= 99.5 || value < -99.5) return value.ToString("F0");
|
||||
else if (value >= 9.95 || value < -9.95) return value.ToString("F1");
|
||||
else if (value >= 0.995 || value < -0.995) return value.ToString("F2");
|
||||
else if (value >= 0.0995 || value < -0.0995) return value.ToString("F3");
|
||||
else if (value >= 0.00995 || value < -0.00995) return value.ToString("F4");
|
||||
else if (value >= 0.000995 || value < -0.000995) return value.ToString("F5");
|
||||
else return value.ToString("F6");
|
||||
}
|
||||
else if (validDigits == 2)
|
||||
{
|
||||
if (value >= 9.5 || value < -9.5) return value.ToString("F0");
|
||||
else if (value >= 0.95 || value < -0.95) return value.ToString("F1");
|
||||
else if (value >= 0.095 || value < -0.095) return value.ToString("F2");
|
||||
else if (value >= 0.0095 || value < -0.0095) return value.ToString("F3");
|
||||
else if (value >= 0.00095 || value < -0.00095) return value.ToString("F4");
|
||||
else return value.ToString("F5");
|
||||
}
|
||||
else return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,525 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>8</zoom_level>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>0</y>
|
||||
<w>40</w>
|
||||
<h>64</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;48;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.InitialState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>8</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes>i</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>48</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>'Test Start' transition sequence</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>56</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.RegionEndState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>96</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>88</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<y>128</y>
|
||||
<w>160</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Initialize (single) test results</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>136</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Decision</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>176</y>
|
||||
<w>32</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>184</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Decision</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>224</y>
|
||||
<w>32</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.RegionEndState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>272</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>232</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>264</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<y>304</y>
|
||||
<w>160</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Make the water tank empty</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>312</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.RegionEndState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>352</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>344</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>272</x>
|
||||
<y>168</y>
|
||||
<w>160</w>
|
||||
<h>128</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
m2=[Emptying always]</panel_attributes>
|
||||
<additional_attributes>144;112;24;112;24;24;136;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>216</y>
|
||||
<w>176</w>
|
||||
<h>160</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
m2=[Enough room in tank]</panel_attributes>
|
||||
<additional_attributes>24;144;160;144;160;24;32;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<y>384</y>
|
||||
<w>160</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Set the required water flow</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>392</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>432</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Measure the 'start' mass of water</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>440</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<y>480</y>
|
||||
<w>160</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Start the test (diverter, etc.)</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>488</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.RegionEndState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>528</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>344</x>
|
||||
<y>560</y>
|
||||
<w>160</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Read intermediate results</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>520</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>568</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Decision</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>608</y>
|
||||
<w>32</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>272</x>
|
||||
<y>512</y>
|
||||
<w>160</w>
|
||||
<h>128</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
m2=[Test in progress]</panel_attributes>
|
||||
<additional_attributes>144;24;24;24;24;112;136;112</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>616</y>
|
||||
<w>40</w>
|
||||
<h>64</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;48;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Text</type>
|
||||
<coordinates>
|
||||
<x>424</x>
|
||||
<y>640</y>
|
||||
<w>104</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>[Test completed]</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>664</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Measure the 'end' mass of water</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>712</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Calculate and save this test results</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>672</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>720</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Decision</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>760</y>
|
||||
<w>32</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>768</y>
|
||||
<w>40</w>
|
||||
<h>64</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;48;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>408</x>
|
||||
<y>80</y>
|
||||
<w>216</w>
|
||||
<h>712</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-
|
||||
m2=[More repetitions to be done]</panel_attributes>
|
||||
<additional_attributes>24;24;200;24;200;696;32;696</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Text</type>
|
||||
<coordinates>
|
||||
<x>264</x>
|
||||
<y>792</y>
|
||||
<w>160</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>[All test repetitions completed]</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>816</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Stop any running tests, etc. (?)</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>328</x>
|
||||
<y>864</y>
|
||||
<w>192</w>
|
||||
<h>32</h>
|
||||
</coordinates>
|
||||
<panel_attributes>'Test End' transition sequence</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>824</y>
|
||||
<w>40</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;40;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>872</y>
|
||||
<w>40</w>
|
||||
<h>64</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>24;48;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.FinalState</type>
|
||||
<coordinates>
|
||||
<x>416</x>
|
||||
<y>920</y>
|
||||
<w>16</w>
|
||||
<h>16</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>10</zoom_level>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>120</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Load the default
|
||||
procedure
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>40</y>
|
||||
<w>50</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;80;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.InitialState</type>
|
||||
<coordinates>
|
||||
<x>450</x>
|
||||
<y>60</y>
|
||||
<w>20</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>i</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>190</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Reset valves,
|
||||
pumps, etc.
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>130</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;60;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>260</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Detect cameras</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>200</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;60;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>370</x>
|
||||
<y>550</y>
|
||||
<w>180</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
<panel_attributes>complex
|
||||
state
|
||||
--
|
||||
some more...
|
||||
|
||||
|
||||
-.</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>370</x>
|
||||
<y>390</y>
|
||||
<w>180</w>
|
||||
<h>60</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Display prompt, enable
|
||||
'Cycle' and 'Test' buttons
|
||||
and wait for a selection</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>320</y>
|
||||
<w>50</w>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;70;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.RegionEndState</type>
|
||||
<coordinates>
|
||||
<x>450</x>
|
||||
<y>330</y>
|
||||
<w>20</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>270</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;60;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Decision</type>
|
||||
<coordinates>
|
||||
<x>440</x>
|
||||
<y>480</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes/>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>420</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;60;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>430</x>
|
||||
<y>490</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;60;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>620</x>
|
||||
<y>430</y>
|
||||
<w>160</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Disable 'Cycle'
|
||||
and 'Test' buttons</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.State</type>
|
||||
<coordinates>
|
||||
<x>620</x>
|
||||
<y>360</y>
|
||||
<w>160</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Empty the tank</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>450</x>
|
||||
<y>440</y>
|
||||
<w>270</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>250;30;250;60;30;60</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>670</x>
|
||||
<y>370</y>
|
||||
<w>50</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;30;30;60</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>440</x>
|
||||
<y>310</y>
|
||||
<w>280</w>
|
||||
<h>70</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>30;30;260;30;260;50</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Text</type>
|
||||
<coordinates>
|
||||
<x>490</x>
|
||||
<y>480</y>
|
||||
<w>180</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>'Empty a tank' selected
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.custom.Text</type>
|
||||
<coordinates>
|
||||
<x>290</x>
|
||||
<y>520</y>
|
||||
<w>160</w>
|
||||
<h>20</h>
|
||||
</coordinates>
|
||||
<panel_attributes>'Cycle' or 'Test' selected
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
Binary file not shown.
@@ -0,0 +1,73 @@
|
||||
Otazky:
|
||||
-------
|
||||
- ako pouzit T6
|
||||
- co je 'T to Open' pri RV
|
||||
- na co sluzia VI2P, VI3P a VI4P
|
||||
|
||||
|
||||
TODO:
|
||||
-----
|
||||
- nefunguje pumpa P3
|
||||
- nahlad na cestu v procedure
|
||||
- purgeStart a purgeEnd --> transitionSteps/Sequences
|
||||
- horeuvedene pre RegulValve
|
||||
- volba procedury nie je zablokovana pocas testov
|
||||
- vsetky Target... v Process tabe
|
||||
- Hmotnosti:
|
||||
1 netarovat, merat okamzitu,
|
||||
2 nulovacia procedura na tlacitko manualne,
|
||||
3 pri starte sa spytat ci vynulovat vahy
|
||||
- Preco sa nenacitaju zmeny v Test-e ???
|
||||
|
||||
|
||||
- pouzit oneskorenie na ventily
|
||||
- skontrolovat doc (freq v Hz)
|
||||
|
||||
Demo version:
|
||||
|
||||
- pouzit progress bary na vyber testu
|
||||
- vycistit Measurement
|
||||
- simulacia skonci pri druhom 'start_measurement'
|
||||
- pri simulacii sa meni mass pri merani end-mass (klapka by mala byt vypnuta!)
|
||||
|
||||
- otvorit Proceduru (v dalsom okne v zamknutom stave) aj ked je okno Procedures zamknute
|
||||
- pridat seriove cisla do parametrov komponentov
|
||||
- zapamatavat si sirky stlpcov v PathsDlg, ... (aj inde)
|
||||
- skontroluj vsetky ListViewEx-y + skorsie spracovanie vysledkov (dolezite aj pre spravnu tvorbu noveho mena)
|
||||
- preco posledne okno skace
|
||||
- chyba spracovanie procedure / metrology2 Tol.Abzug, Fehl.Korr -+
|
||||
- vsetky mena stlpcov a tabov do Strings.xxx
|
||||
|
||||
Testovanie na stanici:
|
||||
|
||||
- pouzivat skutocne 'rvalves'
|
||||
- ked vyberiem priamo Q1, Q2, Q3 (poskonceni predchadzajuceho testu), neprepise sa obsah combo boxu
|
||||
- prislusne EtPulses by mali ist cez RegisterReader komponent + common RegisterReader pre Master
|
||||
- ako je to s WM0 ...
|
||||
- na zaciatku zmerat vahu a dovolit vypustit tanky
|
||||
- updatovat vahu - obrazok = je nespravna kapacita vahy
|
||||
- spracovanie vysledkov podla excelu: corr. na hustotu vzduchu (zavazie), corr. na hustotu vody v zav. od teploty
|
||||
- podpora pre zbieranie vysledkov
|
||||
- logovanie vysledkov do excelu
|
||||
- zastavit vodu na konci skusky
|
||||
- Pri nastavovani prietoku nie je nic vidno
|
||||
- pouzivat skutocne 'rvalves'
|
||||
- pri vytvarani testov vyberat cesty podla prietoku
|
||||
- ked sa zada cesta napisanim mena = skontrolovat
|
||||
- zapamatat si stav ventilu pri prietoku
|
||||
- nulovanie = nulovanie vahy
|
||||
- zmenit text: tarovanie -> vypustanie
|
||||
|
||||
- pripravit IDC100: !ReadRegisterOp, Idc100.GetValue-SetValue (na konci), GetState a ukoncenie operacie
|
||||
- sub-sekvencie pre Q-set a metody
|
||||
- zobrazit typizovanu schemu
|
||||
|
||||
Neskor:
|
||||
|
||||
- nevidno ci su neulozene zmeny
|
||||
- upozornenie pri cancel ak su neulozene zmeny
|
||||
- spravne updatovat tlacitka ked su FixedItems (FixedRows)
|
||||
- ked odomknem Komponenty tak sa zrusi vyber
|
||||
- vaha ToString - prve zobrazit capacity
|
||||
- moznost menenia poradia aj v components
|
||||
- rozdelit ventily podla ciest?
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
@@ -0,0 +1,91 @@
|
||||
Assumption
|
||||
----------
|
||||
The installation consists of one or more similar test benches. Each test bench is controlled by one PC-based computer. In addition, one or more PC-s can run the same application and manipulated data shared by the test benches (e.g. PC located in offices). All PC-s run the same version of software (this is a must now - Munich - in the future we can try to deal with backward/forward compatibility issues).
|
||||
|
||||
Development environment
|
||||
-----------------------
|
||||
- Visual Studio 2012 Professional
|
||||
- Database: MySQL (???)
|
||||
|
||||
User iterface
|
||||
-------------
|
||||
- WindowsFormsApplication
|
||||
- Main part of the window occupies a tab control with hidden tabs
|
||||
(see http://weblogs.asp.net/kdente/archive/2005/11/14/430591.aspx)
|
||||
Tabs swithing is done programatically
|
||||
|
||||
Tabs:
|
||||
|
||||
Procedure
|
||||
- Procedure Info (summary, header)
|
||||
- Procedure History (changes)
|
||||
- Procedure Metrology
|
||||
- Procedure Technical
|
||||
- Procedure Purge
|
||||
- Procedure End
|
||||
- Procedure Adjustment
|
||||
- Procedure View
|
||||
- Procedure Inputs
|
||||
Home
|
||||
Insert
|
||||
Results
|
||||
- Results
|
||||
- Results D
|
||||
- Meters Ch
|
||||
- Temp Ch
|
||||
- Pressure
|
||||
Bench parameters
|
||||
- Technical
|
||||
- Balance
|
||||
- Temperature
|
||||
- Pressure
|
||||
- Flowmeter
|
||||
- Density
|
||||
Logs
|
||||
|
||||
|
||||
|
||||
Sensus Testbench Framework application settings consist of
|
||||
----------------------------------------------------------
|
||||
S1. Local settings stored on each PC
|
||||
S1.1 language settings, appearance, etc. (no other impact on the system function)
|
||||
S1.2 specification of databases used to store other settings (see 2.)
|
||||
There might be several sets of DB settings (1.2) when one should be able to access more test benches. When starting the system, this is indicated on the login screen as 'Test bench'/'Pruefstation'.
|
||||
|
||||
S2. Settings stored in databases:
|
||||
S2.1 'users' (typically shared between all benches - centralized access control)
|
||||
S2.2 'watermeter_types' info (typically shared between more benches)
|
||||
S2.3 'test_procedures' (typically shared between more identical benches)
|
||||
S2.4 'metrological_parameters' of the system (always unique for each system, not shared)
|
||||
S2.5 'watermeters' info (typically centralized / shared)
|
||||
S2.6 'test_results' (typically centralized / shared)
|
||||
etc.
|
||||
The databases might be running either on the local PC or remote,
|
||||
each database might be used by a single bench, or shared by more test benches. This configured in 1.2.
|
||||
|
||||
Application can be used to:
|
||||
---------------------------
|
||||
A1. Change local settings (S1.1, S1.2)
|
||||
A2. Change settings stored in the databases
|
||||
A3. Control system and run test procedures - this is only possible on PC-s controlling the benches. When procedure is started, local copy of necessary information from the DB-s is made to avoid problems.
|
||||
|
||||
User access control:
|
||||
--------------------
|
||||
U1. Access to
|
||||
U1.1 information read
|
||||
U1.2 information write/modify
|
||||
U1.3 action start
|
||||
is controlled by an access control mechanism.
|
||||
U2. Users
|
||||
U3. Groups
|
||||
Each user is a member of one or more groups. In case needed, a group with a single user is created. Access to information/actions is granted to groups.
|
||||
Muenich: Grooups are 'Tester',
|
||||
'Testing specialist',
|
||||
'Head of lab'
|
||||
'Maintenance specialist'
|
||||
'Metrologist'
|
||||
'Calibration specialist'
|
||||
U4. When necessary, system prompts user to authenticate himself/herself (login dialog). Authentication is invalidated as follows (optional):
|
||||
U4.1 When user closes the dialog, which was protected.
|
||||
U4.2 After certain time period
|
||||
U4.3 Never
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name="A1" type="log4net.Appender.ConsoleAppender">
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="A1" />
|
||||
</root>
|
||||
|
||||
<!-- Print only messages of level WARN or above in the package NHibernate -->
|
||||
<logger name="NHibernate">
|
||||
<level value="WARN" />
|
||||
</logger>
|
||||
<logger name="TestBenchFramework.BenchControl.StateMachine">
|
||||
<level value="WARN" />
|
||||
</logger>
|
||||
|
||||
</log4net>
|
||||
@@ -0,0 +1,27 @@
|
||||
foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in StateMachine.Worker()
|
||||
State.Create(...).AddOperation(...).AddOperation(...).EnterState() . . in the sequence in Execute(...)
|
||||
|
||||
foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps()
|
||||
WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps()
|
||||
foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps()
|
||||
IList<Event> events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps()
|
||||
|
||||
foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps()
|
||||
WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps()
|
||||
foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps()
|
||||
IList<Event> events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps()
|
||||
|
||||
State.Create(...).AddOperation(...).AddOperation(...).EnterState() . . in the sequence in Execute(...)
|
||||
|
||||
foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps()
|
||||
WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps()
|
||||
foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps()
|
||||
IList<Event> events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps()
|
||||
|
||||
foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps()
|
||||
WaitNextTick() (assume QuitStateMachineException thrown) . . . . . . in WaitRunDevsRunOps()
|
||||
foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in StateMachine.Worker() catch()
|
||||
State.RunOperations(); . . . . . . . . . . . . . . . . . . . . . . . . in StateMachine.Worker() catch()
|
||||
State.Empty.EnterState(); . . . . . . . . . . . . . . . . . . . . . . in StateMachine.Worker() catch()
|
||||
foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in StateMachine.Worker() catch()
|
||||
foreach (var device in devices) device.StopDevice(); . . . . . . . . . in StateMachine.Worker() catch()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,11 @@
|
||||
Showing tabs in the designer:
|
||||
- select mainTabControl
|
||||
- in Properies change SizeMode to normal
|
||||
- in Properies change ItemSize to 0; 20
|
||||
|
||||
Hiding tabs in the designer:
|
||||
- select mainTabControl
|
||||
- in Properies change SizeMode to Fixed
|
||||
- in Poperties change ItemSize to 0; 1
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
af242843887f3bdcc52e485483356eaccd37ba67a35941530bd195a8310fc7d5aca8560576dfb62ad5a4bd2df789a5e8be068e62e7c976d6eeed8d63abbd9909
|
||||
|
||||
|
||||
= staratura
|
||||
@@ -1,249 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.IO.Ports;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public class CR95HF_Reader
|
||||
{
|
||||
|
||||
private readonly byte [] CR95HF_CMD_ECHO = { 0x55 };
|
||||
private readonly byte[] CR95HF_CMD_IDN = { 0x01, 0x00 }; //CommandCode(0x01), Length(0x00)
|
||||
private readonly byte[] CR95HF_CMD_PROTOCOL_SELECT_ON = { 0x02, 0x02, 0x01, 0x0D }; //CommandCode(0x02), Length(0x02), ISO/IEC 15693(0x01), 26 Kbps H, Wait for SOF, 10% modulation, Single subcarrier S, CRC appended (0x0D)
|
||||
private readonly byte[] CR95HF_CMD_PROTOCOL_SELECT_OFF = { 0x02, 0x02, 0x00, 0x00 }; //CommandCode(0x02), Length(0x02), Protocol off (0x00), Protocol off (0x00)
|
||||
private List<byte> CR95HF_CMD_SEND_RECEIVE = new List<byte>(); // Command code (0x04), Length (this is number of bytes after this length byte), REQUEST_FLAGS(0x02) and payload (this varies based on device command)
|
||||
|
||||
private readonly byte REQUEST_FLAGS = 0x02; // Single subcarrier freq, High data rate, No Inventory/ProtExtn/Select/Address/Option flags
|
||||
|
||||
private SERIAL_Driver _SERIAL_Driver;
|
||||
public event DelNfc_CR95HF_MessageHandler MessageEvent;
|
||||
|
||||
private static readonly Dictionary<byte, string> CR95HF_ErrorCodes = new Dictionary<byte, string>
|
||||
{
|
||||
{ 0x00 , "Success, No error" },
|
||||
{ 0x80 , "Success, No error" },
|
||||
{ 0xA0 , "Success, No error" },
|
||||
{ 0xC0 , "Success, No error" },
|
||||
{ 0x82 , "Invalid command length" },
|
||||
{ 0x83 , "Invalid protocol"},
|
||||
{ 0x63 , "EEmdSOFerror23, SOF error in high part(duration 2 to 3 etu) in ISO/IEC 14443B"},
|
||||
{ 0x65 , "EEmdSOFerror10, SOF error in low part(duration 10 to 11 etu) in ISO/IEC 14443B"},
|
||||
{ 0x66 , "EEmdEgt error, Extended Guard Time error in ISO/IEC 14443B"},
|
||||
{ 0x67 , "ETr1 Too Big Too long, TR1 send by the card, reception stopped in ISO/IEC 14443BT"},
|
||||
{ 0x68 , "ETr1Too small Too small, TR1 send by the card in ISO/IEC 14443B"},
|
||||
{ 0x71 , "EinternalError, Wrong frame format decoded"},
|
||||
{ 0x85 , "EUserStop, Stopped by user(used only in Card mode)"},
|
||||
{ 0x86 , "ECommError, Hardware communication error"},
|
||||
{ 0x87 , "EFrameWaitTOut,Frame wait time out (no valid reception)"},
|
||||
{ 0x88 , "EInvalidSof,Invalid SOF" },
|
||||
{ 0x89 , "EBufOverflow,Too many bytes received and data still arriving" },
|
||||
{ 0x8A , "EFramingError,if start bit = 1 or stop bit = 0"},
|
||||
{ 0x8B , "EEgtError,EGT time out" },
|
||||
{ 0x8C , "EInvalidLen,Valid for ISO/IEC 18092, if Length<3" },
|
||||
{ 0x8D , "ECrcError,CRC error, Valid only for ISO/IEC 18092" },
|
||||
{ 0x8E , "ERecvLost,CRC error,When reception is lost without EOF received(or subcarrier was lost)"},
|
||||
{ 0x8F , "ENoField,CRC error,When Listen command detects the absence of external field)"},
|
||||
{ 0x90 , "EUnintByte,Residual bits in last byte. Useful for ACK/NAK reception of ISO/IEC 14443 Type A"},
|
||||
{ 0xFF , "Invalid COM port, request Failed" },
|
||||
};
|
||||
|
||||
public CR95HF_Reader(SERIAL_Driver serialdriver)
|
||||
{
|
||||
_SERIAL_Driver = serialdriver;
|
||||
}
|
||||
|
||||
#region Message Event
|
||||
private void OnMessageEvent(string message)
|
||||
{
|
||||
NfcMessageEventArgs e = new NfcMessageEventArgs();
|
||||
e.Message = message;
|
||||
|
||||
if (MessageEvent != null)
|
||||
{
|
||||
MessageEvent(this, e);
|
||||
}
|
||||
e = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool OpenConnection(string comport, int baudrate, int databits, Parity parity, StopBits stopbits)
|
||||
{
|
||||
return _SERIAL_Driver.OpenConnection(comport, baudrate, databits, parity, stopbits);//Port Intialization and Port Open;
|
||||
}
|
||||
|
||||
public bool CR95HF_Connect()
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
|
||||
if (_SERIAL_Driver.isOpen())
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Tools.ByteArrayToHexString(CR95HF_CMD_IDN));
|
||||
_SERIAL_Driver.SendMessage(CR95HF_CMD_IDN, CR95HF_CMD_IDN.Length);
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if (bytesReceived.Length == 17 && (bytesReceived[0] == 0x00 || bytesReceived[0] == 0x80))
|
||||
{
|
||||
string strReader = System.Text.Encoding.ASCII.GetString(bytesReceived);
|
||||
strReader = strReader.Substring(2, 12);
|
||||
OnMessageEvent("CombiHead '" + strReader + "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CR95HF_ErrorCodes.ContainsKey(bytesReceived[0]))
|
||||
OnMessageEvent("NFC CR95HF error: " + CR95HF_ErrorCodes[bytesReceived[0]]);
|
||||
else
|
||||
OnMessageEvent("NFC CR95HF error: Unidentified");
|
||||
return false;
|
||||
}
|
||||
|
||||
//OnMessageEvent("Tx- " + Tools.ByteArrayToHexString(CR95HF_CMD_PROTOCOL_SELECT_ON));
|
||||
_SERIAL_Driver.SendMessage(CR95HF_CMD_PROTOCOL_SELECT_ON, CR95HF_CMD_PROTOCOL_SELECT_ON.Length);
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] != 0x00) && (bytesReceived[0] != 0x80))
|
||||
{
|
||||
if (CR95HF_ErrorCodes.ContainsKey(bytesReceived[0]))
|
||||
OnMessageEvent("NFC CR95HF error: " + CR95HF_ErrorCodes[bytesReceived[0]]);
|
||||
else
|
||||
OnMessageEvent("NFC CR95HF error: Unidentified");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return false;
|
||||
}
|
||||
OnMessageEvent("NFC CR95HF: Protocol ON");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CR95HF_RFProtocolOn()
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
|
||||
if (_SERIAL_Driver.isOpen())
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Tools.ByteArrayToHexString(CR95HF_CMD_PROTOCOL_SELECT_ON));
|
||||
_SERIAL_Driver.SendMessage(CR95HF_CMD_PROTOCOL_SELECT_ON, CR95HF_CMD_PROTOCOL_SELECT_ON.Length);
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] != 0x00) && (bytesReceived[0] != 0x80))
|
||||
{
|
||||
if (CR95HF_ErrorCodes.ContainsKey(bytesReceived[0]))
|
||||
OnMessageEvent("NFC CR95HF error: " + CR95HF_ErrorCodes[bytesReceived[0]]);
|
||||
else
|
||||
OnMessageEvent("NFC CR95HF error: Unidentified");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CR95HF_RFProtocolOff()
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
|
||||
if (_SERIAL_Driver.isOpen())
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Tools.ByteArrayToHexString(CR95HF_CMD_PROTOCOL_SELECT_OFF));
|
||||
_SERIAL_Driver.SendMessage(CR95HF_CMD_PROTOCOL_SELECT_OFF, CR95HF_CMD_PROTOCOL_SELECT_OFF.Length);
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] != 0x00) && (bytesReceived[0] != 0x80))
|
||||
{
|
||||
if (CR95HF_ErrorCodes.ContainsKey(bytesReceived[0]))
|
||||
OnMessageEvent("NFC CR95HF error: " + CR95HF_ErrorCodes[bytesReceived[0]]);
|
||||
else
|
||||
OnMessageEvent("NFC CR95HF error: Unidentified");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CR95HF_SendRecv(byte[] fromDevice, out byte[] toDevice)
|
||||
{
|
||||
CR95HF_CMD_SEND_RECEIVE = new List<byte>();
|
||||
toDevice = null;
|
||||
|
||||
if (_SERIAL_Driver.isOpen())
|
||||
{
|
||||
CR95HF_CMD_SEND_RECEIVE.Add(0x04);//Command Code
|
||||
CR95HF_CMD_SEND_RECEIVE.Add((byte)(1 + fromDevice.Length)); // This is bytes from device + 1 (because request flags byte added here)
|
||||
CR95HF_CMD_SEND_RECEIVE.Add(REQUEST_FLAGS);
|
||||
CR95HF_CMD_SEND_RECEIVE.AddRange(fromDevice);
|
||||
|
||||
//OnMessageEvent("Tx- " + Tools.ByteArrayToHexString(CR95HF_CMD_SEND_RECEIVE.ToArray()));
|
||||
_SERIAL_Driver.SendMessage(CR95HF_CMD_SEND_RECEIVE.ToArray(), CR95HF_CMD_SEND_RECEIVE.Count);
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
byte[] bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == 0x00) || (bytesReceived[0] == 0x80) || (bytesReceived[0] == 0xA0) || (bytesReceived[0] == 0xC0))
|
||||
{
|
||||
toDevice = new byte[bytesReceived[1]];
|
||||
for (int i = 0; i < Convert.ToInt32(bytesReceived[1]); i++)
|
||||
{
|
||||
toDevice[i] = bytesReceived[2 + i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CR95HF_ErrorCodes.ContainsKey(bytesReceived[0]))
|
||||
OnMessageEvent("NFC CR95HF error: " + CR95HF_ErrorCodes[bytesReceived[0]]);
|
||||
else
|
||||
OnMessageEvent("NFC CR95HF error: Unidentified");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool CR95HF_Echo()
|
||||
{
|
||||
if (_SERIAL_Driver.isOpen())
|
||||
{
|
||||
if (_SERIAL_Driver.SendMessage(CR95HF_CMD_ECHO, 1))
|
||||
{
|
||||
if (_SERIAL_Driver.GetRawData().Length == 0) return false;
|
||||
byte[] bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
if ((bytesReceived.Length == 1) && (bytesReceived[0] == CR95HF_CMD_ECHO[0]))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,771 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.IO.Ports;
|
||||
using System.Timers;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public class MCI_Protocol
|
||||
{
|
||||
private bool MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
|
||||
private readonly byte STX = (byte) 0x02;
|
||||
private readonly byte ETX = (byte) 0x03;
|
||||
private readonly byte RX_ACK_RESPONSE_MSG_ID = (byte) 0xC9;
|
||||
private readonly ushort[] MciPasswords = { 0x0000, 0x55AA, 0x1234, 0x97D1 };
|
||||
|
||||
public event DelNfc_MCI_MessageHandler MessageEvent;
|
||||
|
||||
public enum StructName
|
||||
{
|
||||
Calibration,
|
||||
Configuration,
|
||||
Status,
|
||||
Power,
|
||||
LCD,
|
||||
unused1,
|
||||
unused2,
|
||||
Diagnostics,
|
||||
ProductionInfo,
|
||||
AckResponse,
|
||||
RadioParams,
|
||||
RadioInfo,
|
||||
Command,
|
||||
EEPROM_Metro,
|
||||
ST25_Chip_Registers,
|
||||
IndexReset,
|
||||
NfcSecurity
|
||||
}
|
||||
|
||||
public static readonly Dictionary<byte, string> StructName_id_to_str = new Dictionary<byte, string>
|
||||
{
|
||||
{0, "Calibration"},
|
||||
{1, "Configuration"},
|
||||
{2, "Status"},
|
||||
{3, "Power"},
|
||||
{4, "LCD"},
|
||||
{5, "unused1"},
|
||||
{6, "unused2"},
|
||||
{7, "Diagnostics"},
|
||||
{8, "ProductionInfo"},
|
||||
{9, "AckResponse"},
|
||||
{10, "RadioParams"},
|
||||
{11, "RadioInfo"},
|
||||
{12, "Command"},
|
||||
{13, "EEPROM_Metro"},
|
||||
{14, "ST25_Chip_Registers"},
|
||||
{15, "IndexReset"},
|
||||
{16, "NfcSecurity"}
|
||||
};
|
||||
|
||||
private string StructToStr(StructName StName)
|
||||
{
|
||||
return StructName_id_to_str[Convert.ToByte(StName)];
|
||||
}
|
||||
|
||||
private bool IsValidStruct(StructName StName)
|
||||
{
|
||||
return MCI_Protocol.StructName_id_to_str.ContainsKey(Convert.ToByte(StName));
|
||||
}
|
||||
|
||||
public enum MCI_ErrorCodes
|
||||
{
|
||||
// these first 0..8 error codes are defined both in
|
||||
// radio and metro. They can return these codes.
|
||||
// higher codes will not be returned
|
||||
Success_No_error = 0,
|
||||
MCI_Error_MeterAns_Timeout = 1,
|
||||
MCI_Error_MeterAns_Wrong_CRC = 2,
|
||||
MCI_Error_MeterAns_Wrong_password = 3,
|
||||
MCI_Error_MeterAns_Data_not_available = 4,
|
||||
MCI_Error_MeterAns_Invalid_access = 5,
|
||||
MCI_Error_MeterAns_Command_not_supported = 6,
|
||||
MCI_Error_MeterAns_Command_not_executed = 7,
|
||||
MCI_Error_MeterAns_Unidentified = 8,
|
||||
// in case higher errors will be defined for the IMI in future
|
||||
// we keep some distance with the errorcodes...
|
||||
|
||||
// host error codes from MCI_Read/Write start from 20:
|
||||
MCI_Error_Host_Bad_MCI_ID = 20,
|
||||
MCI_Error_Host_WriteReq_denied = 21,
|
||||
MCI_Error_Host_WriteReq_bad_device_ans = 22,
|
||||
MCI_Error_Host_ReadReq_denied = 23,
|
||||
MCI_Error_Host_ReadReq_bad_device_ans = 24,
|
||||
MCI_Error_Host_Bad_Payload_Len = 25,
|
||||
MCI_Error_Host_MeterCRCDoesNotMatch = 26,
|
||||
MCI_Error_Host_ReadReqBadResponseStructure = 27,
|
||||
MCI_Error_Host_InvalidStructureID_CannotSendMsg = 28,
|
||||
MCI_Error_Host_CommandNotInCmdCodeList = 29,
|
||||
|
||||
// host error codes from method MCI_TxRequest_RxResponse start from 40
|
||||
MCI_Error_Host_MB_CTRL_Reg_Read1 = 40,
|
||||
MCI_Error_Host_MB_disabled1 = 41,
|
||||
MCI_Error_Host_MB_LEN_Reg_read1 = 42,
|
||||
MCI_Error_Host_MB_msg_read1 = 43,
|
||||
MCI_Error_Host_req_not_sent = 44,
|
||||
MCI_Error_Host_req_not_read_by_iperl = 45,
|
||||
MCI_Error_Host_MB_CTRL_Reg_Read2 = 46,
|
||||
MCI_Error_Host_MB_disabled2 = 47,
|
||||
MCI_Error_Host_MB_LEN_Reg_read2 = 48,
|
||||
MCI_Error_Host_MB_msg_read2 = 49,
|
||||
MCI_Error_Host_Timeout = 50,
|
||||
MCI_Error_Host_msg_write = 51
|
||||
}
|
||||
|
||||
public static string GetMCIErrorMessage(byte ErrorCode)
|
||||
{
|
||||
// this is called reflection. The variable names will be
|
||||
// returned. No need of copys of variable names to string values.
|
||||
return ((MCI_ErrorCodes) ErrorCode).ToString();
|
||||
}
|
||||
|
||||
public static readonly Dictionary<byte, string> MCI_CmdCodes = new Dictionary<byte, string>
|
||||
{
|
||||
{0x00 , "Command: No Operation" },
|
||||
{0x01 , "Command: Clear Alarms" },
|
||||
{0x04 , "Command: Clear Diag" },
|
||||
{0x05 , "Command: Clear Peak flowrate" },
|
||||
{0x06 , "Command: Enter Active mode" },
|
||||
{0x07 , "Command: Enter Test mode" },
|
||||
{0x09 , "Command: Reset Accumulated Volume" },
|
||||
{0x0A , "Command: Factory Default" },
|
||||
{0x0B , "Command: Seal" },
|
||||
{0x0C , "Command: Send radio address to radio FW" },
|
||||
{0x0D , "Command: Adjust Field" },
|
||||
{0x0E , "Command: LCD All segments ON" },
|
||||
{0x0F , "Command: LCD All segments OFF" },
|
||||
{0x10 , "Command: LCD Even segments ON" },
|
||||
{0x11 , "Command: LCD Odd segments ON" },
|
||||
{0x12 , "Command: LNA ON" },
|
||||
{0x13 , "Command: LNA OFF" },
|
||||
{0x14 , "Command: EPD ON" },
|
||||
{0x15 , "Command: EPD OFF" },
|
||||
{0x16 , "Command: Enter LPM4" },
|
||||
{0x17 , "Command: Select drive coil connectivity" },
|
||||
{0x1A , "Command: Enter VRTM" },
|
||||
{0x1B , "Custom Package Mode ON" },
|
||||
{0x1C , "Custom Package Mode OFF" },
|
||||
{0x20 , "Command: Deinstall" },
|
||||
{0x21 , "Command: Audit Mode" },
|
||||
{0x22 , "Command: Diagnostic Refresh" },
|
||||
{0x23 , "Command: NFC Security Reset Access Level" }
|
||||
};
|
||||
|
||||
Dictionary<int, byte[]> MCI_Write_Info = new Dictionary<int, byte[]>();
|
||||
Dictionary<int, byte[]> MCI_Read_Info = new Dictionary<int, byte[]>();
|
||||
Dictionary<int, byte[]> MCI_ReadResponse_Info = new Dictionary<int, byte[]>();
|
||||
|
||||
private byte MB_Ctrl_Reg_Value;
|
||||
private byte MB_LEN_Dyn_Register;
|
||||
|
||||
private ST25DV_Device _ST25DV_Device;
|
||||
Tools.Crc16Ccitt Crc = new Tools.Crc16Ccitt(Tools.InitialCrcValue.NonZero1);
|
||||
|
||||
private System.Timers.Timer _ReqResCycleTimeoutTimer = new System.Timers.Timer();
|
||||
|
||||
public MCI_Protocol(ST25DV_Device ST25DVDevice)
|
||||
{
|
||||
_ST25DV_Device = ST25DVDevice;
|
||||
Init_MCI_Info_MsgId_Password();
|
||||
}
|
||||
private void Init_MCI_Info_MsgId_Password()
|
||||
{
|
||||
//Write request
|
||||
byte[] value1 = { 0x40, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(0, value1);//Calibration
|
||||
|
||||
byte [] value2 = { 0x41, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(1, value2); //Configuration
|
||||
|
||||
byte[] value3 = { 0x42, 0x34, 0x12 };
|
||||
MCI_Write_Info.Add(2, value3); //Status
|
||||
|
||||
byte[] value4 = { 0x43, 0x34, 0x12 };
|
||||
MCI_Write_Info.Add(3, value4);//Power
|
||||
|
||||
byte[] value5 = { 0x44, 0xAA, 0x55 };
|
||||
MCI_Write_Info.Add(4, value5); //LCD
|
||||
|
||||
byte[] value6 = { 0x48, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(8, value6);//ProductionInfo
|
||||
|
||||
byte[] value7 = { 0x4E, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(10, value7);//RadioParams
|
||||
|
||||
byte[] value8 = { 0x4E, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(11, value8);//RadioInfo
|
||||
|
||||
byte[] value9 = { 0x4A, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(12, value9);//Command
|
||||
|
||||
byte[] valueIndexResetWrite = { 0x52, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(15, valueIndexResetWrite);//Index reset
|
||||
|
||||
byte[] valueNfcSecuritySignedWrite = { 0x54, 0xD1, 0x97 };
|
||||
MCI_Write_Info.Add(16, valueNfcSecuritySignedWrite);//NFC Security signed message - while writing
|
||||
|
||||
//Read request
|
||||
byte[] value10 = { 0x00, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(0, value10);//Calibration
|
||||
|
||||
byte[] value11 = { 0x01, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(1, value11); //Configuration
|
||||
|
||||
byte[] value12 = { 0x02, 0x34, 0x12 };
|
||||
MCI_Read_Info.Add(2, value12); //Status
|
||||
|
||||
byte[] value13 = { 0x03, 0x34, 0x12 };
|
||||
MCI_Read_Info.Add(3, value13);//Power
|
||||
|
||||
byte[] value14 = { 0x04, 0xAA, 0x55 };
|
||||
MCI_Read_Info.Add(4, value14); //LCD
|
||||
|
||||
byte[] value15 = { 0x07, 0xAA, 0x55 };
|
||||
MCI_Read_Info.Add(7, value15); //Diag
|
||||
|
||||
byte[] value16 = { 0x08, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(8, value16);//ProductionInfo
|
||||
|
||||
byte[] value17 = { 0x0E, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(10, value17);//RadioParams
|
||||
|
||||
byte[] value18 = { 0x0E, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(11, value18);//RadioInfo
|
||||
|
||||
byte[] valueIndexResetRead = { 0x12, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(15, valueIndexResetRead);//Index reset
|
||||
|
||||
byte[] valueNfcSecurityUnsignedRead = { 0x14, 0xD1, 0x97 };
|
||||
MCI_Read_Info.Add(16, valueNfcSecurityUnsignedRead);//NFC Security non-signed message - while reading
|
||||
|
||||
//Read response
|
||||
byte[] value19 = { 0xC0, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(0, value19);//Calibration
|
||||
|
||||
byte[] value20 = { 0xC1, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(1, value20); //Configuration
|
||||
|
||||
byte[] value21 = { 0xC2, 0x34, 0x12 };
|
||||
MCI_ReadResponse_Info.Add(2, value21); //Status
|
||||
|
||||
byte[] value22 = { 0xC3, 0x34, 0x12 };
|
||||
MCI_ReadResponse_Info.Add(3, value22);//Power
|
||||
|
||||
byte[] value23 = { 0xC4, 0xAA, 0x55 };
|
||||
MCI_ReadResponse_Info.Add(4, value23); //LCD
|
||||
|
||||
byte[] value24 = { 0xC7, 0xAA, 0x55 };
|
||||
MCI_ReadResponse_Info.Add(7, value24); //Diag
|
||||
|
||||
byte[] value25 = { 0xC8, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(8, value25);//ProductionInfo
|
||||
|
||||
byte[] value26 = { 0xC9, 0x00, 0x00 };
|
||||
MCI_ReadResponse_Info.Add(9, value26);//Ack response
|
||||
|
||||
byte[] value27 = { 0xCE, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(10, value27);//RadioParams
|
||||
|
||||
byte[] value28 = { 0xCE, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(11, value28);//RadioInfo
|
||||
|
||||
byte[] valueIndexResetReadResponse = { 0xD2, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(15, valueIndexResetReadResponse);//Index reset
|
||||
|
||||
byte[] valueNfcSecurityUnsignedReadResponse = { 0xD4, 0xD1, 0x97 };
|
||||
MCI_ReadResponse_Info.Add(16, valueNfcSecurityUnsignedReadResponse);//NFC Security non-signed message response - while reading
|
||||
}
|
||||
|
||||
public bool MCI_Write(StructName StName, ushort offset, byte payloadlength, byte[] inBuffer, int timeoutMs,
|
||||
out byte errorCode)
|
||||
{
|
||||
List<byte> RequestMessage = new List<byte>();
|
||||
byte[] ResponseMessage = null;
|
||||
byte[] crcValue = new byte[2];
|
||||
|
||||
errorCode = (byte) MCI_ErrorCodes.Success_No_error;
|
||||
|
||||
if (payloadlength != inBuffer.Length)
|
||||
{
|
||||
// Insufficient Payload length
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_Bad_Payload_Len;
|
||||
return false;
|
||||
}
|
||||
if (StName == StructName.Command)
|
||||
{
|
||||
if (! MCI_Protocol.MCI_CmdCodes.ContainsKey(inBuffer[0]))
|
||||
{
|
||||
// Command not supported
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_CommandNotInCmdCodeList;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // not a command => should be struct
|
||||
{
|
||||
if (!IsValidStruct(StName))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_InvalidStructureID_CannotSendMsg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] MsgId_Password = MCI_Write_Info[(int)StName];
|
||||
|
||||
RequestMessage.Add(STX);
|
||||
RequestMessage.Add(Convert.ToByte(6 + payloadlength));
|
||||
RequestMessage.Add(MsgId_Password[0]);
|
||||
RequestMessage.Add((byte)(offset & 0x00FF));
|
||||
RequestMessage.Add((byte)((offset & 0xFF00) >> 8));
|
||||
RequestMessage.Add(payloadlength);
|
||||
|
||||
for (int i = 0; i < payloadlength; i++) // copy Buffer -> Request Payload
|
||||
{
|
||||
RequestMessage.Add(inBuffer[i]);
|
||||
}
|
||||
|
||||
RequestMessage.Add(MsgId_Password[1]);
|
||||
RequestMessage.Add(MsgId_Password[2]);
|
||||
// calc CRC and add to request
|
||||
crcValue = Crc.calcCRCfromMessage(RequestMessage.ToArray());
|
||||
RequestMessage.Add(crcValue[0]);
|
||||
RequestMessage.Add(crcValue[1]);
|
||||
RequestMessage.Add(ETX);
|
||||
|
||||
OnMessageEvent("Write " + StructToStr(StName) + "Request: " + Tools.BytesToHex(RequestMessage.ToArray()));
|
||||
errorCode = MCI_TxRequest_RxResponse(RequestMessage.ToArray(), out ResponseMessage, timeoutMs);
|
||||
if (errorCode != (byte)MCI_ErrorCodes.Success_No_error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//Response message received
|
||||
byte[] RxCrcComputed = Crc.calcCRCfromMessage(ResponseMessage);
|
||||
byte[] RxCrcMeter = new byte[2];
|
||||
// CRC starts at length + STX(1) + lenbyte(1) = RespMsg[1] + 2.
|
||||
Array.Copy(ResponseMessage, ResponseMessage[1] + 2, RxCrcMeter, 0, 2);
|
||||
if (!Crc.crc_do_match(RxCrcMeter, RxCrcComputed))
|
||||
{
|
||||
OnMessageEvent(Crc.commentCRC(RxCrcMeter, RxCrcComputed));
|
||||
errorCode = (byte) MCI_ErrorCodes.MCI_Error_Host_MeterCRCDoesNotMatch;
|
||||
return false;
|
||||
}
|
||||
if ((ResponseMessage[0] == STX)
|
||||
&& (ResponseMessage[1] == 0x07)
|
||||
&& (ResponseMessage[2] == RX_ACK_RESPONSE_MSG_ID)
|
||||
&& (ResponseMessage[11] == ETX))
|
||||
{
|
||||
errorCode = ResponseMessage[6]; // meter error. Must be between 0..8.
|
||||
// Will be converted to errormessage string from the calling method.
|
||||
if (errorCode != 0)
|
||||
{
|
||||
OnMessageEvent("Write " + StructToStr(StName) + " failed. Request Response: " + Tools.BytesToHex(ResponseMessage));
|
||||
return false;
|
||||
}
|
||||
OnMessageEvent("Write : Success");
|
||||
return true;
|
||||
}
|
||||
errorCode = (byte) MCI_ErrorCodes.MCI_Error_Host_WriteReq_bad_device_ans;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool MCI_Write_Read(StructName StName, ushort offset, byte payloadlength, byte[] inBuffer, out byte[] outBuffer, int timeoutMs,
|
||||
out byte errorCode)
|
||||
{
|
||||
List<byte> RequestMessage = new List<byte>();
|
||||
byte[] ResponseMessage = null;
|
||||
byte[] crcValue = new byte[2];
|
||||
|
||||
byte RxMsgLength;
|
||||
byte RxMsgId;
|
||||
byte[] RxOffset = new byte[2];
|
||||
byte RxPayloadlength;
|
||||
byte[] RxCrcMeter = new byte[2];
|
||||
|
||||
outBuffer = null;
|
||||
|
||||
errorCode = (byte)MCI_ErrorCodes.Success_No_error;
|
||||
|
||||
if (payloadlength != inBuffer.Length)
|
||||
{
|
||||
// Insufficient Payload length
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_Bad_Payload_Len;
|
||||
return false;
|
||||
}
|
||||
if (StName == StructName.Command)
|
||||
{
|
||||
if (!MCI_Protocol.MCI_CmdCodes.ContainsKey(inBuffer[0]))
|
||||
{
|
||||
// Command not supported
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_CommandNotInCmdCodeList;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // not a command => should be struct
|
||||
{
|
||||
if (!IsValidStruct(StName))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_InvalidStructureID_CannotSendMsg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] MsgId_Password = MCI_Write_Info[(int)StName];
|
||||
|
||||
RequestMessage.Add(STX);
|
||||
RequestMessage.Add(Convert.ToByte(6 + payloadlength));
|
||||
RequestMessage.Add(MsgId_Password[0]);
|
||||
RequestMessage.Add((byte)(offset & 0x00FF));
|
||||
RequestMessage.Add((byte)((offset & 0xFF00) >> 8));
|
||||
RequestMessage.Add(payloadlength);
|
||||
|
||||
for (int i = 0; i < payloadlength; i++) // copy Buffer -> Request Payload
|
||||
{
|
||||
RequestMessage.Add(inBuffer[i]);
|
||||
}
|
||||
|
||||
RequestMessage.Add(MsgId_Password[1]);
|
||||
RequestMessage.Add(MsgId_Password[2]);
|
||||
// calc CRC and add to request
|
||||
crcValue = Crc.calcCRCfromMessage(RequestMessage.ToArray());
|
||||
RequestMessage.Add(crcValue[0]);
|
||||
RequestMessage.Add(crcValue[1]);
|
||||
RequestMessage.Add(ETX);
|
||||
|
||||
OnMessageEvent("Write " + StructToStr(StName) + "Request: " + Tools.BytesToHex(RequestMessage.ToArray()));
|
||||
errorCode = MCI_TxRequest_RxResponse(RequestMessage.ToArray(), out ResponseMessage, timeoutMs);
|
||||
if (errorCode != (byte)MCI_ErrorCodes.Success_No_error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((ResponseMessage[0] == STX) && (ResponseMessage[11] == ETX)
|
||||
&& (ResponseMessage[1] == 0x07)
|
||||
&& (ResponseMessage[2] == RX_ACK_RESPONSE_MSG_ID))
|
||||
{
|
||||
//Ack message received, not served the read request
|
||||
errorCode = ResponseMessage[6]; // forward error message from meter
|
||||
OnMessageEvent("Read " + StructToStr(StName) + ": Failed with error "
|
||||
+ Tools.ByteToHexString(errorCode));
|
||||
return false;
|
||||
}
|
||||
//Response message received
|
||||
RxMsgLength = ResponseMessage[1];
|
||||
RxMsgId = ResponseMessage[2];
|
||||
// RxOffset[0] = ResponseMessage[3];
|
||||
// RxOffset[1] = ResponseMessage[4];
|
||||
RxPayloadlength = ResponseMessage[5];
|
||||
// RxPassword[0] = ResponseMessage[6 + RxPayloadlength];
|
||||
// RxPassword[1] = ResponseMessage[7 + RxPayloadlength];
|
||||
RxCrcMeter[0] = ResponseMessage[8 + RxPayloadlength];
|
||||
RxCrcMeter[1] = ResponseMessage[9 + RxPayloadlength];
|
||||
|
||||
|
||||
byte[] RxCrcComputed = Crc.calcCRCfromMessage(ResponseMessage);
|
||||
// OnMessageEvent(Crc.commentCRC(RxCrcMeter, RxCrcComputed));
|
||||
if (!Crc.crc_do_match(RxCrcMeter, RxCrcComputed))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_MeterCRCDoesNotMatch;
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO, verify received password matches with expected password or not?
|
||||
if (!((ResponseMessage[0] == STX) && (ResponseMessage[10 + RxPayloadlength] == ETX)
|
||||
&& ((ResponseMessage[2] & 0x3F) == (MsgId_Password[0] & 0x3F))))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_ReadReqBadResponseStructure;
|
||||
return false;
|
||||
}
|
||||
|
||||
outBuffer = new byte[RxPayloadlength];
|
||||
for (int i = 0; i < RxPayloadlength; i++)
|
||||
{
|
||||
outBuffer[i] = (ResponseMessage[6 + i]);
|
||||
}
|
||||
|
||||
if (IsValidStruct(StName))
|
||||
{
|
||||
OnMessageEvent("Read " + StructToStr(StName) + ": " + Tools.BytesToHex(outBuffer)
|
||||
+ " Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("Read Failed! Unknown MCI ID: " + Convert.ToByte(StName));
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_Bad_MCI_ID;
|
||||
return false;
|
||||
}
|
||||
errorCode = (byte)0x00; //Success, No error
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MCI_Read(StructName StName, ushort offset, byte payloadlength, int timeoutMs,
|
||||
out byte[] outBuffer, out byte errorCode)
|
||||
{
|
||||
List<byte> RequestMessage = new List<byte>();
|
||||
byte[] ResponseMessage = null;
|
||||
|
||||
byte RxMsgLength;
|
||||
byte RxMsgId;
|
||||
byte [] RxOffset = new byte[2];
|
||||
byte RxPayloadlength;
|
||||
byte[] RxCrcMeter = new byte[2];
|
||||
byte[] RxPassword = new byte[2];
|
||||
|
||||
byte[] MsgId_Password = MCI_Read_Info[(byte)StName];
|
||||
byte[] crcValue;
|
||||
outBuffer = null;
|
||||
errorCode = (byte)0x00; //Success, No error
|
||||
|
||||
if (! IsValidStruct(StName))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_InvalidStructureID_CannotSendMsg;
|
||||
OnMessageEvent("Read request:" + MCI_Protocol.GetMCIErrorMessage(errorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
RequestMessage.Add(STX);
|
||||
RequestMessage.Add(0x06);
|
||||
RequestMessage.Add(MsgId_Password[0]);
|
||||
RequestMessage.Add((byte)(offset & 0x00FF));
|
||||
RequestMessage.Add((byte)((offset & 0xFF00) >> 8));
|
||||
RequestMessage.Add(payloadlength);
|
||||
RequestMessage.Add(MsgId_Password[1]);
|
||||
RequestMessage.Add(MsgId_Password[2]);
|
||||
|
||||
crcValue = Crc.calcCRCfromMessage(RequestMessage.ToArray());
|
||||
RequestMessage.AddRange(crcValue);
|
||||
RequestMessage.Add(ETX);
|
||||
|
||||
OnMessageEvent("Read Request: " + Tools.BytesToHex(RequestMessage.ToArray()));
|
||||
errorCode = MCI_TxRequest_RxResponse(RequestMessage.ToArray(), out ResponseMessage, timeoutMs);
|
||||
if (errorCode != (byte) MCI_ErrorCodes.Success_No_error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((ResponseMessage[0] == STX) && (ResponseMessage[11] == ETX)
|
||||
&& (ResponseMessage[1] == 0x07)
|
||||
&& (ResponseMessage[2] == RX_ACK_RESPONSE_MSG_ID))
|
||||
{
|
||||
//Ack message received, not served the read request
|
||||
errorCode = ResponseMessage[6]; // forward error message from meter
|
||||
OnMessageEvent("Read " + StructToStr(StName) + ": Failed with error "
|
||||
+ Tools.ByteToHexString(errorCode));
|
||||
return false;
|
||||
}
|
||||
//Response message received
|
||||
RxMsgLength = ResponseMessage[1];
|
||||
RxMsgId = ResponseMessage[2];
|
||||
// RxOffset[0] = ResponseMessage[3];
|
||||
// RxOffset[1] = ResponseMessage[4];
|
||||
RxPayloadlength = ResponseMessage[5];
|
||||
// RxPassword[0] = ResponseMessage[6 + RxPayloadlength];
|
||||
// RxPassword[1] = ResponseMessage[7 + RxPayloadlength];
|
||||
RxCrcMeter[0] = ResponseMessage[8 + RxPayloadlength];
|
||||
RxCrcMeter[1] = ResponseMessage[9 + RxPayloadlength];
|
||||
|
||||
|
||||
byte[] RxCrcComputed = Crc.calcCRCfromMessage(ResponseMessage);
|
||||
// OnMessageEvent(Crc.commentCRC(RxCrcMeter, RxCrcComputed));
|
||||
if (!Crc.crc_do_match(RxCrcMeter, RxCrcComputed))
|
||||
{
|
||||
errorCode = (byte) MCI_ErrorCodes.MCI_Error_Host_MeterCRCDoesNotMatch;
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO, verify received password matches with expected password or not?
|
||||
if (!((ResponseMessage[0] == STX) && (ResponseMessage[10 + RxPayloadlength] == ETX)
|
||||
&& ((ResponseMessage[2] & 0x3F) == (MsgId_Password[0] & 0x3F))))
|
||||
{
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_ReadReqBadResponseStructure;
|
||||
return false;
|
||||
}
|
||||
|
||||
outBuffer = new byte[RxPayloadlength];
|
||||
for (int i = 0; i < RxPayloadlength; i++)
|
||||
{
|
||||
outBuffer[i] = (ResponseMessage[6 + i]);
|
||||
}
|
||||
|
||||
|
||||
if (IsValidStruct(StName))
|
||||
{
|
||||
OnMessageEvent("Read " + StructToStr(StName) + ": " + Tools.BytesToHex(outBuffer)
|
||||
+ " Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("Read Failed! Unknown MCI ID: " + Convert.ToByte(StName));
|
||||
errorCode = (byte)MCI_ErrorCodes.MCI_Error_Host_Bad_MCI_ID;
|
||||
return false;
|
||||
}
|
||||
errorCode = (byte)0x00; //Success, No error
|
||||
return true;
|
||||
}
|
||||
|
||||
private byte MCI_TxRequest_RxResponse(byte[] InBuffer, out byte[] OutBuffer, int timeout)
|
||||
{
|
||||
// return message is the errorcode, 0 means no error.
|
||||
byte[] responseMsg = null;
|
||||
OutBuffer = null;
|
||||
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
StartReqResCycleTimeoutTimer(timeout);
|
||||
|
||||
if (!_ST25DV_Device.ST25DV_ReadMailboxControlReg(out MB_Ctrl_Reg_Value))
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte) MCI_ErrorCodes.MCI_Error_Host_MB_CTRL_Reg_Read1;
|
||||
}
|
||||
//Mailbox enable/disable check, proceed further only if enabled
|
||||
if ((MB_Ctrl_Reg_Value & 0x01) == 0x00)
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
OnMessageEvent(">> REMARK: Check if Metorlogy firmware-version is at least: 5.1.24 <<");
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_MB_disabled1;
|
||||
}
|
||||
//Checking iPERL previous message is in mailbox or not, if present then read it and return failure
|
||||
if ((MB_Ctrl_Reg_Value & 0x02) == 0x02)
|
||||
{
|
||||
byte returnError;
|
||||
OnMessageEvent("NFC DLL Error: Previous message not read, reading now !");
|
||||
if (!_ST25DV_Device.ST25DV_ReadMailboxMessageLength(out MB_LEN_Dyn_Register))
|
||||
{
|
||||
returnError = (byte)MCI_ErrorCodes.MCI_Error_Host_MB_LEN_Reg_read1;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFC DLL Error: Previous message length " + MB_LEN_Dyn_Register);
|
||||
if (!_ST25DV_Device.ST25DV_ReadMessage(MB_LEN_Dyn_Register, out responseMsg))
|
||||
{
|
||||
returnError = (byte)MCI_ErrorCodes.MCI_Error_Host_MB_msg_read1;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFC DLL Error: Previous message read as " + Tools.BytesToHex(responseMsg));
|
||||
OnMessageEvent("NFC DLL Error: Present request not sent, retry again !");
|
||||
returnError = (byte)MCI_ErrorCodes.MCI_Error_Host_req_not_sent;
|
||||
}
|
||||
}
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return returnError;
|
||||
}
|
||||
|
||||
//Checking previous app message is in mailbox or not, if present then return failure !
|
||||
if ((MB_Ctrl_Reg_Value & 0x04) == 0x04)
|
||||
{
|
||||
// Previous sent request is not read by iPERL
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_req_not_read_by_iperl;
|
||||
}
|
||||
//Mailbox free, so sending request message
|
||||
if (_ST25DV_Device.ST25DV_WriteMessage(InBuffer))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (!_ST25DV_Device.ST25DV_ReadMailboxControlReg(out MB_Ctrl_Reg_Value))
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_MB_CTRL_Reg_Read2;
|
||||
}
|
||||
//Mailbox enable/disable check, proceed further only if enabled
|
||||
if ((MB_Ctrl_Reg_Value & 0x01) == 0x00)
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_MB_disabled2;
|
||||
}
|
||||
|
||||
//Proceed further only if host replied response message, otherwise wait in this loop
|
||||
if ((MB_Ctrl_Reg_Value & 0x02) == 0x02)
|
||||
{
|
||||
if (!_ST25DV_Device.ST25DV_ReadMailboxMessageLength(out MB_LEN_Dyn_Register))
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_MB_LEN_Reg_read2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_ST25DV_Device.ST25DV_ReadMessage(MB_LEN_Dyn_Register, out responseMsg))
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_MB_msg_read2;
|
||||
}
|
||||
else
|
||||
{
|
||||
OutBuffer = new byte[responseMsg.Length];
|
||||
OutBuffer = responseMsg;
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.Success_No_error;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Checking timeout occured or not
|
||||
if(MCI_CycleResponseMsgTimeoutFlag)
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_Timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = false;
|
||||
stopReqResCycleTimeoutTimer();
|
||||
return (byte)MCI_ErrorCodes.MCI_Error_Host_msg_write;
|
||||
}
|
||||
}
|
||||
|
||||
#region Message Event
|
||||
private void OnMessageEvent(string message)
|
||||
{
|
||||
NfcMessageEventArgs e = new NfcMessageEventArgs();
|
||||
e.Message = message;
|
||||
|
||||
if (MessageEvent != null)
|
||||
{
|
||||
MessageEvent(this, e);
|
||||
}
|
||||
e = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void StartReqResCycleTimeoutTimer(int timeoutMilliSec)
|
||||
{
|
||||
_ReqResCycleTimeoutTimer.Elapsed += new ElapsedEventHandler(ReqResCycleTimeoutEvent);
|
||||
_ReqResCycleTimeoutTimer.Interval = timeoutMilliSec;
|
||||
_ReqResCycleTimeoutTimer.Enabled = true;
|
||||
_ReqResCycleTimeoutTimer.Stop();
|
||||
_ReqResCycleTimeoutTimer.Start();
|
||||
}
|
||||
|
||||
private void stopReqResCycleTimeoutTimer()
|
||||
{
|
||||
_ReqResCycleTimeoutTimer.Stop();
|
||||
}
|
||||
|
||||
#region Timer Event
|
||||
private void ReqResCycleTimeoutEvent(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
MCI_CycleResponseMsgTimeoutFlag = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,655 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public class NFCHeadConfig
|
||||
{
|
||||
private SERIAL_Driver _SERIAL_Driver;
|
||||
public event DelNfc_NFCHeadConfig_MessageHandler MessageEvent;
|
||||
|
||||
private readonly byte NFC_HEAD_CONFIG_MAX_RETRIES = 5;
|
||||
private readonly byte[] NFCHeadConfig_OK_res_msg = Encoding.ASCII.GetBytes("OK\n"); //'OK\n' - ack - request is implemented successfully
|
||||
private readonly byte[] NFCHeadConfig_crst_req_msg = Encoding.ASCII.GetBytes("crst\r\n"); //'crst\r\n' - command - reset message
|
||||
private readonly byte[] NFCHeadConfig_cdoff_req_msg = Encoding.ASCII.GetBytes("cdoff\r\n"); //'cdoff\r\n' - command - data mode off request message
|
||||
private readonly byte[] NFCHeadConfig_cdon_req_msg = Encoding.ASCII.GetBytes("cdon\r\n"); //'cdon\r\n' - command - data mode on request message
|
||||
private readonly byte[] NFCHeadConfig_cpon_req_msg = Encoding.ASCII.GetBytes("cpon\r\n"); //'cpon\r\n' - command - pulse output enable command request message
|
||||
private readonly byte[] NFCHeadConfig_cnfc_req_msg = Encoding.ASCII.GetBytes("cnfc\r\n"); //'cnfc\r\n' - command - nfc interface configure request message
|
||||
private readonly byte[] NFCHeadConfig_crfid_req_msg = Encoding.ASCII.GetBytes("crfid\r\n"); //'crfid\r\n' - command - rfid interface configure request message
|
||||
private readonly byte[] NFCHeadConfig_cadc_req_msg = Encoding.ASCII.GetBytes("cadc\r\n"); //'cadc\r\n' - command - adc sampling start request message
|
||||
private byte[] NFCHeadConfig_gw_write_req_msg = Encoding.ASCII.GetBytes("gw00\r\n"); //'gw00\r\n' - write request - gain write request message. here 00 are hex digits and to be replaced with value to be written
|
||||
private readonly byte[] NFCHeadConfig_ir_read_req_msg = Encoding.ASCII.GetBytes("ir\r\n"); //'ir\r\n' - read request - interface read request message
|
||||
private readonly byte[] NFCHeadConfig_ir_read_res_msg_nfc = Encoding.ASCII.GetBytes("INFC\n"); //'INFC\n' - read response - NFC interface read response message
|
||||
private readonly byte[] NFCHeadConfig_ir_read_res_msg_rfid = Encoding.ASCII.GetBytes("IRFID\n"); //'IRFID\n' - read response - RFID interface read response message
|
||||
private readonly byte[] NFCHeadConfig_gr_read_req_msg = Encoding.ASCII.GetBytes("gr\r\n"); //'gr\r\n' - read request - gain read request message
|
||||
private readonly byte[] NFCHeadConfig_gr_read_res_msg = Encoding.ASCII.GetBytes("GR00\n"); //'GR00\n' - read response - gain read response message. here 00 are hex digits
|
||||
private readonly byte[] NFCHeadConfig_opr_read_req_msg = Encoding.ASCII.GetBytes("opr\r\n"); //'opr\r\n' - read request - opamp output read request message
|
||||
private readonly byte[] NFCHeadConfig_opr_read_res_msg = Encoding.ASCII.GetBytes("OP0000\n"); //'OP0000\n' - read response - opamp output read response message. here 0000 are hex digits
|
||||
private readonly byte[] NFCHeadConfig_fr_read_req_msg = Encoding.ASCII.GetBytes("fr\r\n"); //'fr\r\n' - read request - firmware read request message
|
||||
private readonly byte[] NFCHeadConfig_fr_read_res_msg = Encoding.ASCII.GetBytes("V1.23\n"); //'V1.23\n' - read response - firmware read response message. here 1 is major number and 23 is minor numer
|
||||
|
||||
public NFCHeadConfig(SERIAL_Driver serialdriver)
|
||||
{
|
||||
_SERIAL_Driver = serialdriver;
|
||||
}
|
||||
|
||||
#region Message Event
|
||||
private void OnMessageEvent(string message)
|
||||
{
|
||||
NfcMessageEventArgs e = new NfcMessageEventArgs();
|
||||
e.Message = message;
|
||||
|
||||
if (MessageEvent != null)
|
||||
{
|
||||
MessageEvent(this, e);
|
||||
}
|
||||
e = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private byte HexToAscii(byte u8HexDigit)
|
||||
{
|
||||
if (u8HexDigit < 10)
|
||||
{
|
||||
u8HexDigit += 0x30; //'0' - 0x30
|
||||
}
|
||||
else if (u8HexDigit < 16)
|
||||
{
|
||||
u8HexDigit -= 10;
|
||||
u8HexDigit += 0x61; //'a' - 0x61
|
||||
}
|
||||
else
|
||||
{
|
||||
u8HexDigit = 0xFF;
|
||||
}
|
||||
return u8HexDigit;
|
||||
}
|
||||
|
||||
static byte AsciiToHex(byte u8AsciiByte)
|
||||
{
|
||||
if (('0' <= u8AsciiByte) && ('9' >= u8AsciiByte))
|
||||
{
|
||||
u8AsciiByte -= 0x30; //'0' - 0x30
|
||||
}
|
||||
else if (('A' <= u8AsciiByte) && ('F' >= u8AsciiByte))
|
||||
{
|
||||
u8AsciiByte -= 0x41; //'A' - 0x41
|
||||
u8AsciiByte += 0xA;
|
||||
}
|
||||
else if (('a' <= u8AsciiByte) && ('f' >= u8AsciiByte))
|
||||
{
|
||||
u8AsciiByte -= 0x61; //'a' - 0x61
|
||||
u8AsciiByte += 0xA;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8AsciiByte = 0xFF;
|
||||
}
|
||||
return u8AsciiByte;
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_PulseLedOutputEnable()
|
||||
{
|
||||
//Switching off data mode or changing to command mode ("cdoff\r\n")
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
return false; // true - success, false - failed
|
||||
}
|
||||
|
||||
//Pulse output enable command ("cpon\r\n")
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cpon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
return false; // true - success, false - failed
|
||||
}
|
||||
return true; // true - success, false - failed
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_DataLedOutputEnable()
|
||||
{
|
||||
//Switching on data mode ("cdon\r\n")
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
return false; // true - success, false - failed
|
||||
}
|
||||
return true; // true - success, false - failed
|
||||
}
|
||||
|
||||
public ushort NFCHeadConfig_ReadOpampOutput()
|
||||
{
|
||||
ushort temp = 0;
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
ushort retVal = 0; // 0 - failed, any other value is Opamp Output
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
retVal = 0;
|
||||
OnMessageEvent("NFCHeadConfig_ReadOpampOutput........Failed");
|
||||
return retVal; // 0 - failed, any other value is Opamp Output
|
||||
}
|
||||
|
||||
//NFC head is in command mode
|
||||
//Sending command 'cadc\r\n' for starting sampling of OP_OUT
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cadc_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
retVal = 0;
|
||||
OnMessageEvent("NFCHeadConfig_ReadOpampOutput........Failed");
|
||||
return retVal; // 0 - failed, any other value is Opamp Output
|
||||
}
|
||||
|
||||
OnMessageEvent("NFCHeadConfig_ReadOpampOutput........Start");
|
||||
|
||||
while (retryCounter++ <= NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_opr_read_req_msg) + "=0x" + Tools.ByteArrayToHexString(NFCHeadConfig_opr_read_req_msg));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_opr_read_req_msg));
|
||||
if (_SERIAL_Driver.SendMessage(NFCHeadConfig_opr_read_req_msg, NFCHeadConfig_opr_read_req_msg.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_opr_read_res_msg[0]) && (bytesReceived[1] == NFCHeadConfig_opr_read_res_msg[1]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
//'OP' received as first 2 charaters in the response. 3rd to 6th are hex digits of OP_OUT from MSB to LSB respectively
|
||||
temp = AsciiToHex(bytesReceived[2]);
|
||||
retVal = (ushort)(temp << 12);
|
||||
temp = AsciiToHex(bytesReceived[3]);
|
||||
retVal += (ushort)(temp << 8);
|
||||
temp = AsciiToHex(bytesReceived[4]);
|
||||
retVal += (ushort)(temp << 4);
|
||||
temp = AsciiToHex(bytesReceived[5]);
|
||||
retVal += temp;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (retVal == 0)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadOpampOutput........Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadOpampOutput: " + retVal + " ........Success");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return retVal; // 0 - failed, any other value is gain
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_SetGain(byte gain)
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
bool bRetVal = false;
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
bRetVal = false;
|
||||
OnMessageEvent("NFCHeadConfig_SetGain........Failed");
|
||||
return bRetVal; // true - success, false - failed
|
||||
}
|
||||
|
||||
OnMessageEvent("NFCHeadConfig_SetGain........Start");
|
||||
|
||||
NFCHeadConfig_gw_write_req_msg[2] = HexToAscii((byte)((gain & 0xF0) >> 4)); //Higher nibble of gain
|
||||
NFCHeadConfig_gw_write_req_msg[3] = HexToAscii((byte)(gain & 0x0F)); //Lower nibble of gain
|
||||
while (retryCounter++ <= NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_gw_write_req_msg) + "=0x" + Tools.ByteArrayToHexString(NFCHeadConfig_gw_write_req_msg));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_gw_write_req_msg));
|
||||
if (_SERIAL_Driver.SendMessage(NFCHeadConfig_gw_write_req_msg, NFCHeadConfig_gw_write_req_msg.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_OK_res_msg[0]) && (bytesReceived[1] == NFCHeadConfig_OK_res_msg[1])
|
||||
&& (bytesReceived[2] == NFCHeadConfig_OK_res_msg[2]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
//'OK\n' received
|
||||
bRetVal = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (bRetVal)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_SetGain........Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_SetGain........Failed");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
public byte NFCHeadConfig_ReadGain()
|
||||
{
|
||||
byte temp = 0;
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
byte retVal = 0; // 0 - failed, any other value is gain
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
retVal = 0;
|
||||
OnMessageEvent("NFCHeadConfig_ReadGain........Failed");
|
||||
return retVal; // 0 - failed, any other value is gain
|
||||
}
|
||||
|
||||
OnMessageEvent("NFCHeadConfig_ReadGain........Start");
|
||||
|
||||
//NFC head is in command mode
|
||||
while (retryCounter++ <= NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_gr_read_req_msg) + "=0x" + Tools.ByteArrayToHexString(NFCHeadConfig_gr_read_req_msg));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_gr_read_req_msg));
|
||||
if (_SERIAL_Driver.SendMessage(NFCHeadConfig_gr_read_req_msg, NFCHeadConfig_gr_read_req_msg.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_gr_read_res_msg[0]) && (bytesReceived[1] == NFCHeadConfig_gr_read_res_msg[1])
|
||||
&& (bytesReceived[4] == NFCHeadConfig_gr_read_res_msg[4]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
//'GR' received as first 2 charaters in the response. 3rd and 4th are gain as hex digits
|
||||
temp = AsciiToHex(bytesReceived[2]);
|
||||
retVal = (byte)(temp << 4);
|
||||
temp = AsciiToHex(bytesReceived[3]);
|
||||
retVal += temp; // 0 - failed, any other value is gain
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (retVal == 0)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadGain........Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadGain: " + retVal + " ........Success");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return retVal; // 0 - failed, any other value is gain
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_SetInterface(bool value)
|
||||
{
|
||||
byte[] bytesTransmit;
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
bool bRetVal = false;
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
bRetVal = false;
|
||||
OnMessageEvent("NFCHeadConfig_SetInterface........Failed");
|
||||
return bRetVal; // true - success, false - failed
|
||||
}
|
||||
|
||||
//NFC head is in command mode
|
||||
if (value) //true - NFC, false - RFID
|
||||
{
|
||||
bytesTransmit = NFCHeadConfig_cnfc_req_msg;
|
||||
OnMessageEvent("NFCHeadConfig_SetInterface: NFC........Start");
|
||||
}
|
||||
else
|
||||
{
|
||||
bytesTransmit = NFCHeadConfig_crfid_req_msg;
|
||||
OnMessageEvent("NFCHeadConfig_SetInterface: RFID........Start");
|
||||
}
|
||||
|
||||
while (retryCounter++ <= NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(bytesTransmit) + "=0x" + Tools.ByteArrayToHexString(bytesTransmit));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(bytesTransmit));
|
||||
if (_SERIAL_Driver.SendMessage(bytesTransmit, bytesTransmit.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_OK_res_msg[0]) && (bytesReceived[1] == NFCHeadConfig_OK_res_msg[1])
|
||||
&& (bytesReceived[2] == NFCHeadConfig_OK_res_msg[2]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
//'OK\n' received
|
||||
bRetVal = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (bRetVal)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_SetInterface........Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_SetInterface........Failed");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
public byte NFCHeadConfig_ReadInterface()
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
byte retVal = 0; // 0 - failed, 1 - NFC, 2 - RFID
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
retVal = 0;
|
||||
OnMessageEvent("NFCHeadConfig_ReadInterface........Failed");
|
||||
return retVal; // 0 - failed, any other value is gain
|
||||
}
|
||||
|
||||
OnMessageEvent("NFCHeadConfig_ReadInterface........Start");
|
||||
|
||||
//NFC head is in command mode
|
||||
while (retryCounter++ < NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_ir_read_req_msg) + "=0x" + Tools.ByteArrayToHexString(NFCHeadConfig_ir_read_req_msg));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_ir_read_req_msg));
|
||||
if (_SERIAL_Driver.SendMessage(NFCHeadConfig_ir_read_req_msg, NFCHeadConfig_ir_read_req_msg.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_ir_read_res_msg_nfc[0]) && (bytesReceived[1] == NFCHeadConfig_ir_read_res_msg_nfc[1])
|
||||
&& (bytesReceived[2] == NFCHeadConfig_ir_read_res_msg_nfc[2]) && (bytesReceived[3] == NFCHeadConfig_ir_read_res_msg_nfc[3]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
retVal = 1; // 0 - failed, 1 - NFC, 2 - RFID
|
||||
break;
|
||||
}
|
||||
else if ((bytesReceived[0] == NFCHeadConfig_ir_read_res_msg_rfid[0]) && (bytesReceived[1] == NFCHeadConfig_ir_read_res_msg_rfid[1])
|
||||
&& (bytesReceived[2] == NFCHeadConfig_ir_read_res_msg_rfid[2]) && (bytesReceived[3] == NFCHeadConfig_ir_read_res_msg_rfid[3])
|
||||
&& (bytesReceived[4] == NFCHeadConfig_ir_read_res_msg_rfid[4]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
retVal = 2; // 0 - failed, 1 - NFC, 2 - RFID
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (retVal == 0)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadInterface........Failed");
|
||||
}
|
||||
else if (retVal == 1)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadInterface: NFC ........Success");
|
||||
}
|
||||
else if (retVal == 2)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadInterface: RFID ........Success");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return retVal; // 0 - failed, 1 - NFC, 2 - RFID
|
||||
}
|
||||
|
||||
public byte[] NFCHeadConfig_ReadFirmwareVersion()
|
||||
{
|
||||
byte[] bytesReceived = { 0 };
|
||||
int retryCounter = 0;
|
||||
|
||||
//Switching off data mode (means command mode is on)
|
||||
if (NFCHeadConfig_cmd_tx(NFCHeadConfig_cdoff_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES) == false)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadFirmwareVersion........Failed");
|
||||
return bytesReceived; // 0 - failed
|
||||
}
|
||||
|
||||
OnMessageEvent("NFCHeadConfig_ReadFirmwareVersion........Start");
|
||||
|
||||
//NFC head is in command mode
|
||||
while (retryCounter++ <= NFC_HEAD_CONFIG_MAX_RETRIES)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_fr_read_req_msg) + "=0x" + Tools.ByteArrayToHexString(NFCHeadConfig_fr_read_req_msg));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(NFCHeadConfig_fr_read_req_msg));
|
||||
if (_SERIAL_Driver.SendMessage(NFCHeadConfig_fr_read_req_msg, NFCHeadConfig_fr_read_req_msg.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if (bytesReceived[0] == NFCHeadConfig_fr_read_res_msg[0])
|
||||
{
|
||||
//'V' is received as first character in the response. So, the firmware version string is followed and ended with '\n'
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (bytesReceived[0] == 0)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadFirmwareVersion........Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_ReadFirmwareVersion........Success");
|
||||
}
|
||||
|
||||
//Switching data mode on (means command mode is off)
|
||||
NFCHeadConfig_cmd_tx(NFCHeadConfig_cdon_req_msg, NFC_HEAD_CONFIG_MAX_RETRIES);
|
||||
|
||||
return bytesReceived; // 0 - failed, any other value is firmware version
|
||||
}
|
||||
private bool NFCHeadConfig_cmd_tx(byte[] requestTxMessage, int retries)
|
||||
{
|
||||
byte[] bytesReceived;
|
||||
int retryCounter = 0;
|
||||
bool bRetVal = false;
|
||||
|
||||
if (requestTxMessage == NFCHeadConfig_cpon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cpon........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdoff_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdoff........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdon........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cnfc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cnfc........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crfid_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crfid........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cadc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cadc........Start");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crst_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crst........Start");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cmd_tx: unidentified command........Failed");
|
||||
bRetVal = false;
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
while (++retryCounter <= retries)
|
||||
{
|
||||
//OnMessageEvent("Tx- " + Encoding.ASCII.GetString(requestTxMessage) + "=0x" + Tools.ByteArrayToHexString(requestTxMessage));
|
||||
OnMessageEvent("Tx- " + Encoding.ASCII.GetString(requestTxMessage));
|
||||
if (_SERIAL_Driver.SendMessage(requestTxMessage, requestTxMessage.Length))
|
||||
{
|
||||
bytesReceived = _SERIAL_Driver.GetRawData();
|
||||
//OnMessageEvent("Rx- " + Encoding.ASCII.GetString(bytesReceived) + "=0x" + Tools.ByteArrayToHexString(bytesReceived));
|
||||
if ((bytesReceived[0] == NFCHeadConfig_OK_res_msg[0]) && (bytesReceived[1] == NFCHeadConfig_OK_res_msg[1])
|
||||
&& (bytesReceived[2] == NFCHeadConfig_OK_res_msg[2]))
|
||||
{
|
||||
OnMessageEvent("Rx- " + Encoding.ASCII.GetString(NFCHeadConfig_OK_res_msg));
|
||||
//'OK\n' received
|
||||
bRetVal = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
if (bRetVal == true)
|
||||
{
|
||||
if (requestTxMessage == NFCHeadConfig_cpon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cpon........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdoff_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdoff........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdon........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cnfc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cnfc........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crfid_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crfid........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cadc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cadc........Success");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crst_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crst........Success");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (requestTxMessage == NFCHeadConfig_cpon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cpon........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdoff_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdoff........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cdon_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cdon........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cnfc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cnfc........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crfid_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crfid........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_cadc_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_cadc........Failed");
|
||||
}
|
||||
else if (requestTxMessage == NFCHeadConfig_crst_req_msg)
|
||||
{
|
||||
OnMessageEvent("NFCHeadConfig_crst........Failed");
|
||||
}
|
||||
}
|
||||
return bRetVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,550 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public sealed class NfcDataHandler
|
||||
{
|
||||
private string _ComPort = "";
|
||||
private readonly byte[] readCommand = { 0x80, 0x08, 0x00, 0x03, 0x00, 0x00 };
|
||||
|
||||
public SERIAL_Driver _SERIAL_Driver;
|
||||
public SERIAL_Driver _SERIAL_Driver_Head_Config;
|
||||
|
||||
public CR95HF_Reader _CR95HF_Reader;
|
||||
public ST25DV_Device _ST25DV_Device;
|
||||
public MCI_Protocol _MCI_Protocol;
|
||||
public NFCHeadConfig _NFCHead_Config;
|
||||
|
||||
public byte LastErrorCode { get; set; }
|
||||
public string LastErrorMessage { get; set; }
|
||||
public byte[] LastData { get; set; }
|
||||
|
||||
public event DelNfcMessageHandler MessageEvent;
|
||||
|
||||
public NfcDataHandler()
|
||||
{
|
||||
_SERIAL_Driver = new SERIAL_Driver();
|
||||
_SERIAL_Driver_Head_Config = new SERIAL_Driver();
|
||||
_CR95HF_Reader = new CR95HF_Reader(_SERIAL_Driver);
|
||||
_ST25DV_Device = new ST25DV_Device(_CR95HF_Reader);
|
||||
_MCI_Protocol = new MCI_Protocol(_ST25DV_Device);
|
||||
_NFCHead_Config = new NFCHeadConfig(_SERIAL_Driver_Head_Config);
|
||||
LastErrorCode = 0;
|
||||
}
|
||||
|
||||
public bool OpenConnection(string comport, int baudrate, int databits, Parity parity, StopBits stopbits)
|
||||
{
|
||||
_ComPort = comport;
|
||||
bool isopen = _SERIAL_Driver.OpenConnection(comport, baudrate, databits, parity, stopbits);
|
||||
if (!isopen) OnMessageEvent(_SERIAL_Driver.ErrorMessage);
|
||||
return isopen;
|
||||
}
|
||||
|
||||
public bool isOpen()
|
||||
{
|
||||
return _SERIAL_Driver.isOpen();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_SERIAL_Driver.Close();
|
||||
_SERIAL_Driver.Dispose();
|
||||
}
|
||||
|
||||
public bool OpenConnectionSTM(string comport)
|
||||
{
|
||||
// helper for lazy people who don't know the comport settings or don't have
|
||||
// parameters of type 'Parity' or 'StopBits' in their language (Python) at hand
|
||||
// used here: https://slm.sms-esaap.com/iPERL/tetoo/-/tree/dev/tetoo/nfcs5_dll_wrapper
|
||||
return OpenConnection(comport, 57600, 8, Parity.None, StopBits.Two);
|
||||
}
|
||||
|
||||
|
||||
public bool NFCHead_OpenConnection(string comport)
|
||||
{
|
||||
if (isOpen() && _ComPort == comport)
|
||||
{
|
||||
OnMessageEvent(comport + "......... Already in use ");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isopen = _SERIAL_Driver_Head_Config.OpenConnection(comport, 9600, 8, Parity.None, StopBits.Two);
|
||||
OnMessageEvent(_SERIAL_Driver_Head_Config.ErrorMessage);
|
||||
return isopen;
|
||||
}
|
||||
|
||||
public bool isNFCHeadOpen()
|
||||
{
|
||||
return _SERIAL_Driver_Head_Config.isOpen();
|
||||
}
|
||||
|
||||
public void NFCHeadClose()
|
||||
{
|
||||
if (_SERIAL_Driver_Head_Config.isOpen())
|
||||
{
|
||||
_SERIAL_Driver_Head_Config.Close();
|
||||
_SERIAL_Driver_Head_Config.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ConnectReader()
|
||||
{
|
||||
if (_CR95HF_Reader.CR95HF_Connect())
|
||||
{
|
||||
OnMessageEvent("CombiHead.......Connected");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("CombiHead.......Not connected");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RFProtocolON()
|
||||
{
|
||||
if (_CR95HF_Reader.CR95HF_RFProtocolOn())
|
||||
{
|
||||
OnMessageEvent("NFC CR95HF RF Protocol ON........Success");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFC CR95HF RF Protocol ON........Failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RFProtocolOFF()
|
||||
{
|
||||
if (_CR95HF_Reader.CR95HF_RFProtocolOff())
|
||||
{
|
||||
OnMessageEvent("NFC CR95HF RF Protocol OFF........Success");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("NFC CR95HF RF Protocol OFF........Failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ConnectDevice()
|
||||
{
|
||||
byte[] responseData;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_RFProtocolOn())
|
||||
{
|
||||
if (GetSystemInfo())
|
||||
{
|
||||
responseData = LastData;
|
||||
if (responseData[0] == 0x0F)
|
||||
OnMessageEvent("Device -> ST25DV04K");
|
||||
else
|
||||
OnMessageEvent("Device -> ST25DV16K or 64K");
|
||||
|
||||
OnMessageEvent("UID -> " + Tools.ByteToHexString(responseData[1]) + " " + Tools.ByteToHexString(responseData[2]) + " " + Tools.ByteToHexString(responseData[3]) + " " + Tools.ByteToHexString(responseData[4]) +
|
||||
" " + Tools.ByteToHexString(responseData[5]) + " " + Tools.ByteToHexString(responseData[6]) + " " + Tools.ByteToHexString(responseData[7]) + " " + Tools.ByteToHexString(responseData[8]));
|
||||
//OnMessageEvent("DSFID -> " + Tools.ByteToHexString(responseData[9]));
|
||||
//OnMessageEvent("AFI -> " + Tools.ByteToHexString(responseData[10]));
|
||||
//OnMessageEvent("Block size -> " + Tools.ByteToHexString(responseData[11]));
|
||||
//OnMessageEvent("Memory size -> " + Tools.ByteToHexString(responseData[12]));
|
||||
//if (responseData[13] == 0x24)
|
||||
// OnMessageEvent("IC Ref -> ST25DV04K");
|
||||
//else
|
||||
// OnMessageEvent("IC Ref -> ST25DV16K or 64K");
|
||||
OnMessageEvent("iPERL.......Connected");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("iPERL.......Not connected");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool GetSystemInfo()
|
||||
{
|
||||
byte[] responseData = null;
|
||||
try
|
||||
{
|
||||
if (_ST25DV_Device.ST25DV_GetSystemInfo(out responseData))
|
||||
{
|
||||
LastData = responseData;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnMessageEvent(ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadSingleBlock(byte blockNumber, out byte[] outBuffer)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_ReadSingleBlock(blockNumber, out outBuffer);
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteSingleBlock(byte blockNumber, byte[] inBuffer)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_WriteSingleBlock(blockNumber, inBuffer);
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMultipleBlocks(byte startingBlockNumber, byte numberOfBlocks, out byte[] OutBuffer)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_ReadMultipleBlocks(startingBlockNumber, numberOfBlocks, out OutBuffer);
|
||||
}
|
||||
|
||||
public bool Echo()
|
||||
{
|
||||
if (!_CR95HF_Reader.CR95HF_Echo())
|
||||
{
|
||||
OnMessageEvent("Echo..Failed. CombiHead connection...Lost");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadConfiguration(byte pointer, out byte value)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_ReadConfiguration(pointer, out value, true);
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadDynamicConfiguration(byte regAddress, out byte OutBuffer)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_ReadDynamicConfiguration(regAddress, out OutBuffer, true);
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteDynamicConfiguration(byte regAddress, byte regValue)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_WriteDynamicConfiguration(regAddress, regValue, true);
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMailboxMessageLength(out byte MessageLength)
|
||||
{
|
||||
return _ST25DV_Device.ST25DV_ReadMailboxMessageLength(out MessageLength, true);
|
||||
}
|
||||
|
||||
// This function-header is needed for calls to the DLL without need for using enums.
|
||||
// In python 3.11 the module pythonnet (v3.x) does not support casting 'int' to 'enum' aynmore,
|
||||
// so this workaround is needed.
|
||||
public bool MCI_Read_pythonwrapper_enum(int STIndex, ushort offset, byte payloadlength, int timeoutMs)
|
||||
{
|
||||
return MCI_Read((MCI_Protocol.StructName)STIndex, offset, payloadlength, timeoutMs);
|
||||
}
|
||||
|
||||
public bool MCI_Read(MCI_Protocol.StructName StName, ushort offset, byte payloadlength, int timeoutMs)
|
||||
{
|
||||
LastErrorMessage = string.Empty;
|
||||
byte[] response;
|
||||
byte errorCode = 0;
|
||||
if (ST25DV_MailboxCommStart())
|
||||
{
|
||||
bool worked = _MCI_Protocol.MCI_Read(StName, offset, payloadlength, timeoutMs, out response, out errorCode);
|
||||
LastErrorCode = errorCode;
|
||||
LastData = response;
|
||||
if (!worked)
|
||||
{
|
||||
SetLastErrorMesage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// This function-header is needed for calls to the DLL without need for using enums.
|
||||
// In python 3.11 the module pythonnet (v3.x) does not support casting 'int' to 'enum' aynmore,
|
||||
// so this workaround is needed.
|
||||
public bool MCI_Write_pythonwrapper_enum(int STIndex, ushort offset, byte payloadlength, byte[] payload, int timeoutMs)
|
||||
{
|
||||
return MCI_Write((MCI_Protocol.StructName)STIndex, offset, payloadlength, payload, timeoutMs);
|
||||
}
|
||||
|
||||
public bool MCI_Write(MCI_Protocol.StructName StName, ushort offset, byte payloadlength, byte[] payload, int timeoutMs)
|
||||
{
|
||||
LastErrorMessage = string.Empty;
|
||||
LastData = null;
|
||||
byte errorCode = 0;
|
||||
if (ST25DV_MailboxCommStart())
|
||||
{
|
||||
bool ans = _MCI_Protocol.MCI_Write(StName, offset, payloadlength, payload, timeoutMs, out errorCode);
|
||||
LastErrorCode = errorCode;
|
||||
if (!ans)
|
||||
{
|
||||
SetLastErrorMesage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool MCI_Write_Read(MCI_Protocol.StructName StName, ushort offset, byte payloadlength, byte[] payload, int timeoutMs)
|
||||
{
|
||||
LastErrorMessage = string.Empty;
|
||||
LastData = null;
|
||||
byte[] response;
|
||||
|
||||
byte errorCode = 0;
|
||||
if (ST25DV_MailboxCommStart())
|
||||
{
|
||||
bool ans = _MCI_Protocol.MCI_Write_Read(StName, offset, payloadlength, payload, out response, timeoutMs, out errorCode);
|
||||
LastErrorCode = errorCode;
|
||||
LastData = response;
|
||||
if (!ans)
|
||||
{
|
||||
SetLastErrorMesage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ST25DV_MailboxCommStart()
|
||||
{
|
||||
// wake up the ST25DV by setting the GPO pin to output a pulse -> INT on Metro (set highest bit to one -> causes a pulse on GPO)
|
||||
if (_ST25DV_Device.ST25DV_WriteGPOManageCommand(_ST25DV_Device.GPO_MANAGE_SET_PULSE, false))
|
||||
{
|
||||
Thread.Sleep(10); // wait 10ms to give metro some time
|
||||
byte MB_Ctrl_Reg_Value = 0x00;
|
||||
for (int i = 0; i < 20; i++) // do 20 retries max (20 times 100ms = 2sec, which should be more than enough)
|
||||
{
|
||||
if (_ST25DV_Device.ST25DV_ReadMailboxControlReg(out MB_Ctrl_Reg_Value))
|
||||
{
|
||||
if ((MB_Ctrl_Reg_Value & 0x01) == 0x01)
|
||||
{
|
||||
return true; //With this we proceed for mailbox communication with ST25
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(100); // wait 100ms, then try again
|
||||
LastErrorMessage = "Mailbox was not activated by Firmware (ST25DV_MailboxCommStart), try again";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(100); // wait 100ms, then try again
|
||||
LastErrorMessage = "Mailbox state could not be read (ST25DV_MailboxCommStart), try again";
|
||||
}
|
||||
}
|
||||
LastErrorCode = 0x08; //MCI Error: Unidentified
|
||||
OnMessageEvent(">> REMARK: Check if Metorlogy firmware-version is at least: 5.1.24 <<");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastErrorCode = 0x08; //MCI Error: Unidentified
|
||||
LastErrorMessage = "GPO config writing failed(ST25DV_MailboxCommStart), try again";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetLastErrorMesage()
|
||||
{
|
||||
try
|
||||
{
|
||||
LastErrorMessage = MCI_Protocol.GetMCIErrorMessage(LastErrorCode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
LastErrorMessage = "MCI Error: The Errorcode '" + LastErrorCode as string +
|
||||
"' couldn't be converted to string with the enum MCI_ErrorCodes!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_PulseLedOutputEnable()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_PulseLedOutputEnable(); // true - success, false - failed
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_DataLedOutputEnable()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_DataLedOutputEnable(); // true - success, false - failed
|
||||
}
|
||||
|
||||
public ushort NFCHeadConfig_ReadOpampOutput()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_ReadOpampOutput(); // 0 - failed, any other value is opamp output
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_SetGain(byte gain)
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_SetGain(gain); // true - success, false - failed
|
||||
}
|
||||
|
||||
public byte NFCHeadConfig_ReadGain()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_ReadGain(); // 0 - failed, any other value is gain
|
||||
}
|
||||
|
||||
public bool NFCHeadConfig_SetInterface(bool value)
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_SetInterface(value); // true - success, false - failed
|
||||
}
|
||||
|
||||
public byte NFCHeadConfig_ReadInterface()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_ReadInterface(); // 0 - failed, 1 - NFC, 2 - RFID
|
||||
}
|
||||
|
||||
public byte[] NFCHeadConfig_ReadFirmwareVersion()
|
||||
{
|
||||
return _NFCHead_Config.NFCHeadConfig_ReadFirmwareVersion(); // 0 - failed, any other value is firmware version
|
||||
}
|
||||
|
||||
public bool NFCSecurity_SendSignedCommand(byte[] payload, int timeoutMs)
|
||||
{
|
||||
byte payloadLength = Convert.ToByte(payload.Length);
|
||||
ushort offset = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ((!MCI_Write(MCI_Protocol.StructName.NfcSecurity, offset, payloadLength, payload, timeoutMs)) || (LastErrorCode != 0x00))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnMessageEvent(ex.Message);
|
||||
}
|
||||
return true; // true - success, false - failed
|
||||
}
|
||||
|
||||
public string NFCSecurity_Read_EndpointId(int timeoutMs)
|
||||
{
|
||||
string result = string.Empty;
|
||||
byte[] payload = readCommand;
|
||||
byte payloadLength = Convert.ToByte(payload.Length);
|
||||
ushort offset = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ((!MCI_Write_Read(MCI_Protocol.StructName.NfcSecurity, offset, payloadLength, payload, timeoutMs)) || (LastErrorCode != 0x00))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnMessageEvent(ex.Message);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//Check response header
|
||||
if (LastData[0] != 0x05 || LastData[1] != 0x00)
|
||||
{
|
||||
LastErrorMessage = "Wrong response header";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//Check length byte
|
||||
if (LastData[2] == 0x00)
|
||||
{
|
||||
LastErrorMessage = "Response length is 0";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//Check length of message
|
||||
int lengthMessage = LastData[2] + 3; // two header bytes and one length byte
|
||||
if (LastData.Length != lengthMessage)
|
||||
{
|
||||
LastErrorMessage = "Response length is wrong";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//Check identifier for information
|
||||
if (LastData[3] != 0x00 || LastData[4] != 0x00)
|
||||
{
|
||||
LastErrorMessage = "Wrong identifier";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
int lengthEndpointId = LastData[2] - 2; //Identifier bytes
|
||||
byte[] id = new byte[lengthEndpointId];
|
||||
Array.Copy(LastData, 5, id, 0, lengthEndpointId);
|
||||
result = Encoding.ASCII.GetString(id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte NFCSecurity_ReadPrivilegeLevel(int timeoutMs)
|
||||
{
|
||||
ushort offset = 0;
|
||||
byte payloadLength = 1;
|
||||
byte payload = 4;
|
||||
try
|
||||
{
|
||||
if ((!MCI_Read(MCI_Protocol.StructName.NfcSecurity, offset, payloadLength, timeoutMs)) || (LastErrorCode != 0x00))
|
||||
{
|
||||
payload = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
payload = LastData[0];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnMessageEvent(ex.Message);
|
||||
}
|
||||
|
||||
return payload; // 0 - No Security, 1 - Customer Maintenance, 2 - Customer Admin, 3 - Sensus Admin, 4 and above - failed
|
||||
}
|
||||
|
||||
public bool NFCSecurity_ClearPrivilegeLevel(int timeoutMs)
|
||||
{
|
||||
ushort offset = 0;
|
||||
byte payloadLength = 1;
|
||||
byte[] payload = { 0x23 }; // 0x23 - Command code for 'NFC Security reset access level'
|
||||
|
||||
try
|
||||
{
|
||||
if ((!MCI_Write(MCI_Protocol.StructName.Command, offset, payloadLength, payload, timeoutMs)) || (LastErrorCode != 0x00))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnMessageEvent(ex.Message);
|
||||
}
|
||||
return true; // true - success, false - failed
|
||||
}
|
||||
|
||||
public string GetDllVersion()
|
||||
{
|
||||
Version dll_version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
return "NfcS5 DLL v" + String.Format("{0}.{1}.{2}", dll_version.Major, dll_version.Minor, dll_version.Build); //, dll_version.MajorRevision);
|
||||
}
|
||||
|
||||
#region Message Event
|
||||
private void OnMessageEvent(string message)
|
||||
{
|
||||
NfcMessageEventArgs e = new NfcMessageEventArgs();
|
||||
e.Message = message;
|
||||
|
||||
if (MessageEvent != null)
|
||||
{
|
||||
MessageEvent(this, e);
|
||||
}
|
||||
e = null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public delegate void DelNfcMessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_ST25DV_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_CR95HF_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_MCI_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public delegate void DelNfc_NFCHeadConfig_MessageHandler(object sender, NfcMessageEventArgs e);
|
||||
public class NfcMessageEventArgs
|
||||
{
|
||||
public string Message;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public class SERIAL_Driver
|
||||
{
|
||||
public string ErrorMessage { get; private set; }
|
||||
public Collection<byte> SerialPortReadBuffer = new Collection<byte>();
|
||||
private SerialPort _serialPort;
|
||||
|
||||
private List<byte[]> _binMessages = new List<byte[]>();
|
||||
private bool _isReading;
|
||||
private Parity Parity { get; set; }
|
||||
private StopBits StopBits { get; set; }
|
||||
|
||||
public SERIAL_Driver()
|
||||
{
|
||||
_serialPort = new SerialPort();
|
||||
}
|
||||
|
||||
public bool OpenConnection(string comPort, int baudrate, int dataBits, Parity parity, StopBits stopbits, int readTimeout=1000, int writeTimeout = 1000)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if ((_serialPort != null) && (_serialPort.IsOpen))
|
||||
{
|
||||
_serialPort.DataReceived -= DataReceivedHandler;
|
||||
_serialPort.Close();
|
||||
_serialPort.Dispose();
|
||||
_serialPort = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
ErrorMessage = "";
|
||||
//_serialPort = new SerialPort(comPort, 57600, Parity.None, 8, StopBits.Two);
|
||||
_serialPort = new SerialPort(comPort, baudrate, parity, dataBits, stopbits);
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
|
||||
_serialPort.Open();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Open failed {0}.{1}", comPort, ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_serialPort.IsOpen)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Can't Open {0}.", comPort);
|
||||
return false;
|
||||
}
|
||||
}//End Lock
|
||||
return true;
|
||||
}
|
||||
public bool SendMessage(byte[] sendDataBytes, int length, int readTimeout = 1000, int writeTimeout=1000)
|
||||
{
|
||||
if (!isOpen()) return false;
|
||||
if (sendDataBytes.Length == 0) return true; // nothing to send - no error
|
||||
try
|
||||
{
|
||||
PrepareReading(); //clear read buffer etc.
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.Write(sendDataBytes, 0, length);
|
||||
_isReading = true;
|
||||
Thread.Sleep(100);
|
||||
var stopWatch = Stopwatch.StartNew(); //start stop watch for data recevie timeout
|
||||
while (_isReading) //wait until reading finishes or timeout occur
|
||||
{
|
||||
if (stopWatch.ElapsedMilliseconds > readTimeout)
|
||||
{
|
||||
stopWatch.Stop();
|
||||
ErrorMessage = "COM error: Receive timeout";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Transmit timeout {0}.{1}", _serialPort.PortName, ex.Message);
|
||||
return false; // Exception in send function
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void PrepareReading()
|
||||
{
|
||||
_serialPort.DiscardInBuffer();
|
||||
if(_binMessages != null) _binMessages.Clear();
|
||||
_isReading = true;
|
||||
}
|
||||
public byte[] GetRawData()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _binMessages[0].ToArray();
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
byte[] err = { 0xFF };
|
||||
return err;
|
||||
}
|
||||
}
|
||||
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
|
||||
{
|
||||
if (!_serialPort.IsOpen) return;
|
||||
lock (this)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
SerialPortReadBuffer = new Collection<byte>();
|
||||
while (_serialPort.BytesToRead > 0)
|
||||
{
|
||||
SerialPortReadBuffer.Add((byte)_serialPort.ReadByte());
|
||||
}
|
||||
|
||||
_binMessages.Add(SerialPortReadBuffer.ToArray());
|
||||
_isReading = false;
|
||||
}
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
if (isOpen())
|
||||
{
|
||||
_serialPort.Close();
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_serialPort != null)
|
||||
{
|
||||
_serialPort.Dispose();
|
||||
}
|
||||
}
|
||||
public bool isOpen()
|
||||
{
|
||||
if(_serialPort != null)
|
||||
return _serialPort.IsOpen;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,433 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public class ST25DV_Device
|
||||
{
|
||||
private readonly byte[] ST25DV_CMD_GET_SYSTEM_INFO = { 0x2B }; //Command code
|
||||
private byte[] ST25DV_CMD_READ_SINGLE_BLOCK = { 0x20, 0x00 }; //Command code, EEPROM block number (this will be received from caller).
|
||||
private byte[] ST25DV_CMD_WRITE_SINGLE_BLOCK = { 0x21, 0x00, 0x00, 0x00, 0x00, 0x00 }; //Command code, EEPROM block number (this will be received from caller), 4-byte payload to be written (this will be received from caller).
|
||||
private byte[] ST25DV_CMD_READ_MULTIPLE_BLOCKS = { 0x23, 0x00, 0x00 }; //Command code, EEPROM starting block number (this will be received from caller), number of blocks (this will be received from caller)
|
||||
private byte[] ST25DV_CMD_READ_CONFIG = { 0xA0, 0x02, 0x00 }; //Command code, IC Mfg Code, Register address (this will be received from caller)
|
||||
private byte[] ST25DV_CMD_READ_DYNAMIC_CONFIG = { 0xAD, 0x02, 0x00 }; //Command code, IC Mfg Code, Register address (this will be received from caller)
|
||||
private byte[] ST25DV_CMD_WRITE_DYNAMIC_CONFIG = { 0xAE, 0x02, 0x00, 0x00 }; //Command code, IC Mfg Code, Register address, register value to be written
|
||||
private readonly byte[] ST25DV_CMD_READ_MAILBOX_CONTROL_REG = { 0xAD, 0x02, 0x0D }; //Command code, IC Mfg Code, MB_CTRL_Dyn Register address
|
||||
private readonly byte[] ST25DV_CMD_READ_MAILBOX_MESSAGE_LENGTH = { 0xAB, 0x02 }; //Command code, IC Mfg Code
|
||||
private byte[] ST25DV_CMD_READ_MESSAGE = { 0xAC, 0x02, 0x00, 0x00 }; //Command code, IC Mfg Code, Mailbox pointer(mostly this is 0), NumberofBytesToRead (this will be received from caller)
|
||||
private byte[] ST25DV_CMD_MANAGE_GPO = { 0xA9, 0x02, 0x00 }; //Command code, IC Mfg Code, GPO value
|
||||
public readonly byte GPO_MANAGE_SET_PULSE = 0x80; // Command code to set a pulse on the GPO pin (if enabled by FW in the Meter)
|
||||
|
||||
private CR95HF_Reader _CR95HF_Reader;
|
||||
private System.Timers.Timer _CycleTimeoutTimer = new System.Timers.Timer();
|
||||
|
||||
private static readonly Dictionary<byte, string> ST25DV_ErrorCodes = new Dictionary<byte, string>
|
||||
{
|
||||
{0x00 , "Success, No error" },
|
||||
{0x01 , "Command is not supported" },
|
||||
{0x02 , "Command is not recognized(format error)" },
|
||||
{0x03 , "Option not supported" },
|
||||
{0x0F , "Error with no information given" },
|
||||
{0x10 , "The specified block is not available" },
|
||||
{0x11 , "The specified block is already locked and thus cannot be locked again" },
|
||||
{0x12 , "The specified block is locked and its contents cannot be changed" },
|
||||
{0x13 , "The specified block was not successfully programmed" },
|
||||
{0x14 , "The specified block was not successfully locked" },
|
||||
{0x15 , "The specified block is protected in read" }
|
||||
};
|
||||
|
||||
public event DelNfc_ST25DV_MessageHandler MessageEvent;
|
||||
|
||||
public ST25DV_Device(CR95HF_Reader CR95HFReader)
|
||||
{
|
||||
_CR95HF_Reader = CR95HFReader;
|
||||
}
|
||||
|
||||
#region Message Event
|
||||
private void OnMessageEvent(string message)
|
||||
{
|
||||
NfcMessageEventArgs e = new NfcMessageEventArgs();
|
||||
e.Message = message;
|
||||
|
||||
if (MessageEvent != null)
|
||||
{
|
||||
MessageEvent(this, e);
|
||||
}
|
||||
e = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool ST25DV_GetSystemInfo(out byte[] responseData)
|
||||
{
|
||||
byte[] response = new byte[20];
|
||||
responseData = null;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_GET_SYSTEM_INFO, out response))
|
||||
{
|
||||
if (response == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//Success - ResponseFlags = 0x00, 14 bytes payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
responseData = new byte[14];
|
||||
for (int i=0; i<14; i++)
|
||||
{
|
||||
responseData[i] = response[i + 1];
|
||||
}
|
||||
//OnMessageEvent("Read GetSystemInfo: " + Tools.ByteArrayToHexString(responseData));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((responseData[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(responseData[1])))
|
||||
OnMessageEvent("Read GetSystemInfo: Failed with ST25DV error - " + ST25DV_ErrorCodes[responseData[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read GetSystemInfo: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadSingleBlock(byte blockNumber, out byte[] outBuffer, bool logEnabled = false)
|
||||
{
|
||||
byte[] response = null;
|
||||
outBuffer = null;
|
||||
int StartingByteAddress = Convert.ToInt32(blockNumber) * 4;
|
||||
|
||||
ST25DV_CMD_READ_SINGLE_BLOCK[1] = blockNumber;
|
||||
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Read EEPROM: 0x04" + " bytes from the address 0x" + Tools.DecimalToHexString(StartingByteAddress.ToString(), 1));
|
||||
}
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_SINGLE_BLOCK, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = new byte[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
outBuffer[i] = response[1 + i];
|
||||
}
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Read EEPROM: " + Tools.BytesToHex(outBuffer));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read EEPROM: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read EEPROM: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteSingleBlock(byte blockNumber, byte[] inBuffer, bool logEnabled = false)
|
||||
{
|
||||
byte[] response = null;
|
||||
int StartingByteAddress = Convert.ToInt32(blockNumber) * 4;
|
||||
|
||||
ST25DV_CMD_WRITE_SINGLE_BLOCK[1] = blockNumber;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ST25DV_CMD_WRITE_SINGLE_BLOCK[2 + i] = inBuffer[i];
|
||||
}
|
||||
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Write EEPROM: 0x04 bytes 0x" + Tools.BytesToHex(inBuffer) + " to the address 0x" + Tools.DecimalToHexString(StartingByteAddress.ToString(), 1));
|
||||
}
|
||||
|
||||
//This will disable MB, 0x0D is MB_CTRL_Dyn register pointer and 0x00 is the value written
|
||||
if (ST25DV_WriteDynamicConfiguration(0x0D, 0x00, false))
|
||||
{
|
||||
_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_WRITE_SINGLE_BLOCK, out response);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessageEvent("Write EEPROM: MB disable failed");
|
||||
return false;
|
||||
}
|
||||
//This function will leave ST25DV with MB disabled state and it needs to be enabled by I2C interface
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMultipleBlocks(byte startingBlockNumber, byte numberOfBlocks, out byte [] outBuffer)
|
||||
{
|
||||
byte[] response = new byte[16]; //Maximum allowed to read is 16 bytes (4 blocks) with this command
|
||||
outBuffer = null;
|
||||
|
||||
ST25DV_CMD_READ_MULTIPLE_BLOCKS[1] = startingBlockNumber;
|
||||
ST25DV_CMD_READ_MULTIPLE_BLOCKS[2] = numberOfBlocks;
|
||||
|
||||
if (Convert.ToInt32(numberOfBlocks) >= 4) //maximum allowed to read with one command is 4 blocks (means 3)
|
||||
{
|
||||
OnMessageEvent("Read EEPROM: Invalid Input"); //TBD-needs to validate startingBlockNumber based on 4K or 16K or 64K chip read info
|
||||
return false;
|
||||
}
|
||||
|
||||
int totalReadBytes = (Convert.ToInt32(numberOfBlocks) + 1) * 4;
|
||||
int StartingByteAddress = Convert.ToInt32(startingBlockNumber) * 4;
|
||||
|
||||
OnMessageEvent("Read EEPROM: " + "0x" + Tools.DecimalToHexString(totalReadBytes.ToString(),1) + " bytes from the byte " + "0x" + Tools.DecimalToHexString(StartingByteAddress.ToString(), 1));
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_MULTIPLE_BLOCKS, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = new byte[response.Length-4];
|
||||
for (int i = 0; i < response.Length-4; i++)
|
||||
{
|
||||
outBuffer[i] = response[1 + i];
|
||||
}
|
||||
OnMessageEvent("Read EEPROM: " + Tools.BytesToHex(outBuffer));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read EEPROM: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read EEPROM: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadConfiguration(byte regAddress, out byte outBuffer, bool logEnabled = false)
|
||||
{
|
||||
byte[] response = null;
|
||||
ST25DV_CMD_READ_CONFIG[2] = regAddress;
|
||||
outBuffer = 0x00;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_CONFIG, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, 1 byte payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = response[1];
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Read Static Config Register @address: " + "0x" + Tools.DecimalToHexString(Convert.ToInt32(regAddress).ToString(), 1) + " as " + Tools.ByteToHexString(outBuffer));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read Static Config Register: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read Static Config Register: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadDynamicConfiguration(byte regAddress, out byte outBuffer, bool logEnabled = false)
|
||||
{
|
||||
byte[] response = null;
|
||||
ST25DV_CMD_READ_DYNAMIC_CONFIG[2] = regAddress;
|
||||
outBuffer = 0x00;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_DYNAMIC_CONFIG, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, 1 byte payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = response[1];
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Read Dynamic Config Register @address: " + "0x" + Tools.DecimalToHexString(Convert.ToInt32(regAddress).ToString(), 1) + " as " + Tools.ByteToHexString(outBuffer));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read Dynamic Config Register: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read Dynamic Config Register: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteGPOManageCommand(byte regValue, bool logEnabled)
|
||||
{
|
||||
byte[] response = null;
|
||||
ST25DV_CMD_MANAGE_GPO[2] = regValue;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_MANAGE_GPO, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, success
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Write GPO Manage: Success");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Write GPO Manage: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Write GPO Manage: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteDynamicConfiguration(byte regAddress, byte regValue, bool logEnabled)
|
||||
{
|
||||
byte[] response = null;
|
||||
ST25DV_CMD_WRITE_DYNAMIC_CONFIG[2] = regAddress;
|
||||
ST25DV_CMD_WRITE_DYNAMIC_CONFIG[3] = regValue;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_WRITE_DYNAMIC_CONFIG, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, success
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Write Dynamic Config Register: Success");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Write Dynamic Config Register: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Write Dynamic Config Register: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMailboxControlReg(out byte outBuffer)
|
||||
{
|
||||
byte[] response = null;
|
||||
outBuffer = 0x00;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_MAILBOX_CONTROL_REG, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, 1 byte payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = response[1];
|
||||
//OnMessageEvent("Read Dynamic Config Register MBCtrl @address: 0x0D" + " as " + Tools.ByteToHexString(outBuffer));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read Dynamic Config Register MBCtrl: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read Dynamic Config Register MBCtrl: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMailboxMessageLength(out byte outBuffer, bool logEnabled = false)
|
||||
{
|
||||
byte[] response = null;
|
||||
outBuffer = 0x00;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_MAILBOX_MESSAGE_LENGTH, out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00, 1 byte payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
outBuffer = response[1];
|
||||
if (logEnabled)
|
||||
{
|
||||
OnMessageEvent("Read Mailbox Message Length: " + Tools.ByteToHexString(outBuffer));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response[0] == 0x01) && (ST25DV_ErrorCodes.ContainsKey(response[1])))
|
||||
OnMessageEvent("Read Mailbox Message Length: Failed with ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
}
|
||||
OnMessageEvent("Read Mailbox Message Length: Failed with ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_ReadMessage(byte bytesToRead, out byte[] outBuffer)
|
||||
{
|
||||
byte[] response = null;
|
||||
outBuffer = null;
|
||||
|
||||
ST25DV_CMD_READ_MESSAGE[2] = 0x00; //Pointer in mailbox, 0x00 indicates reads from beginning
|
||||
ST25DV_CMD_READ_MESSAGE[3] = bytesToRead;
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_READ_MESSAGE, out response))
|
||||
{
|
||||
outBuffer = new byte[response.Length-4];
|
||||
//Success - ResponseFlags = 0x00, payload
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
for (int i = 0; i < response.Length-4; i++)
|
||||
{
|
||||
outBuffer[i] = response[1 + i];
|
||||
}
|
||||
OnMessageEvent("Read Message: " + Tools.BytesToHex(outBuffer));
|
||||
return true;
|
||||
}
|
||||
if ((response[0] == 0x01) && ST25DV_ErrorCodes.ContainsKey(response[1]))
|
||||
OnMessageEvent("Read Message Failed: With ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
OnMessageEvent("Read Message Failed: With ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ST25DV_WriteMessage(byte [] inBuffer)
|
||||
{
|
||||
byte[] response = null;
|
||||
List<byte> ST25DV_CMD_WRITE_MESSAGE = new List<byte>();
|
||||
|
||||
ST25DV_CMD_WRITE_MESSAGE.Add(0xAA); //Write message command code
|
||||
ST25DV_CMD_WRITE_MESSAGE.Add(0x02); //IC Mfg Code
|
||||
ST25DV_CMD_WRITE_MESSAGE.Add(Convert.ToByte(inBuffer.Length - 1)); //This is the app given payload - 1
|
||||
ST25DV_CMD_WRITE_MESSAGE.AddRange(inBuffer);
|
||||
|
||||
if (_CR95HF_Reader.CR95HF_SendRecv(ST25DV_CMD_WRITE_MESSAGE.ToArray(), out response))
|
||||
{
|
||||
//Success - ResponseFlags = 0x00
|
||||
//Error - ResponseFlags = 0x01, 1 byte error code
|
||||
if (response[0] == 0x00)
|
||||
{
|
||||
//OnMessageEvent("Write Message: " + Tools.ByteArrayToHexString(inBuffer));
|
||||
return true;
|
||||
}
|
||||
if ((response[0] == 0x01) && ST25DV_ErrorCodes.ContainsKey(response[1]))
|
||||
OnMessageEvent("Write Message Failed: With ST25DV error - " + ST25DV_ErrorCodes[response[1]]);
|
||||
}
|
||||
OnMessageEvent("Write Message Failed: With ST25DV Unidentified error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.iPerl.NfcHandler
|
||||
{
|
||||
public static class Tools
|
||||
{
|
||||
public static bool ByteArrayCompare(byte[] a1, byte[] a2)
|
||||
{
|
||||
// thanks to https://stackoverflow.com/questions/43289/comparing-two-byte-arrays-in-net
|
||||
if (a1.Length != a2.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < a1.Length; i++)
|
||||
if (a1[i] != a2[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
public static string SwapHex(string sHex)
|
||||
{
|
||||
string sResult = "";
|
||||
int iPos = sHex.Length - 2;
|
||||
while (iPos >= 0)
|
||||
{
|
||||
sResult += sHex.Substring(iPos, 2);
|
||||
sHex = sHex.Remove(iPos, 2);
|
||||
iPos = sHex.Length - 2;
|
||||
}
|
||||
return sResult;
|
||||
}
|
||||
public static string DecimalToHexString(string value, int size = 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
long Lval = long.Parse(value);
|
||||
if (size == 1) return Lval.ToString("X2");
|
||||
if (size == 2) return Lval.ToString("X4");
|
||||
if (size == 4) return Lval.ToString("X8");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (size == 1) return "00";
|
||||
if (size == 2) return "0000";
|
||||
if (size == 4) return "00000000";
|
||||
}
|
||||
return "00";
|
||||
}
|
||||
public static string ByteToHexString(byte data)
|
||||
{
|
||||
List<byte> val = new List<byte>();
|
||||
val.Add(data);
|
||||
byte[] arr = val.ToArray();
|
||||
return BytesToHex(arr);
|
||||
}
|
||||
public static string BytesToHex(byte[] data)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (byte b in data)
|
||||
sb.Append(b.ToString("X2"));
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
}
|
||||
public static byte[] HexStringToByteArray(String hexString)
|
||||
{
|
||||
int numberChars = hexString.Length;
|
||||
byte[] bytes = new byte[numberChars / 2];
|
||||
for (int i = 0; i < numberChars; i += 2)
|
||||
{
|
||||
bytes[i / 2] = Convert.ToByte(hexString.Substring(i, 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
public enum InitialCrcValue
|
||||
{
|
||||
Zeros,
|
||||
NonZero1 = 0xffff,
|
||||
NonZero2 = 0x1D0F
|
||||
}
|
||||
|
||||
public class Crc16Ccitt
|
||||
{
|
||||
private const ushort poly = 0x1021;
|
||||
ushort[] table = new ushort[256];
|
||||
ushort initialValue = 0;
|
||||
|
||||
public ushort ComputeChecksum(byte[] bytes)
|
||||
{
|
||||
ushort crc = this.initialValue;
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
crc = (ushort)((crc << 8) ^ table[((crc >> 8) ^ (0xff & bytes[i]))]);
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
public byte[] ComputeChecksumBytes(byte[] bytes)
|
||||
{
|
||||
ushort crc = ComputeChecksum(bytes);
|
||||
return BitConverter.GetBytes(crc);
|
||||
}
|
||||
public Crc16Ccitt(InitialCrcValue initialValue)
|
||||
{
|
||||
this.initialValue = (ushort) initialValue;
|
||||
ushort temp, a;
|
||||
for (int i = 0; i < table.Length; ++i)
|
||||
{
|
||||
temp = 0;
|
||||
a = (ushort) (i << 8);
|
||||
for (int j = 0; j < 8; ++j)
|
||||
{
|
||||
if (((temp ^ a) & 0x8000) != 0)
|
||||
{
|
||||
temp = (ushort) ((temp << 1) ^ poly);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp <<= 1;
|
||||
}
|
||||
a <<= 1;
|
||||
}
|
||||
table[i] = temp;
|
||||
}
|
||||
}
|
||||
public byte[] calcCRCfromMessage(byte[] message)
|
||||
{
|
||||
// CRC calculation goes from MessageID to Password
|
||||
// For Read this means MsgID (1) + Offset (2) + PayloadLength (1) + Password (2) = 6
|
||||
// for write the length of the payload comes on top.
|
||||
// STX(1), length(1), CRC(2) and ETX(1) are excluded, in total 5 bytes.
|
||||
//
|
||||
// the method works both for sending messages (where the CRC and ETX are not in message)
|
||||
// and for receiving messages (where the CRC and ETX are included at the end)
|
||||
byte[] crc_msg = new byte[message[1]]; // message length is 2nd byte
|
||||
Array.Copy(message, 2, crc_msg, 0, crc_msg.Length);
|
||||
return ComputeChecksumBytes(crc_msg);
|
||||
}
|
||||
public string commentCRC(byte[] crc_meter, byte[] crc_computed)
|
||||
{
|
||||
bool crc_do_match = Tools.ByteArrayCompare(crc_meter, crc_computed);
|
||||
string crcComment = crc_do_match ? "ok." : "CRC DOESN'T MATCH!!";
|
||||
return "CRC Meter: " + Tools.BytesToHex(crc_meter) + (crc_do_match ? " == " : " != ")
|
||||
+ "CRC Computed: " + Tools.BytesToHex(crc_computed) + ". " + crcComment;
|
||||
}
|
||||
public bool crc_do_match(byte[] a, byte[] b)
|
||||
{
|
||||
return ByteArrayCompare(a, b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.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>{5954D496-CAAB-4F7A-BDE2-BDC8F47DAB19}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Sensus.iPerl</RootNamespace>
|
||||
<AssemblyName>NfcS5_DLL</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NfcHandler\CR95HF_Reader.cs" />
|
||||
<Compile Include="NfcHandler\MCI_Protocol.cs" />
|
||||
<Compile Include="NfcHandler\NfcDataHandler.cs" />
|
||||
<Compile Include="NfcHandler\NFCHeadConfig.cs" />
|
||||
<Compile Include="NfcHandler\NfcMessageEventArgs.cs" />
|
||||
<Compile Include="NfcHandler\SERIAL_Driver.cs" />
|
||||
<Compile Include="NfcHandler\ST25DV_Device.cs" />
|
||||
<Compile Include="NfcHandler\Tools.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</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>
|
||||
@@ -0,0 +1 @@
|
||||
Test StartTime: when? Start of flow set or start of real test?
|
||||
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public class BatchResults
|
||||
{
|
||||
public readonly int WMPositionsCount;
|
||||
|
||||
public IList<Entities.TestData> TestDataList;
|
||||
public IList<Entities.Components> ComponentsList;
|
||||
public IList<Entities.WaterMeterData> WaterMeterDataList;
|
||||
|
||||
private BatchResults(int wmPositionsCount)
|
||||
{
|
||||
WMPositionsCount = wmPositionsCount;
|
||||
|
||||
TestDataList = new List<Entities.TestData>();
|
||||
ComponentsList = new List<Entities.Components>();
|
||||
WaterMeterDataList = new List<Entities.WaterMeterData>();
|
||||
}
|
||||
|
||||
|
||||
public Batch Batch;
|
||||
public WaterMeter[] WaterMeters;
|
||||
|
||||
public static BatchResults NewFromProcedure(int batchNr, int benchId, string user, string programVer,
|
||||
Config.Entities.Procedure procedure,
|
||||
WaterMeterData[] waterMeterDatas, int[] waterMeterParts)
|
||||
{
|
||||
BatchResults d = new BatchResults(waterMeterDatas.Length);
|
||||
int year = DateTime.Now.Year;
|
||||
|
||||
/// Create new batch
|
||||
d.Batch = new Batch()
|
||||
{
|
||||
TestBenchId = benchId,
|
||||
BatchNr = batchNr,
|
||||
ProgramVersion = programVer,
|
||||
UserName = user,
|
||||
ProcedureName = procedure.Name,
|
||||
ProcedureDescription = procedure.Description,
|
||||
WatermetersStr = procedure.Watermeters,
|
||||
ProcedureRevision = procedure.Revision,
|
||||
ProtocolTitle = procedure.ProtocolTitle,
|
||||
StartTime = DateTime.Now,
|
||||
Compound = (procedure.MetersKind == Config.Entities.MetersKind.Combined),
|
||||
#if HEAT_METERS_SUPPORT
|
||||
HeatMeter = (procedure.MetersKind == Config.Entities.MetersKind.HeatMeter),
|
||||
#endif
|
||||
};
|
||||
|
||||
///
|
||||
/// Add watermeter to an array, array index is WM position.
|
||||
/// AddWaterMetersToBatch() has to be used before saving results.
|
||||
///
|
||||
d.WaterMeters = new WaterMeter[d.WMPositionsCount];
|
||||
for (int i = 0; i < d.WMPositionsCount; i++)
|
||||
{
|
||||
if (waterMeterDatas[i] == null) continue;
|
||||
WaterMeterData wmd = WaterMeterData.UpdateList(d.WaterMeterDataList, waterMeterDatas[i]);
|
||||
d.WaterMeters[i] = new WaterMeter()
|
||||
{
|
||||
Batch = d.Batch,
|
||||
WaterMeterData = wmd,
|
||||
WMPosition = i + 1,
|
||||
YearOfProduction = year,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
foreach (var t in procedure.Tests)
|
||||
{
|
||||
if (t.Publish != (byte)Config.Entities.Publish.Never)
|
||||
{
|
||||
TestData td = TestData.UpdateList(d.TestDataList, new TestData(t));
|
||||
|
||||
for (int rnr = 1; rnr <= t.Repeats; rnr++)
|
||||
{
|
||||
/// Create an empty test result and add it to the list
|
||||
TestRslt tr = new TestRslt(d.Batch, td, t.Part, rnr);
|
||||
d.Batch.TestRslts.Add(tr);
|
||||
|
||||
for (int i = 0; i < d.WMPositionsCount; i++)
|
||||
{
|
||||
if (d.WaterMeters[i] == null) continue;
|
||||
|
||||
if (t.Part != 0 && waterMeterParts[i] != 0 && t.Part != waterMeterParts[i]) continue;
|
||||
|
||||
/// Create empty watermeter test results and add them to the list and to dictionaries
|
||||
if (!d.Batch.Compound)
|
||||
{
|
||||
MeterTestRslt mtr = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Single);
|
||||
d.WaterMeters[i].MeterTestRslts.Add(mtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
MeterTestRslt mainMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundMain);
|
||||
d.WaterMeters[i].MeterTestRslts.Add(mainMTR);
|
||||
|
||||
MeterTestRslt auxMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.CompoundAux);
|
||||
d.WaterMeters[i].MeterTestRslts.Add(auxMTR);
|
||||
|
||||
MeterTestRslt cmpdMTR = new MeterTestRslt(d.WaterMeters[i], tr, Config.Entities.CompoundMeterId.Compound);
|
||||
d.WaterMeters[i].MeterTestRslts.Add(cmpdMTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public static BatchResults FromBatch(Batch batch)
|
||||
{
|
||||
int wmCount = batch.WaterMeters.Count;
|
||||
if (wmCount == 0) return null;
|
||||
|
||||
BatchResults batchResults = new BatchResults(wmCount);
|
||||
batchResults.Batch = batch;
|
||||
batchResults.WaterMeters = new WaterMeter[wmCount];
|
||||
for (int i = 0; i < wmCount; i++) batchResults.WaterMeters[i] = batch.WaterMeters[i];
|
||||
|
||||
return batchResults;
|
||||
}
|
||||
|
||||
public TestRslt GetTestRslt(string name, int part)
|
||||
{
|
||||
return Batch.GetTestRslt(name, part);
|
||||
}
|
||||
|
||||
public MeterTestRslt GetMeterTestRslt(string name, int wmnr0, Config.Entities.CompoundMeterId meterId)
|
||||
{
|
||||
if (WaterMeters[wmnr0] != null)
|
||||
{
|
||||
return WaterMeters[wmnr0].GetMeterTestRslt(name, meterId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when all tests were done
|
||||
/// </summary>
|
||||
/// <returns>true = all tests done</returns>
|
||||
public bool AllTestsDone()
|
||||
{
|
||||
for (int i = 0; i < WMPositionsCount; i++)
|
||||
{
|
||||
if (WaterMeters[i] != null)
|
||||
{
|
||||
foreach (var mtr in WaterMeters[i].MeterTestRslts)
|
||||
{
|
||||
if (!mtr.TestDone) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds non-null water meters from an array to a Batch water meters list.
|
||||
/// This method should be used when results are prepared and
|
||||
/// all disabled water meters are deleted.
|
||||
/// </summary>
|
||||
public void AddWaterMetersToBatch()
|
||||
{
|
||||
for (int i = 0; i < WMPositionsCount; i++)
|
||||
{
|
||||
if (WaterMeters[i] != null)
|
||||
{
|
||||
WaterMeters[i].Passed = WaterMeters[i].PassedFromTests();
|
||||
if (!WaterMeters[i].Disabled)
|
||||
{
|
||||
Batch.WaterMeters.Add(WaterMeters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public static class DB
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(DB));
|
||||
|
||||
/// <summary> Session factory for all regular sessions, not for CreateEmptyResultsDB(). </summary>
|
||||
public static ISessionFactory SessionFactory;
|
||||
|
||||
/// <summary> Connection string for all sessions </summary>
|
||||
private static string connectionString;
|
||||
///
|
||||
public static string ConnectionString
|
||||
{
|
||||
get { return connectionString; }
|
||||
set { connectionString = value; SessionFactory = null; }
|
||||
}
|
||||
|
||||
/// <summary> Database type (MySQL or SQLite) for all sessions </summary>
|
||||
private static Config.Entities.DBType dbType;
|
||||
///
|
||||
public static Config.Entities.DBType DbType
|
||||
{
|
||||
get { return dbType; }
|
||||
set { dbType = value; SessionFactory = null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <returns>A database session</returns>
|
||||
static ISessionFactory CreateSessionFactory()
|
||||
{
|
||||
return CreateSessionFactory(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NHibernate session factory (to create the database session 'SessionFactory')
|
||||
/// </summary>
|
||||
/// <param name="createDB">true = Create a new DB, false = Regular DB</param>
|
||||
/// <returns>A database session</returns>
|
||||
public static ISessionFactory CreateSessionFactory(bool createDB)
|
||||
{
|
||||
FluentConfiguration cfg = Fluently.Configure();
|
||||
|
||||
switch (dbType)
|
||||
{
|
||||
default:
|
||||
case Config.Entities.DBType.SQLite:
|
||||
cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
|
||||
break;
|
||||
case Config.Entities.DBType.MySql:
|
||||
cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
|
||||
break;
|
||||
}
|
||||
|
||||
cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entities.WaterMeterData>());
|
||||
|
||||
if (createDB)
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
static void BuildSchema(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
|
||||
new SchemaExport(config).SetOutputFile("db_schema");
|
||||
}
|
||||
|
||||
static void BuildSchemaCreate(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration with mapping info and exports a database schema
|
||||
new SchemaExport(config).Create(true, true);
|
||||
}
|
||||
|
||||
/// Create a NHibernate session for the given database
|
||||
public static ISession CreateSession()
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
throw new Exception("Connection string was not specified");
|
||||
}
|
||||
|
||||
if (SessionFactory == null) SessionFactory = CreateSessionFactory();
|
||||
|
||||
return SessionFactory.OpenSession();
|
||||
}
|
||||
|
||||
|
||||
public static void SaveObject(object obj)
|
||||
{
|
||||
SaveObject(CreateSession(), obj);
|
||||
}
|
||||
///
|
||||
public static void SaveObject(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.SaveOrUpdate(obj);
|
||||
try { transaction.Commit(); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteObject(object obj)
|
||||
{
|
||||
DeleteObject(CreateSession(), obj);
|
||||
}
|
||||
///
|
||||
public static void DeleteObject(ISession session, object obj)
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
session.Delete(obj);
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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 CreateEmptyDB()
|
||||
{
|
||||
ISessionFactory sessionFactory = CreateSessionFactory(true);
|
||||
if (sessionFactory == null) return false;
|
||||
|
||||
/// Populate the database
|
||||
using (var session = sessionFactory.OpenSession())
|
||||
{
|
||||
using (var transaction = session.BeginTransaction())
|
||||
{
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Shared data
|
||||
/// </summary>
|
||||
public static IList<Entities.TestData> TestDataList;
|
||||
public static IList<Entities.Components> ComponentsList;
|
||||
public static IList<Entities.WaterMeterData> WaterMeterDataList;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads shared data from the database
|
||||
/// </summary>
|
||||
/// <exception>Throws NHibernate exceptions</exception>
|
||||
public static void LoadSharedData()
|
||||
{
|
||||
ISession session = DB.CreateSession();
|
||||
|
||||
TestDataList = session.CreateQuery("FROM TestData").List<Entities.TestData>();
|
||||
ComponentsList = session.CreateQuery("FROM Components").List<Entities.Components>();
|
||||
WaterMeterDataList = session.CreateQuery("FROM WaterMeterData").List<Entities.WaterMeterData>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update TestData, Components and WaterMeterData fo tests and water meters in batch results
|
||||
/// with existing data in static lists TestDataList, ComponentsList and WaterMeterDataList.
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch results</param>
|
||||
/// <returns>true when any data modiifed</returns>
|
||||
public static bool UpdateBatchData(Entities.Batch batch)
|
||||
{
|
||||
ISession session = DB.CreateSession();
|
||||
|
||||
if (session == null) return false;
|
||||
|
||||
foreach (var tr in batch.TestRslts)
|
||||
{
|
||||
/// Search in TestDataList and update test data in the new batch
|
||||
TestData td = TestData.UpdateList(TestDataList, tr.TestData);
|
||||
tr.TestData = td;
|
||||
|
||||
/// Search in ComponentsList and update components in the new batch
|
||||
Components cd = Components.UpdateList(ComponentsList, tr.Components);
|
||||
tr.Components = cd;
|
||||
}
|
||||
|
||||
foreach (var wm in batch.WaterMeters)
|
||||
{
|
||||
/// Search in WaterMeterDataList and update water meter data in the new batch
|
||||
WaterMeterData wmd = WaterMeterData.UpdateList(WaterMeterDataList, wm.WaterMeterData);
|
||||
wm.WaterMeterData = wmd;
|
||||
}
|
||||
|
||||
return true; /// TODO: Really check for modifications
|
||||
}
|
||||
|
||||
|
||||
public static bool SaveNewBatch(Entities.Batch batch)
|
||||
{
|
||||
ISession session = DB.CreateSession();
|
||||
if (session == null) return false;
|
||||
|
||||
TestDataList = session.CreateQuery("FROM TestData").List<Entities.TestData>();
|
||||
ComponentsList = session.CreateQuery("FROM Components").List<Entities.Components>();
|
||||
WaterMeterDataList = session.CreateQuery("FROM WaterMeterData").List<Entities.WaterMeterData>();
|
||||
|
||||
UpdateBatchData(batch);
|
||||
|
||||
ITransaction transaction = session.BeginTransaction();
|
||||
if (transaction == null) return false;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var td in TestDataList) if (td.Id == 0) session.SaveOrUpdate(td);
|
||||
foreach (var cd in ComponentsList) if (cd.Id == 0) session.SaveOrUpdate(cd);
|
||||
foreach (var wd in WaterMeterDataList) if (wd.Id == 0) session.SaveOrUpdate(wd);
|
||||
|
||||
session.SaveOrUpdate(batch);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
transaction.Rollback();
|
||||
log.FatalFormat("Saving results of batch #{0} into the results DB failed: {1}", batch.BatchNr, exc.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
session.Flush();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class Batch
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int BatchNr { get; set; }
|
||||
public virtual int TestBenchId { get; set; }
|
||||
public virtual string ProgramVersion { get; set; }
|
||||
public virtual string UserName { get; set; }
|
||||
public virtual int UserNumber { get; set; }
|
||||
public virtual string ProcedureName { get; set; }
|
||||
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual int ProcedureRevision { get; set; }
|
||||
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
|
||||
public virtual string ProtocolTitle { get; set; }
|
||||
public virtual string Remark { get; set; }
|
||||
public virtual float Custom1 { get; set; }
|
||||
public virtual float Custom2 { get; set; }
|
||||
public virtual float Custom3 { get; set; }
|
||||
public virtual DateTime StartTime { get; set; }
|
||||
public virtual DateTime EndTime { get; set; }
|
||||
public virtual bool RsltsSent { get; set; }
|
||||
public virtual bool RsltsPrinted { get; set; }
|
||||
public virtual IList<TestData> Tests { get; set; }
|
||||
public virtual IList<WaterMeter> WaterMeters { get; set; }
|
||||
public virtual IList<TestRslt> TestRslts { get; set; }
|
||||
public virtual bool Compound { get; set; } /// Not mapped to DB now
|
||||
#if HEAT_METERS_SUPPORT
|
||||
public virtual bool HeatMeter { get; set; } /// Not mapped to DB now
|
||||
#endif
|
||||
|
||||
public Batch()
|
||||
{
|
||||
Tests = new List<TestData>();
|
||||
WaterMeters = new List<WaterMeter>();
|
||||
TestRslts = new List<TestRslt>();
|
||||
}
|
||||
|
||||
public virtual float AmbientTempAve()
|
||||
{
|
||||
if (TestRslts.Count == 0) return 0;
|
||||
float sum = 0;
|
||||
foreach (var tr in TestRslts) sum += tr.AmbientTempAve;
|
||||
return sum / TestRslts.Count;
|
||||
}
|
||||
|
||||
public virtual float AmbientPressAve()
|
||||
{
|
||||
if (TestRslts.Count == 0) return 0;
|
||||
float sum = 0;
|
||||
foreach (var tr in TestRslts) sum += tr.AmbientPressAve;
|
||||
return sum / TestRslts.Count;
|
||||
}
|
||||
|
||||
public virtual float AmbientHumiAve()
|
||||
{
|
||||
if (TestRslts.Count == 0) return 0;
|
||||
float sum = 0;
|
||||
foreach (var tr in TestRslts) sum += tr.AmbientHumiAve;
|
||||
return sum / TestRslts.Count;
|
||||
}
|
||||
|
||||
public virtual TestRslt GetTestRslt(string name, int part)
|
||||
{
|
||||
foreach (var tr in TestRslts)
|
||||
{
|
||||
if (part == tr.Part && name.Equals(tr.Name())) return tr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Batch #{0}, Start:{1}, End:{2}, Procedure:{3}", BatchNr, StartTime, EndTime, ProcedureName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class Components
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual int TestBenchId { get; set; }
|
||||
public virtual string TestBenchName { get; set; }
|
||||
public virtual string Pump { get; set; }
|
||||
public virtual string RegValve { get; set; }
|
||||
public virtual string Flowmeter { get; set; }
|
||||
public virtual string Diverter { get; set; }
|
||||
public virtual string Scale { get; set; }
|
||||
public virtual string Custom1 { get; set; }
|
||||
public virtual string Custom2 { get; set; }
|
||||
public virtual string Custom3 { get; set; }
|
||||
|
||||
protected Components()
|
||||
{
|
||||
TestBenchId = 0;
|
||||
TestBenchName = string.Empty;
|
||||
Pump = string.Empty;
|
||||
RegValve = string.Empty;
|
||||
Flowmeter = string.Empty;
|
||||
Diverter = string.Empty;
|
||||
Scale = string.Empty;
|
||||
Custom1 = string.Empty;
|
||||
Custom2 = string.Empty;
|
||||
Custom3 = string.Empty;
|
||||
}
|
||||
|
||||
public Components(int benchId, string benchName, string pump, string flowmeter,
|
||||
string scale, string regValve, string diverter)
|
||||
{
|
||||
TestBenchId = benchId;
|
||||
TestBenchName = benchName;
|
||||
Pump = pump;
|
||||
RegValve = regValve;
|
||||
Flowmeter = flowmeter;
|
||||
Diverter = diverter;
|
||||
Scale = scale;
|
||||
Custom1 = string.Empty;
|
||||
Custom2 = string.Empty;
|
||||
Custom3 = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method to compare the content of two entities
|
||||
/// </summary>
|
||||
/// <param name="wmd">Second entity to compare with</param>
|
||||
/// <returns>first = two entities are equal (except of Id)</returns>
|
||||
public virtual bool Equals(Components bc)
|
||||
{
|
||||
if (TestBenchId != bc.TestBenchId) return false;
|
||||
if (!TestBenchName.Equals(bc.TestBenchName)) return false;
|
||||
if (!Pump.Equals(bc.Pump)) return false;
|
||||
if (!RegValve.Equals(bc.RegValve)) return false;
|
||||
if (!Flowmeter.Equals(bc.Flowmeter)) return false;
|
||||
if (!Diverter.Equals(bc.Diverter)) return false;
|
||||
if (!Scale.Equals(bc.Scale)) return false;
|
||||
if (!Custom1.Equals(bc.Custom1)) return false;
|
||||
if (!Custom2.Equals(bc.Custom2)) return false;
|
||||
if (!Custom3.Equals(bc.Custom3)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the list if it does not occur there
|
||||
/// </summary>
|
||||
/// <param name="list">List of items</param>
|
||||
/// <param name="item">Item to add to the list or find there</param>
|
||||
/// <returns>Item from the list (existing or added)</returns>
|
||||
public static Components UpdateList(IList<Components> list, Components item)
|
||||
{
|
||||
if (item == null) return null; /// Null item is not stored in the list
|
||||
|
||||
Components found = list.FirstOrDefault<Components>(x => x.Equals(item));
|
||||
|
||||
if (found != null) return found; /// The same item found in the list, The found item returned
|
||||
|
||||
list.Add(item); /// Item not fund in the list, it is added to the list
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class MeterTestRslt
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
|
||||
public virtual byte CompoundMeterId { get; set; } /// 0=single, 1=compound/main, 2=compound/aux., 3=compound/overal
|
||||
public virtual double PulsesMeter { get; set; } /// # of water meter pulses
|
||||
public virtual double PulsesMaster { get; set; } /// # of reference flowmeter pulses (gated by this water meter pulses)
|
||||
public virtual double PulsesPerLiter { get; set; } /// # of water meter pulses per one liter
|
||||
public virtual double VolumeStart { get; set; } /// [l]
|
||||
public virtual double VolumeEnd { get; set; } /// [l]
|
||||
public virtual double VolumeMeter { get; set; } /// [l]
|
||||
public virtual double VolumeRef { get; set; } /// [l]
|
||||
public virtual double TimestampStart { get; set; } /// [s]
|
||||
public virtual double TimestampEnd { get; set; } /// [s]
|
||||
public virtual double TestTime { get; set; } /// [s]
|
||||
public virtual double Error { get; set; } /// [%]
|
||||
public virtual bool TestDone { get; set; } /// true = test was completed
|
||||
public virtual bool Passed { get; set; } /// true = test passed, water meter is OK
|
||||
|
||||
public virtual WaterMeter WaterMeter { get; set; } /// reference to the WaterMeter entity
|
||||
public virtual TestRslt TestRslt { get; set; } /// reference to the TestRslt entity
|
||||
|
||||
/// Wrappers
|
||||
public virtual string Name() { return TestRslt.Name(); }
|
||||
public virtual DateTime StartTime() { return TestRslt.StartTime; }
|
||||
public virtual DateTime EndTime() { return TestRslt.EndTime; }
|
||||
public virtual double FlowSetTime() { return TestRslt.FlowSetTime; } /// [s]
|
||||
public virtual double FlowMass() { return TestRslt.FlowMass; } /// [kg/h]
|
||||
public virtual double FlowVolume() { return TestRslt.FlowVolume; } /// [m3/h]
|
||||
public virtual double ErrorMaster() { return TestRslt.ErrorMaster; } /// [%]
|
||||
public virtual double DensityOut() { return TestRslt.DensityOut; }
|
||||
public virtual Components Components(){ return TestRslt.Components; }
|
||||
///
|
||||
protected virtual TestData TestData() { return TestRslt.TestData; }
|
||||
///
|
||||
public virtual int Repeats() { return TestData().Repeats; }
|
||||
public virtual double Qfrom() { return TestData().Qfrom; } /// [m3/h]
|
||||
public virtual double Qto() { return TestData().Qto; } /// [m3/h]
|
||||
public virtual double TargetVolume() { return TestData().TargetVolume; } /// [l]
|
||||
public virtual double TargetTime() { return TestData().TargetTime; } /// [s]
|
||||
public virtual string Method() { return TestData().Method; }
|
||||
public virtual double ErrLimLo() { return TestData().ErrLimLo; } /// [%]
|
||||
public virtual double ErrLimHi() { return TestData().ErrLimHi; } /// [%]
|
||||
public virtual double Uncertainty() { return TestData().Uncertainty; } /// [%]
|
||||
|
||||
public virtual string ProcedureName() { return WaterMeter.Batch.ProcedureName; }
|
||||
public virtual int BatchNr() { return WaterMeter.Batch.BatchNr; }
|
||||
public virtual string SerialNr() { return WaterMeter.SerialNr; }
|
||||
public virtual string EndState() { return WaterMeter.EndState; }
|
||||
public virtual double QRise() { return WaterMeter.QRise; } /// [m3/h]
|
||||
public virtual double QFall() { return WaterMeter.QFall; } /// [m3/h]
|
||||
|
||||
public virtual bool Evaluate() { return TestData().Evaluate; }
|
||||
public virtual Config.Entities.Publish Publish() { return (Config.Entities.Publish)TestData().Publish; }
|
||||
|
||||
public virtual WaterMeterData WaterMeterData() { return WaterMeter.WaterMeterData; }
|
||||
public virtual Batch Batch() { return WaterMeter.Batch; }
|
||||
|
||||
public virtual string PassedColorStr()
|
||||
{
|
||||
#if PUCHONG_PT200
|
||||
if (!Evaluate()) return Passed ? "OK|White" : "NG|White";
|
||||
else return Passed ? "OK|Green" : "NG|Red";
|
||||
#else
|
||||
if (!Evaluate()) return Passed ? "OK|White" : "NOK|White";
|
||||
else return Passed ? "OK|Green" : "NOK|Red";
|
||||
#endif
|
||||
}
|
||||
|
||||
public MeterTestRslt()
|
||||
{
|
||||
TestDone = false;
|
||||
Passed = false;
|
||||
}
|
||||
|
||||
public MeterTestRslt(WaterMeter waterMeterRslt, TestRslt testRslt, Config.Entities.CompoundMeterId compoundMeterId)
|
||||
: this()
|
||||
{
|
||||
WaterMeter = waterMeterRslt;
|
||||
TestRslt = testRslt;
|
||||
CompoundMeterId = (byte)compoundMeterId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Test, consisting of one or more repetitions of the test 'SingleTest'.
|
||||
/// </summary>
|
||||
public class TestData
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual int Repeats { get; set; }
|
||||
public virtual double Qfrom { get; set; } /// [m3/h] flow range low limit
|
||||
public virtual double Qto { get; set; } /// [m3/h] flow range high limit
|
||||
public virtual double TargetVolume { get; set; } /// [l] target test volume
|
||||
public virtual double TargetTime { get; set; } /// [s] target test time
|
||||
public virtual string Method { get; set; }
|
||||
public virtual double ErrLimLo { get; set; } /// [%] (usually < 0)
|
||||
public virtual double ErrLimHi { get; set; } /// [%] (usually > 0)
|
||||
public virtual double Uncertainty { get; set; } /// [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx)
|
||||
public virtual sbyte Publish { get; set; } /// 0=no, 1=in all protocols, 2=on screen, 3=internal
|
||||
public virtual bool Evaluate { get; set; }
|
||||
|
||||
|
||||
protected TestData()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Method = string.Empty;
|
||||
}
|
||||
|
||||
public TestData(Config.Entities.Test test)
|
||||
: this()
|
||||
{
|
||||
Name = test.Name;
|
||||
Repeats = test.Repeats;
|
||||
Qfrom = (double)test.Qfrom;
|
||||
Qto = (double)test.Qto;
|
||||
TargetVolume = (double)test.Volume;
|
||||
TargetTime = (double)test.TstTime;
|
||||
Method = test.Method;
|
||||
ErrLimLo = (double)test.ErrLimLo;
|
||||
ErrLimHi = (double)test.ErrLimHi;
|
||||
Uncertainty = (double)test.Uncertainty;
|
||||
Publish = test.Publish;
|
||||
Evaluate = test.Evaluate;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method to compare the content of two entities
|
||||
/// </summary>
|
||||
/// <param name="wmd">Second entity to compare with</param>
|
||||
/// <returns>first = two entities are equal (except of Id)</returns>
|
||||
public virtual bool Equals(TestData td)
|
||||
{
|
||||
if (!Name.Equals(td.Name)) return false;
|
||||
if (Repeats != td.Repeats) return false;
|
||||
if (Qfrom != td.Qfrom) return false;
|
||||
if (Qto != td.Qto) return false;
|
||||
if (TargetVolume != td.TargetVolume) return false;
|
||||
if (TargetTime != td.TargetTime) return false;
|
||||
if (!Method.Equals(td.Method)) return false;
|
||||
if (ErrLimLo != td.ErrLimLo) return false;
|
||||
if (ErrLimHi != td.ErrLimHi) return false;
|
||||
if (Uncertainty != td.Uncertainty) return false;
|
||||
if (Publish != td.Publish) return false;
|
||||
if (Evaluate != td.Evaluate) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the list if it does not occur there
|
||||
/// </summary>
|
||||
/// <param name="list">List of items</param>
|
||||
/// <param name="item">Item to add to the list or find there</param>
|
||||
/// <returns>Item from the list (existing or added)</returns>
|
||||
public static TestData UpdateList(IList<TestData> list, TestData item)
|
||||
{
|
||||
if (item == null) return null; /// Null item is not stored in the list
|
||||
|
||||
TestData found = list.FirstOrDefault<TestData>(x => x.Equals(item));
|
||||
|
||||
if (found != null) return found; /// The same item found in the list, The found item returned
|
||||
|
||||
list.Add(item); /// Item not fund in the list, it is added to the list
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class TestRslt
|
||||
{
|
||||
/// Identity
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual Batch Batch { get; set; }
|
||||
public virtual TestData TestData { get; set; }
|
||||
public virtual Components Components { get; set; }
|
||||
public virtual int Part { get; set; }
|
||||
public virtual int RepetitionNr { get; set; } /// Repetition number from the set of repeated tests (1...)
|
||||
|
||||
/// Main results
|
||||
public virtual DateTime StartTime { get; set; } /// Date and time of the test start
|
||||
public virtual DateTime EndTime { get; set; } /// Date and time of the test end
|
||||
public virtual int FlowSetTime { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual double TestTime { get; set; } /// [s] Measurement time in seconds
|
||||
public virtual double PulsesMaster { get; set; }
|
||||
public virtual double ConstMaster { get; set; } /// [pls/l] Pulses per liter master flow meter
|
||||
public virtual double MassStartRaw { get; set; } /// [kg]
|
||||
public virtual double MassStart { get; set; } /// [kg]
|
||||
public virtual double MassEndRaw { get; set; } /// [kg]
|
||||
public virtual double MassEnd { get; set; } /// [kg]
|
||||
public virtual double DensityIn { get; set; } /// [kg/m3]
|
||||
public virtual double DensityOut { get; set; } /// [kg/m3]
|
||||
public virtual double DensityDiv { get; set; } /// [kg/m3]
|
||||
public virtual double Buoyancy { get; set; }
|
||||
public virtual double FlowMass { get; set; } /// [kg/h] calculated from conventional true value
|
||||
public virtual double FlowVolume { get; set; } ///![m3/h]
|
||||
public virtual double VolumeCTV { get; set; } /// [l] Volume conventional true value
|
||||
public virtual double VolumeMaster { get; set; } /// [l] Volume from the master flow meter
|
||||
public virtual double ErrorMaster { get; set; } /// [%]
|
||||
|
||||
/// Auxiliary results
|
||||
public virtual float AmbientTempAve { get; set; } /// [deg.C] Average ambient air temperature
|
||||
public virtual float AmbientPressAve { get; set; } /// Average ambient air pressure
|
||||
public virtual float AmbientHumiAve { get; set; } /// [%] Average ambient air relative humidity
|
||||
public virtual float PressUpAvrg { get; set; } /// [Bar] Input water pressure (average)
|
||||
public virtual float PressUpStart { get; set; } /// [Bar]
|
||||
public virtual float PressUpEnd { get; set; } /// [Bar]
|
||||
public virtual float PressUpMin { get; set; } /// [Bar]
|
||||
public virtual float PressUpMax { get; set; } /// [Bar]
|
||||
public virtual float PressDownAvrg { get; set; } /// [Bar]
|
||||
public virtual float PressDownStart { get; set; } /// [Bar]
|
||||
public virtual float PressDownEnd { get; set; } /// [Bar]
|
||||
public virtual float PressDownMin { get; set; } /// [Bar]
|
||||
public virtual float PressDownMax { get; set; } /// [Bar]
|
||||
public virtual float TempInAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempInStart { get; set; } /// [deg.C]
|
||||
public virtual float TempInEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempInMin { get; set; } /// [deg.C]
|
||||
public virtual float TempInMax { get; set; } /// [deg.C]
|
||||
public virtual float TempOutAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempOutStart { get; set; } /// [deg.C]
|
||||
public virtual float TempOutEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempOutMin { get; set; } /// [deg.C]
|
||||
public virtual float TempOutMax { get; set; } /// [deg.C]
|
||||
public virtual float TempDivAvrg { get; set; } /// [deg.C]
|
||||
public virtual float TempDivStart { get; set; } /// [deg.C]
|
||||
public virtual float TempDivEnd { get; set; } /// [deg.C]
|
||||
public virtual float TempDivMin { get; set; } /// [deg.C]
|
||||
public virtual float TempDivMax { get; set; } /// [deg.C]
|
||||
public virtual float FlowMin { get; set; } /// [kg/m3] minimum flow
|
||||
public virtual float FlowMax { get; set; } /// [kg/m3] maximum flow
|
||||
|
||||
public virtual float Custom1 { get; set; }
|
||||
public virtual float Custom2 { get; set; }
|
||||
public virtual float Custom3 { get; set; }
|
||||
public virtual float Custom4 { get; set; }
|
||||
public virtual float Custom5 { get; set; }
|
||||
public virtual float Custom6 { get; set; }
|
||||
public virtual float Custom7 { get; set; }
|
||||
public virtual float Custom8 { get; set; }
|
||||
|
||||
/// Wrappers
|
||||
public virtual string Name() { return Utils.GetTestName(TestData.Name, TestData.Repeats, RepetitionNr); }
|
||||
public virtual int Repeats() { return TestData.Repeats; }
|
||||
public virtual double Qfrom() { return TestData.Qfrom; }
|
||||
public virtual double Qto() { return TestData.Qto; }
|
||||
public virtual double TargetVolume() { return TestData.TargetVolume; }
|
||||
public virtual double TargetTime() { return TestData.TargetTime; }
|
||||
public virtual string Method() { return TestData.Method; }
|
||||
public virtual double ErrLimLo() { return TestData.ErrLimLo; }
|
||||
public virtual double ErrLimHi() { return TestData.ErrLimHi; }
|
||||
public virtual double Uncertainty() { return TestData.Uncertainty; }
|
||||
public virtual bool Evaluate() { return TestData.Evaluate; }
|
||||
public virtual Config.Entities.Publish Publish() { return (Config.Entities.Publish)TestData.Publish; }
|
||||
|
||||
|
||||
protected TestRslt()
|
||||
{
|
||||
}
|
||||
|
||||
public TestRslt(Batch batch, TestData testData, int part, int repetitionNr)
|
||||
: this()
|
||||
{
|
||||
Batch = batch;
|
||||
TestData = testData;
|
||||
Part = part;
|
||||
RepetitionNr = repetitionNr;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("batch={0}, procedure={1}, test={2}, {3} {4}", Batch.BatchNr, Batch.ProcedureName, Name(), StartTime.ToShortDateString(), StartTime.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Config.Entities;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class WaterMeter
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
public virtual string SerialNr { get; set; } /// Main s/n for compound meters, PCB Number for iPerl water meter
|
||||
public virtual string SerialNrAux { get; set; } /// Aux s/n for compound meters, Serial number for iPerl water meter
|
||||
public virtual string PurchaseOrder { get; set; }
|
||||
public virtual int YearOfProduction { get; set; }
|
||||
public virtual int WMPosition { get; set; }
|
||||
public virtual string EndState { get; set; } /// End state (of the main water meter)
|
||||
public virtual string EndStateAux { get; set; } /// End state of the auxiliary water meter
|
||||
public virtual double QRise { get; set; } ///![m3/h] detected Q_rise of a composed meter
|
||||
public virtual double QFall { get; set; } ///![m3/h] detected Q_fall of a composed meter
|
||||
public virtual bool Passed { get; set; }
|
||||
public virtual int ResultCode { get; set; }
|
||||
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
public virtual int SerialNrEx { get; set; } /// Aux s/n for compound meters, Serial number for iPerl water meter
|
||||
public virtual double OrigCalibFactor { get; set; } /// iPerl calibration factor used during the test
|
||||
public virtual double CalibFactor { get; set; } /// iPerl calibration factor used during the test
|
||||
public virtual double Q2ErrWOCorrection { get; set; }
|
||||
public virtual bool Q2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done
|
||||
public virtual double Q2Correction { get; set; } /// iPerl Q2 correction used during the test
|
||||
public virtual int Q2CorrFlowRight { get; set; } /// 1 = right to left
|
||||
public virtual double Diff2Hz8Hz { get; set; }
|
||||
public virtual bool Hz2CorrectionDone { get; set; } /// true = iPerl Q2 correction was done
|
||||
public virtual int Hz2Correction { get; set; } /// iPerl Q2 correction used during the test
|
||||
public virtual int Pruefindex { get; set; } /// Not mapped to DB !!! 0=unknown (saving to Oracle failed), >=1 ... pruefindex
|
||||
public virtual int HydrPruefung { get; set; } /// Not mapped to DB !!!
|
||||
#endif
|
||||
public virtual WaterMeterData WaterMeterData { get; set; }
|
||||
public virtual Batch Batch { get; set; }
|
||||
public virtual IList<MeterTestRslt> MeterTestRslts { get; set; }
|
||||
|
||||
///
|
||||
/// Wrappers
|
||||
///
|
||||
public virtual string ProductName() { return WaterMeterData.ProductName; }
|
||||
public virtual string Producer() { return WaterMeterData.Producer; }
|
||||
public virtual string MetrologicalClass() { return WaterMeterData.MetrologicalClass; }
|
||||
public virtual string ApprovalInfo() { return WaterMeterData.ApprovalInfo; }
|
||||
public virtual double Q4_Qmax() { return WaterMeterData.Q4_Qmax; }
|
||||
public virtual double Q3_Qn() { return WaterMeterData.Q3_Qn; }
|
||||
public virtual double Q2_Qt() { return WaterMeterData.Q2_Qt; }
|
||||
public virtual double Q1_Qmin() { return WaterMeterData.Q1_Qmin; }
|
||||
|
||||
public virtual bool Compound() { return WaterMeterData.Compound; }
|
||||
#if HEAT_METER_SUPPORT
|
||||
public virtual bool HeatMeter() { return WaterMeterData.HeatMeter; }
|
||||
#endif
|
||||
|
||||
public virtual string ProducerAux() { return WaterMeterData.ProducerAux; }
|
||||
public virtual double Q3_Qn_Aux() { return WaterMeterData.Q3_Qn_Aux; }
|
||||
public virtual string MetrologicalClassAux() { return WaterMeterData.MetrologicalClassAux; }
|
||||
public virtual string ApprovalInfoAux() { return WaterMeterData.ApprovalInfoAux; }
|
||||
|
||||
public virtual int BatchNr() { return Batch.BatchNr; }
|
||||
public virtual int BenchId() { return Batch.TestBenchId; }
|
||||
public virtual string ProcedureName() { return Batch.ProcedureName; }
|
||||
public virtual int ProcedureRevision() { return Batch.ProcedureRevision; }
|
||||
public virtual DateTime StartTime() { return Batch.StartTime; }
|
||||
public virtual DateTime EndTime() { return Batch.EndTime; }
|
||||
|
||||
protected MeterTestRslt lastMeterTestRslts;
|
||||
public virtual MeterTestRslt LastMeterTestRslts() { return lastMeterTestRslts; }
|
||||
|
||||
|
||||
public virtual bool PassedFromTests()
|
||||
{
|
||||
bool passed = true;
|
||||
foreach (var mtr in MeterTestRslts)
|
||||
{
|
||||
if (mtr.Evaluate() && (!mtr.Passed || !mtr.TestDone))
|
||||
{
|
||||
passed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
///
|
||||
/// Not mapped to the database
|
||||
///
|
||||
public virtual bool Disabled { get; set; } /// true = Disabled water meters (not saved into DB)
|
||||
|
||||
|
||||
public virtual MeterTestRslt GetMeterTestRslt(string testName)
|
||||
{
|
||||
return GetMeterTestRslt(testName, CompoundMeterId.Single);
|
||||
}
|
||||
|
||||
public virtual MeterTestRslt GetMeterTestRslt(string testName, Config.Entities.CompoundMeterId meterId)
|
||||
{
|
||||
if (Disabled) return null;
|
||||
string testNameL = testName.ToLower();
|
||||
foreach (var mtr in MeterTestRslts)
|
||||
{
|
||||
if ((mtr.CompoundMeterId == (byte)meterId) && mtr.Name().ToLower().Equals(testNameL))
|
||||
{
|
||||
return mtr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual TestRslt GetTestRslt(string testName)
|
||||
{
|
||||
MeterTestRslt mtr = GetMeterTestRslt(testName);
|
||||
if (mtr != null) return mtr.TestRslt;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, initializes a list, used as a base for other constructors
|
||||
/// </summary>
|
||||
public WaterMeter()
|
||||
{
|
||||
MeterTestRslts = new List<MeterTestRslt>();
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
sb.AppendFormat("PCB:{0} S/N:{1} ", SerialNr, SerialNrEx);
|
||||
#else
|
||||
sb.AppendFormat("S/N:{0} ", SerialNr);
|
||||
#endif
|
||||
|
||||
foreach (var tr in MeterTestRslts) sb.AppendFormat(" {0}:{1}%", tr.Name(), tr.Error.ToString("F2"));
|
||||
sb.AppendFormat(" test start: {0} {1} batch={2}", StartTime().ToShortDateString(), StartTime().ToShortTimeString(), BatchNr());
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Results.Entities
|
||||
{
|
||||
public class WaterMeterData
|
||||
{
|
||||
public virtual int Id { get; protected set; }
|
||||
|
||||
public virtual string ProductName { get; set; }
|
||||
public virtual string Producer { get; set; }
|
||||
|
||||
public virtual double DN { get; set; } /// [mm]
|
||||
public virtual double L { get; set; } /// [mm]
|
||||
public virtual Config.Entities.Mounting Mounting { get; set; } /// H / V / S / F
|
||||
|
||||
public virtual double Q4_Qmax { get; set; } /// [m3/h]
|
||||
public virtual double Q3_Qn { get; set; } /// [m3/h]
|
||||
public virtual double Q2_Qt { get; set; } /// [m3/h]
|
||||
public virtual double Q1_Qmin { get; set; } /// [m3/h]
|
||||
|
||||
public virtual string MetrologicalClass { get; set; }
|
||||
public virtual Config.Entities.TemperatureClass TemperatureClass { get; set; }
|
||||
public virtual Config.Entities.PressureLossClass PressureLossClass { get; set; }
|
||||
public virtual Config.Entities.MaxAdmissiblePressure MaxAdmissiblePressure { get; set; }
|
||||
public virtual Config.Entities.FlowProfileSensitivityClass FlowProfileSensitivityClass { get; set; }
|
||||
|
||||
public virtual string ApprovalInfo { get; set; }
|
||||
public virtual string Certificate { get; set; }
|
||||
|
||||
public virtual double PulsesPerLtr { get; set; }
|
||||
|
||||
/// Concerns compound water meters
|
||||
public virtual string ProducerAux { get; set; }
|
||||
public virtual double Q3_Qn_Aux { get; set; } /// [m3/h]
|
||||
public virtual string MetrologicalClassAux { get; set; }
|
||||
public virtual string ApprovalInfoAux { get; set; }
|
||||
|
||||
public virtual string Text1 { get; set; }
|
||||
public virtual string Text2 { get; set; }
|
||||
public virtual string Text3 { get; set; }
|
||||
public virtual string Text4 { get; set; }
|
||||
public virtual string Text5 { get; set; }
|
||||
|
||||
public virtual bool Compound { get; set; }
|
||||
#if HEAT_METER_SUPPORT
|
||||
public virtual bool HeatMeter { get; set; }
|
||||
#endif
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
public virtual int WMTypeId { get; set; }
|
||||
public virtual int WMTypeRev { get; set; }
|
||||
#endif
|
||||
|
||||
public WaterMeterData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method to compare the content of two entities
|
||||
/// </summary>
|
||||
/// <param name="wmd">Second entity to compare with</param>
|
||||
/// <returns>first = two entities are equal (except of Id)</returns>
|
||||
public virtual bool Equals(WaterMeterData wmd)
|
||||
{
|
||||
if (!ProductName.Equals(wmd.ProductName)) return false;
|
||||
if (!Producer.Equals(wmd.Producer)) return false;
|
||||
|
||||
if (DN != wmd.DN) return false;
|
||||
if (L != wmd.L) return false;
|
||||
if (Mounting != wmd.Mounting) return false;
|
||||
|
||||
if (Q4_Qmax != wmd.Q4_Qmax) return false;
|
||||
if (Q3_Qn != wmd.Q3_Qn) return false;
|
||||
if (Q2_Qt != wmd.Q2_Qt) return false;
|
||||
if (Q1_Qmin != wmd.Q1_Qmin) return false;
|
||||
|
||||
if (!MetrologicalClass.Equals(wmd.MetrologicalClass)) return false;
|
||||
if (!TemperatureClass.Equals(wmd.TemperatureClass)) return false;
|
||||
if (!PressureLossClass.Equals(wmd.PressureLossClass)) return false;
|
||||
if (!MaxAdmissiblePressure.Equals(wmd.MaxAdmissiblePressure)) return false;
|
||||
if (!FlowProfileSensitivityClass.Equals(wmd.FlowProfileSensitivityClass)) return false;
|
||||
|
||||
if (!ApprovalInfo.Equals(wmd.ApprovalInfo)) return false;
|
||||
if (Certificate != wmd.Certificate) return false;
|
||||
|
||||
if (PulsesPerLtr != wmd.PulsesPerLtr) return false;
|
||||
|
||||
if (ProducerAux != wmd.ProducerAux) return false;
|
||||
if (Q3_Qn_Aux != wmd.Q3_Qn_Aux) return false;
|
||||
if (MetrologicalClassAux != wmd.MetrologicalClassAux) return false;
|
||||
if (ApprovalInfoAux != wmd.ApprovalInfoAux) return false;
|
||||
|
||||
if (Text1 != wmd.Text1) return false;
|
||||
if (Text2 != wmd.Text2) return false;
|
||||
if (Text3 != wmd.Text3) return false;
|
||||
if (Text4 != wmd.Text4) return false;
|
||||
if (Text5 != wmd.Text5) return false;
|
||||
|
||||
if (Compound != wmd.Compound) return false;
|
||||
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
if (WMTypeId != wmd.WMTypeId) return false;
|
||||
if (WMTypeRev != wmd.WMTypeRev) return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the list if it does not occur there
|
||||
/// </summary>
|
||||
/// <param name="list">List of items</param>
|
||||
/// <param name="item">Item to add to the list or find there</param>
|
||||
/// <returns>Item from the list (existing or added)</returns>
|
||||
public static WaterMeterData UpdateList(IList<WaterMeterData> list, WaterMeterData item)
|
||||
{
|
||||
if (item == null) return null; /// Null item is not stored in the list
|
||||
|
||||
WaterMeterData found = list.FirstOrDefault<WaterMeterData>(x => x.Equals(item));
|
||||
|
||||
if (found != null) return found; /// The same item found in the list, The found item returned
|
||||
|
||||
list.Add(item); /// Item not fund in the list, it is added to the list
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public class ItemSpec
|
||||
{
|
||||
///
|
||||
/// Public fields
|
||||
///
|
||||
public readonly string Name; /// Name-s of all items must be unique
|
||||
public readonly string ClmnHeaderText; /// Text printed in the column header
|
||||
|
||||
|
||||
///
|
||||
/// Function to pick a MeterTestResult field and convert it into a string
|
||||
///
|
||||
public delegate string PrintDlgt(MeterTestRslt meterTestRslt);
|
||||
|
||||
private readonly PrintDlgt printDlgt;
|
||||
|
||||
public bool CanPrintSingle { get { return (printDlgt != null); } }
|
||||
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string Print(MeterTestRslt meterTestRslt)
|
||||
{
|
||||
string str = printDlgt(meterTestRslt);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Function to pick a MeterTestResult field and convert it into a string
|
||||
///
|
||||
public delegate string PrintCombinedDlgt(MeterTestRslt mainMtrTestResult,
|
||||
MeterTestRslt auxMtrTestResult,
|
||||
MeterTestRslt compoundMtrTestResult);
|
||||
|
||||
private readonly PrintCombinedDlgt printCombinedDlgt;
|
||||
|
||||
public bool CanPrintCombined { get { return (printCombinedDlgt != null); } }
|
||||
|
||||
/// <summary> Safe wrapper which replaces null-s by empty strings </summary>
|
||||
public string PrintCombined(MeterTestRslt mainMtrTestResult,
|
||||
MeterTestRslt auxMtrTestResult,
|
||||
MeterTestRslt compoundMtrTestResult)
|
||||
{
|
||||
string str = printCombinedDlgt(mainMtrTestResult, auxMtrTestResult, compoundMtrTestResult);
|
||||
return (str == null) ? string.Empty : str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Public constructor
|
||||
///
|
||||
public ItemSpec(string name, string clmnHeaderText, PrintDlgt printDlgt, PrintCombinedDlgt printCombinedDlgt)
|
||||
{
|
||||
Name = name;
|
||||
ClmnHeaderText = clmnHeaderText;
|
||||
this.printDlgt = printDlgt;
|
||||
this.printCombinedDlgt = printCombinedDlgt;
|
||||
}
|
||||
|
||||
|
||||
/// Static list of all available items
|
||||
public static readonly IList<ItemSpec> AllItems;
|
||||
|
||||
/// Static constructor that initializes the list of all items
|
||||
static ItemSpec()
|
||||
{
|
||||
AllItems = new List<ItemSpec>();
|
||||
|
||||
/// Common
|
||||
|
||||
//AllItems.Add(new ResultItemSpec("Bench ID", "Bench ID", x => x.BenchID,
|
||||
// (x, y, z) => x.BenchID));
|
||||
AllItems.Add(new ItemSpec("Test name", "Test", x => x.Name(), (x, y, z) => z.Name()));
|
||||
AllItems.Add(new ItemSpec("Procedure name", "Procedure", x => x.ProcedureName(), (x, y, z) => z.ProcedureName()));
|
||||
AllItems.Add(new ItemSpec("Batch number", "Batch nr.", x => x.BatchNr().ToString(), (x, y, z) => z.BatchNr().ToString()));
|
||||
AllItems.Add(new ItemSpec("Test method", "Test method", x => x.Method(), (x, y, z) => z.Method()));
|
||||
AllItems.Add(new ItemSpec("Density", "Density", x => x.DensityOut().ToString("F1"), (x, y, z) => z.DensityOut().ToString("F1"))); /// [kg/m3]
|
||||
|
||||
/// Target values
|
||||
AllItems.Add(new ItemSpec("Q from", "Q from [m3/h]", x => x.Qfrom().ToString("F3"), (x, y, z) => z.Qfrom().ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Q to", "Q to [m3/h]", x => x.Qto().ToString("F3"), (x, y, z) => z.Qto().ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Test volume", "Test vol. [l]", x => x.TargetVolume().ToString("F1"),(x, y, z) => z.TargetVolume().ToString("F1")));
|
||||
AllItems.Add(new ItemSpec("Error limit Lo", "Err.Lim.Lo [%]", x => x.ErrLimLo().ToString("F1"), (x, y, z) => z.ErrLimLo().ToString("F1")));
|
||||
AllItems.Add(new ItemSpec("Error limit Hi", "Err.Lim.Hi [%]", x => x.ErrLimHi().ToString("F1"), (x, y, z) => z.ErrLimHi().ToString("F1")));
|
||||
AllItems.Add(new ItemSpec("Uncertainty", "Uncertainty [%]",x => x.Uncertainty().ToString("F2"), (x, y, z) => z.Uncertainty().ToString("F2")));
|
||||
|
||||
/// Test results
|
||||
AllItems.Add(new ItemSpec("Start time", "T start", x => x.StartTime().ToShortTimeString(), (x, y, z) => z.StartTime().ToShortTimeString()));
|
||||
AllItems.Add(new ItemSpec("End time", "T end", x => x.EndTime().ToShortTimeString(), (x, y, z) => z.EndTime().ToShortTimeString()));
|
||||
AllItems.Add(new ItemSpec("Test time", "T [s]", x => x.TestTime.ToString("F2"), (x, y, z) => z.TestTime.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("Flow", "Flow [m3/h]", x => DoubleToStr(x.FlowVolume(), 4), (x, y, z) => DoubleToStr(z.FlowVolume(), 4)));
|
||||
AllItems.Add(new ItemSpec("T in", "T in", x => x.TestRslt.TempInAvrg.ToString("F2"), (x, y, z) => z.TestRslt.TempInAvrg.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("T out", "T out", x => x.TestRslt.TempOutAvrg.ToString("F2"), (x, y, z) => z.TestRslt.TempOutAvrg.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("T div", "T div", x => x.TestRslt.TempDivAvrg.ToString("F2"), (x, y, z) => z.TestRslt.TempDivAvrg.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("P up", "P up", x => x.TestRslt.PressUpAvrg.ToString("F3"), (x, y, z) => z.TestRslt.PressUpAvrg.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("P up start", "P up start", x => x.TestRslt.PressUpStart.ToString("F3"), (x, y, z) => z.TestRslt.PressUpStart.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("P up end", "P up end", x => x.TestRslt.PressUpEnd.ToString("F3"), (x, y, z) => z.TestRslt.PressUpEnd.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("P down", "P down", x => x.TestRslt.PressDownAvrg.ToString("F3"), (x, y, z) => z.TestRslt.PressDownAvrg.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("P down start", "P down start", x => x.TestRslt.PressDownStart.ToString("F3"), (x, y, z) => z.TestRslt.PressDownStart.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("P down end", "P down end", x => x.TestRslt.PressDownEnd.ToString("F3"), (x, y, z) => z.TestRslt.PressDownEnd.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Reference error","Err.ref. [%]", x => x.TestRslt.ErrorMaster.ToString("F3"), (x, y, z) => z.TestRslt.ErrorMaster.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Ambient temperature","T amb", x => x.TestRslt.AmbientTempAve.ToString("F1"), (x, y, z) => z.TestRslt.AmbientTempAve.ToString("F1")));
|
||||
AllItems.Add(new ItemSpec("Ambient pressure", "P amb", x => x.TestRslt.AmbientPressAve.ToString("F0"), (x, y, z) => z.TestRslt.AmbientPressAve.ToString("F0")));
|
||||
AllItems.Add(new ItemSpec("Ambient humidity", "H amb [%]",x => x.TestRslt.AmbientHumiAve.ToString("F1"), (x, y, z) => z.TestRslt.AmbientHumiAve.ToString("F1")));
|
||||
|
||||
/// Single and combined meter results
|
||||
AllItems.Add(new ItemSpec("Volume", "Volume [l]", x => x.VolumeMeter.ToString("F3"), (x, y, z) => z.VolumeMeter.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Reference volume", "Vol.ref. [l]", x => x.VolumeRef.ToString("F3"), (x, y, z) => z.VolumeRef.ToString("F3")));
|
||||
AllItems.Add(new ItemSpec("Error", "Error [%]", x => x.Error.ToString("F2"), (x, y, z) => z.Error.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("Passed", "Result", x => x.PassedColorStr(), (x, y, z) => z.PassedColorStr()));
|
||||
/// Single water meters only results
|
||||
AllItems.Add(new ItemSpec("Serial Nr", "s/n", x => x.SerialNr(), null));
|
||||
AllItems.Add(new ItemSpec("End state", "End state", x => x.EndState(), null));
|
||||
AllItems.Add(new ItemSpec("Pulses", "Pulses", x => x.PulsesMeter.ToString(), null));
|
||||
AllItems.Add(new ItemSpec("Pulses/liter", "Pulses/liter", x => x.PulsesPerLiter.ToString(), null));
|
||||
AllItems.Add(new ItemSpec("Reference pulses", "Ref.pulses", x => x.PulsesMaster.ToString(), null));
|
||||
|
||||
/// Combined water meters only results
|
||||
AllItems.Add(new ItemSpec("Q rise", "Q rise [m3/h]", null, (x, y, z) => (z.QRise() == 0) ? "-" : DoubleToStr(z.QRise(), 4)));
|
||||
AllItems.Add(new ItemSpec("Q fall", "Q fall [m3/h]", null, (x, y, z) => (z.QFall() == 0) ? "-" : DoubleToStr(z.QFall(), 4)));
|
||||
AllItems.Add(new ItemSpec("Error large WM", "Error-L [%]", null, (x, y, z) => x.Error.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("Error small WM", "Error-S [%]", null, (x, y, z) => y.Error.ToString("F2")));
|
||||
AllItems.Add(new ItemSpec("Serial Nr large WM", "s/n", null, (x, y, z) => x.SerialNr()));
|
||||
AllItems.Add(new ItemSpec("Serial Nr small WM", "s/n", null, (x, y, z) => y.SerialNr()));
|
||||
AllItems.Add(new ItemSpec("End state large WM", "End state", null, (x, y, z) => x.EndState()));
|
||||
AllItems.Add(new ItemSpec("End state small WM", "End state", null, (x, y, z) => y.EndState()));
|
||||
}
|
||||
|
||||
public static ItemSpec GetItem(string name)
|
||||
{
|
||||
foreach (var item in AllItems) if (item.Name.Equals(name)) return item;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string[] ToStrArray(IList<ItemSpec> items)
|
||||
{
|
||||
int count = (items != null) ? items.Count : 0;
|
||||
string[] result = new string[count];
|
||||
for (int i = 0; i < count; i++) result[i] = items[i].Name;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IList<ItemSpec> FromStrArray(string[] strArray)
|
||||
{
|
||||
IList<ItemSpec> result = new List<ItemSpec>();
|
||||
if (strArray != null)
|
||||
{
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
ItemSpec item = GetItem(strArray[i]);
|
||||
if (item != null) result.Add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts float number to a string with the specified number of valid digits
|
||||
/// </summary>
|
||||
/// <param name="value">Float value to be converted to a string</param>
|
||||
/// <param name="validDigits">Number of valid digits: 4, 3, or 2 (otherwise a full precision number is printed)</param>
|
||||
/// <returns>String representation of the float number</returns>
|
||||
public static string DoubleToStr(double value, int validDigits)
|
||||
{
|
||||
if (-float.Epsilon <= value && value <= float.Epsilon)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
else if (validDigits == 4)
|
||||
{
|
||||
if (value >= 999.5 || value < -999.5) return value.ToString("F0");
|
||||
else if (value >= 99.95 || value < -99.95) return value.ToString("F1");
|
||||
else if (value >= 9.995 || value < -9.995) return value.ToString("F2");
|
||||
else if (value >= 0.9995 || value < -0.9995) return value.ToString("F3");
|
||||
else if (value >= 0.09995 || value < -0.09995) return value.ToString("F4");
|
||||
else if (value >= 0.009995 || value < -0.009995) return value.ToString("F5");
|
||||
else return value.ToString("F6");
|
||||
}
|
||||
else if (validDigits == 3)
|
||||
{
|
||||
if (value >= 99.5 || value < -99.5) return value.ToString("F0");
|
||||
else if (value >= 9.95 || value < -9.95) return value.ToString("F1");
|
||||
else if (value >= 0.995 || value < -0.995) return value.ToString("F2");
|
||||
else if (value >= 0.0995 || value < -0.0995) return value.ToString("F3");
|
||||
else if (value >= 0.00995 || value < -0.00995) return value.ToString("F4");
|
||||
else if (value >= 0.000995 || value < -0.000995) return value.ToString("F5");
|
||||
else return value.ToString("F6");
|
||||
}
|
||||
else if (validDigits == 2)
|
||||
{
|
||||
if (value >= 9.5 || value < -9.5) return value.ToString("F0");
|
||||
else if (value >= 0.95 || value < -0.95) return value.ToString("F1");
|
||||
else if (value >= 0.095 || value < -0.095) return value.ToString("F2");
|
||||
else if (value >= 0.0095 || value < -0.0095) return value.ToString("F3");
|
||||
else if (value >= 0.00095 || value < -0.00095) return value.ToString("F4");
|
||||
else return value.ToString("F5");
|
||||
}
|
||||
else return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class BatchMap : ClassMap<Batch>
|
||||
{
|
||||
public BatchMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.BatchNr);
|
||||
Map(x => x.TestBenchId);
|
||||
Map(x => x.ProgramVersion);
|
||||
Map(x => x.UserName);
|
||||
Map(x => x.UserNumber);
|
||||
Map(x => x.ProcedureName);
|
||||
Map(x => x.ProcedureRevision);
|
||||
Map(x => x.ProtocolTitle);
|
||||
Map(x => x.Remark)
|
||||
.CustomType("StringClob")
|
||||
.CustomSqlType("varchar(2000)");
|
||||
Map(x => x.Custom1);
|
||||
Map(x => x.Custom2);
|
||||
Map(x => x.Custom3);
|
||||
Map(x => x.StartTime);
|
||||
Map(x => x.EndTime);
|
||||
Map(x => x.RsltsSent);
|
||||
Map(x => x.RsltsPrinted);
|
||||
HasMany(x => x.Tests)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.WaterMeters)
|
||||
.Cascade.All();
|
||||
HasMany(x => x.TestRslts)
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class ComponentsMap : ClassMap<Components>
|
||||
{
|
||||
public ComponentsMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.TestBenchId);
|
||||
Map(x => x.TestBenchName);
|
||||
Map(x => x.Pump);
|
||||
Map(x => x.RegValve);
|
||||
Map(x => x.Flowmeter);
|
||||
Map(x => x.Diverter);
|
||||
Map(x => x.Scale);
|
||||
Map(x => x.Custom1);
|
||||
Map(x => x.Custom2);
|
||||
Map(x => x.Custom3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class MeterTestRsltMap : ClassMap<MeterTestRslt>
|
||||
{
|
||||
public MeterTestRsltMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.CompoundMeterId);
|
||||
Map(x => x.PulsesMeter);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.PulsesPerLiter);
|
||||
Map(x => x.VolumeStart);
|
||||
Map(x => x.VolumeEnd);
|
||||
Map(x => x.VolumeMeter);
|
||||
Map(x => x.VolumeRef);
|
||||
Map(x => x.TimestampStart);
|
||||
Map(x => x.TimestampEnd);
|
||||
Map(x => x.TestTime);
|
||||
Map(x => x.Error);
|
||||
Map(x => x.TestDone);
|
||||
Map(x => x.Passed);
|
||||
|
||||
References(x => x.WaterMeter);
|
||||
References(x => x.TestRslt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class TestDataMap : ClassMap<TestData>
|
||||
{
|
||||
public TestDataMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.Name);
|
||||
Map(x => x.Qfrom);
|
||||
Map(x => x.Qto);
|
||||
Map(x => x.TargetVolume);
|
||||
Map(x => x.TargetTime);
|
||||
Map(x => x.Repeats);
|
||||
Map(x => x.Method);
|
||||
Map(x => x.ErrLimLo);
|
||||
Map(x => x.ErrLimHi);
|
||||
Map(x => x.Uncertainty);
|
||||
Map(x => x.Publish);
|
||||
Map(x => x.Evaluate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class TestRsltMap : ClassMap<TestRslt>
|
||||
{
|
||||
public TestRsltMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
References<Batch>(x => x.Batch);
|
||||
References<TestData>(x => x.TestData);
|
||||
References<Components>(x => x.Components);
|
||||
Map(x => x.Part);
|
||||
Map(x => x.RepetitionNr);
|
||||
|
||||
Map(x => x.StartTime);
|
||||
Map(x => x.EndTime);
|
||||
Map(x => x.FlowSetTime);
|
||||
Map(x => x.TestTime);
|
||||
Map(x => x.PulsesMaster);
|
||||
Map(x => x.ConstMaster);
|
||||
Map(x => x.MassStartRaw);
|
||||
Map(x => x.MassStart);
|
||||
Map(x => x.MassEndRaw);
|
||||
Map(x => x.MassEnd);
|
||||
Map(x => x.DensityIn);
|
||||
Map(x => x.DensityOut);
|
||||
Map(x => x.DensityDiv);
|
||||
Map(x => x.Buoyancy);
|
||||
Map(x => x.FlowMass);
|
||||
Map(x => x.FlowVolume);
|
||||
Map(x => x.VolumeCTV);
|
||||
Map(x => x.VolumeMaster);
|
||||
Map(x => x.ErrorMaster);
|
||||
|
||||
Map(x => x.AmbientTempAve);
|
||||
Map(x => x.AmbientPressAve);
|
||||
Map(x => x.AmbientHumiAve);
|
||||
Map(x => x.PressUpAvrg);
|
||||
Map(x => x.PressUpStart);
|
||||
Map(x => x.PressUpEnd);
|
||||
Map(x => x.PressUpMin);
|
||||
Map(x => x.PressUpMax);
|
||||
Map(x => x.PressDownAvrg);
|
||||
Map(x => x.PressDownStart);
|
||||
Map(x => x.PressDownEnd);
|
||||
Map(x => x.PressDownMin);
|
||||
Map(x => x.PressDownMax);
|
||||
Map(x => x.TempInAvrg);
|
||||
Map(x => x.TempInStart);
|
||||
Map(x => x.TempInEnd);
|
||||
Map(x => x.TempInMin);
|
||||
Map(x => x.TempInMax);
|
||||
Map(x => x.TempOutAvrg);
|
||||
Map(x => x.TempOutStart);
|
||||
Map(x => x.TempOutEnd);
|
||||
Map(x => x.TempOutMin);
|
||||
Map(x => x.TempOutMax);
|
||||
Map(x => x.TempDivAvrg);
|
||||
Map(x => x.TempDivStart);
|
||||
Map(x => x.TempDivEnd);
|
||||
Map(x => x.TempDivMin);
|
||||
Map(x => x.TempDivMax);
|
||||
Map(x => x.FlowMin);
|
||||
Map(x => x.FlowMax);
|
||||
|
||||
Map(x => x.Custom1);
|
||||
Map(x => x.Custom2);
|
||||
Map(x => x.Custom3);
|
||||
Map(x => x.Custom4);
|
||||
Map(x => x.Custom5);
|
||||
Map(x => x.Custom6);
|
||||
Map(x => x.Custom7);
|
||||
Map(x => x.Custom8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class WaterMeterDataMap : ClassMap<WaterMeterData>
|
||||
{
|
||||
public WaterMeterDataMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.ProductName);
|
||||
Map(x => x.Producer);
|
||||
|
||||
Map(x => x.DN);
|
||||
Map(x => x.L);
|
||||
Map(x => x.Mounting);
|
||||
|
||||
Map(x => x.Q4_Qmax);
|
||||
Map(x => x.Q3_Qn);
|
||||
Map(x => x.Q2_Qt);
|
||||
Map(x => x.Q1_Qmin);
|
||||
|
||||
Map(x => x.MetrologicalClass);
|
||||
Map(x => x.TemperatureClass);
|
||||
Map(x => x.PressureLossClass);
|
||||
Map(x => x.MaxAdmissiblePressure);
|
||||
Map(x => x.FlowProfileSensitivityClass);
|
||||
|
||||
Map(x => x.ApprovalInfo);
|
||||
Map(x => x.Certificate);
|
||||
|
||||
Map(x => x.PulsesPerLtr);
|
||||
|
||||
Map(x => x.ProducerAux);
|
||||
Map(x => x.Q3_Qn_Aux);
|
||||
Map(x => x.MetrologicalClassAux);
|
||||
Map(x => x.ApprovalInfoAux);
|
||||
|
||||
Map(x => x.Text1);
|
||||
Map(x => x.Text2);
|
||||
Map(x => x.Text3);
|
||||
Map(x => x.Text4);
|
||||
Map(x => x.Text5);
|
||||
|
||||
Map(x => x.Compound);
|
||||
#if HEAT_METER_SUPPORT
|
||||
Map(x => x.HeatMeter);
|
||||
#endif
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
Map(x => x.WMTypeId);
|
||||
Map(x => x.WMTypeRev);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
using FluentNHibernate.Mapping;
|
||||
using Results.Entities;
|
||||
|
||||
namespace Results.Mappings
|
||||
{
|
||||
class WaterMeterMap : ClassMap<WaterMeter>
|
||||
{
|
||||
public WaterMeterMap()
|
||||
{
|
||||
Id(x => x.Id);
|
||||
Map(x => x.SerialNr);
|
||||
Map(x => x.SerialNrAux);
|
||||
Map(x => x.PurchaseOrder);
|
||||
Map(x => x.YearOfProduction);
|
||||
Map(x => x.WMPosition);
|
||||
Map(x => x.EndState);
|
||||
Map(x => x.EndStateAux);
|
||||
Map(x => x.QRise);
|
||||
Map(x => x.QFall);
|
||||
Map(x => x.Passed);
|
||||
Map(x => x.ResultCode);
|
||||
|
||||
#if IPERLST || IPERLST_SPECIAL
|
||||
Map(x => x.SerialNrEx);
|
||||
Map(x => x.OrigCalibFactor);
|
||||
Map(x => x.CalibFactor);
|
||||
Map(x => x.Q2ErrWOCorrection);
|
||||
Map(x => x.Q2CorrectionDone);
|
||||
Map(x => x.Q2Correction);
|
||||
Map(x => x.Q2CorrFlowRight);
|
||||
Map(x => x.Diff2Hz8Hz);
|
||||
Map(x => x.Hz2CorrectionDone);
|
||||
Map(x => x.Hz2Correction);
|
||||
#endif
|
||||
References(x => x.WaterMeterData);
|
||||
References(x => x.Batch);
|
||||
HasMany(x => x.MeterTestRslts)
|
||||
.Cascade.All();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@ 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("NfcS5_DLL")]
|
||||
[assembly: AssemblyTitle("Results")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NfcS5_DLL")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyCompany("Sensus")]
|
||||
[assembly: AssemblyProduct("Results")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5954d496-caab-4f7a-bde2-bdc8f47dab19")]
|
||||
[assembly: Guid("5da980c4-8924-4762-9b72-91e011e08f6c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
@@ -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("1.18.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.18.0.0")]
|
||||
[assembly: AssemblyVersion("2.9.329.0")]
|
||||
[assembly: AssemblyFileVersion("2.9.329.0")]
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Results</RootNamespace>
|
||||
<AssemblyName>Results</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</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>TRACE;DEBUG;IPERLST</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;IPERLST</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentNHibernate">
|
||||
<HintPath>..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections">
|
||||
<HintPath>..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.6.6.5\lib\net20\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BatchResults.cs" />
|
||||
<Compile Include="Entities\Batch.cs" />
|
||||
<Compile Include="Entities\Components.cs" />
|
||||
<Compile Include="Entities\MeterTestRslt.cs" />
|
||||
<Compile Include="Entities\TestData.cs" />
|
||||
<Compile Include="Entities\TestRslt.cs" />
|
||||
<Compile Include="Entities\WaterMeterData.cs" />
|
||||
<Compile Include="Entities\WaterMeter.cs" />
|
||||
<Compile Include="DB.cs" />
|
||||
<Compile Include="Mappings\BatchMap.cs" />
|
||||
<Compile Include="Mappings\ComponentsMap.cs" />
|
||||
<Compile Include="Mappings\MeterTestRsltMap.cs" />
|
||||
<Compile Include="Mappings\TestDataMap.cs" />
|
||||
<Compile Include="Mappings\TestRsltMap.cs" />
|
||||
<Compile Include="Mappings\WaterMeterDataMap.cs" />
|
||||
<Compile Include="Mappings\WaterMeterMap.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ItemSpec.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Config\Config.csproj">
|
||||
<Project>{743DF7DB-C7B6-42EB-986D-0F485E5588E4}</Project>
|
||||
<Name>Config</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="FileWriters\" />
|
||||
<Folder Include="Printers\" />
|
||||
</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>
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Results
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string GetTestName(string name, int repeats, int repetitionNr)
|
||||
{
|
||||
if (repeats == 1) return name;
|
||||
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
|
||||
}
|
||||
|
||||
public static int BenchIdOracle2Asc(int benchIdOracle)
|
||||
{
|
||||
switch (benchIdOracle)
|
||||
{
|
||||
case 4: return 35; /// WR9
|
||||
case 5: return 33; /// WR10
|
||||
case 6: return 34; /// WR11
|
||||
case 7: return 29; /// PT7, special
|
||||
case 8: return 36; /// WR13
|
||||
case 9: return 37; /// WR15
|
||||
case 10: return 38; /// WR16
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
namespace ResultsBrowser.Forms
|
||||
{
|
||||
partial class DatabaseSettings
|
||||
{
|
||||
/// <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.textBox10 = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBox11 = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.textBox12 = new System.Windows.Forms.TextBox();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox10
|
||||
//
|
||||
this.textBox10.Location = new System.Drawing.Point(85, 23);
|
||||
this.textBox10.Name = "textBox10";
|
||||
this.textBox10.Size = new System.Drawing.Size(555, 20);
|
||||
this.textBox10.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 26);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(38, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "WR10";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(26, 52);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(38, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "WR11";
|
||||
//
|
||||
// textBox11
|
||||
//
|
||||
this.textBox11.Location = new System.Drawing.Point(85, 49);
|
||||
this.textBox11.Name = "textBox11";
|
||||
this.textBox11.Size = new System.Drawing.Size(555, 20);
|
||||
this.textBox11.TabIndex = 2;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(26, 78);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(38, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "WR12";
|
||||
//
|
||||
// textBox12
|
||||
//
|
||||
this.textBox12.Location = new System.Drawing.Point(85, 75);
|
||||
this.textBox12.Name = "textBox12";
|
||||
this.textBox12.Size = new System.Drawing.Size(555, 20);
|
||||
this.textBox12.TabIndex = 4;
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Location = new System.Drawing.Point(434, 109);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(95, 38);
|
||||
this.okButton.TabIndex = 6;
|
||||
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(545, 109);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(95, 38);
|
||||
this.cancelButton.TabIndex = 7;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// DatabaseSettings
|
||||
//
|
||||
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(668, 159);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.textBox12);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBox11);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.textBox10);
|
||||
this.Name = "DatabaseSettings";
|
||||
this.Text = "Database Settings";
|
||||
this.Load += new System.EventHandler(this.DatabaseSettings_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBox10;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox textBox11;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox textBox12;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user