OMNI: 01-16 - tests on 2020
This commit is contained in:
@@ -50,27 +50,18 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Content Include="bin\Debug\CommonConsole.exe" />
|
|
||||||
<Content Include="bin\Debug\CommonConsole.pdb" />
|
|
||||||
<Content Include="bin\Debug\test.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400032_aggregations.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400032_backwards.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400032_messurements.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400261_aggregations.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400261_backwards.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\193400261_messurements.txt" />
|
|
||||||
<Content Include="temperature_calibrations_26_10_2023\temp.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ExchangeHub\ExchangeHub.csproj">
|
<ProjectReference Include="..\ExchangeHub\ExchangeHub.csproj">
|
||||||
<Project>{6033FF0C-CF32-4BC5-8EFE-4774CCDC663D}</Project>
|
<Project>{6033FF0C-CF32-4BC5-8EFE-4774CCDC663D}</Project>
|
||||||
<Name>ExchangeHub</Name>
|
<Name>ExchangeHub</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OmniPlus\OmniPlus\OmniPlus.csproj">
|
||||||
|
<Project>{F8D84B9A-0FCF-4083-B067-8C39B7314152}</Project>
|
||||||
|
<Name>OmniPlus</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
<None Include="bin\Debug\CommonConsole.exe.config" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,47 +1,74 @@
|
|||||||
using System;
|
namespace CommonConsole
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CommonConsole
|
|
||||||
{
|
{
|
||||||
class Program
|
using OmniPlus.Connections;
|
||||||
{
|
using OmniPlus.Inspection;
|
||||||
static void Main()
|
using System;
|
||||||
{
|
using System.Collections.Generic;
|
||||||
var counter = 1;
|
|
||||||
|
|
||||||
void Executable()
|
public class Program
|
||||||
{
|
{
|
||||||
counter = 1;
|
private static readonly IDictionary<OmniPlusTestPoint, OmniPlusTest> results
|
||||||
|
= new SortedDictionary<OmniPlusTestPoint, OmniPlusTest>();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
public static void Main()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"counter = {counter}");
|
|
||||||
|
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var exception = new Exception("Task end");
|
//public static void Main()
|
||||||
|
//{
|
||||||
|
// var bytes = new byte[] {
|
||||||
|
// 0x9B, 0x83, 0x52, 0x61, 0x8C, 0xB7,
|
||||||
|
// 0x9B, 0x83, 0x54, 0x61, 0x5C, 0xE3,
|
||||||
|
// 0x9B, 0x83, 0x54, 0x61, 0x5C, 0xE3,
|
||||||
|
// 0x9B, 0x83, 0x54, 0x61, 0x5C, 0xE3,
|
||||||
|
// 0x9B, 0x83, 0x54, 0x61, 0x5C, 0xE3,
|
||||||
|
// 0x9B, 0x83, 0x54, 0x61, 0x5C, 0xE3,
|
||||||
|
// 0x9B, 0x83, 0x5C, 0x61, 0x9C, 0x2D,
|
||||||
|
// 0x9B, 0x83, 0x67, 0x61, 0x96, 0x7F,
|
||||||
|
// 0x9B, 0x83, 0x77, 0x61, 0x07, 0xEA,
|
||||||
|
// 0x9B, 0x83, 0x86, 0x61, 0xD7, 0x8F,
|
||||||
|
// 0x9B, 0x83, 0x95, 0x61, 0x2E, 0x30,
|
||||||
|
// 0x9B, 0x83, 0xA4, 0x61, 0x54, 0x9F,
|
||||||
|
// 0x9B, 0x83, 0xB2, 0x61, 0x15, 0x5E,
|
||||||
|
// 0x9B, 0x83, 0xC0, 0x61, 0x61, 0x9D,
|
||||||
|
// 0x9B, 0x83, 0xCF, 0x61, 0xA9, 0x1E,
|
||||||
|
// 0x9B, 0x83, 0xDD, 0x61, 0x88, 0xB8,
|
||||||
|
// 0x9B, 0x83, 0xEA, 0x61, 0x22, 0x43,
|
||||||
|
// 0x9B, 0x83, 0xF8, 0x61, 0x03, 0xE5,
|
||||||
|
// 0x9B, 0x83, 0x06, 0x62, 0x80, 0x31,
|
||||||
|
// 0x9B, 0x83, 0x13, 0x62, 0xA9, 0xDA,
|
||||||
|
// 0x9B, 0x83, 0x21, 0x62, 0xBB, 0x5F,
|
||||||
|
// 0x9B, 0x83, 0x2E, 0x62, 0x73, 0xDC,
|
||||||
|
// 0x9B, 0x83, 0x3B, 0x62, 0x5A, 0x37,
|
||||||
|
// 0x9B, 0x83, 0x48, 0x62, 0xF6, 0xED,
|
||||||
|
// 0x9B, 0x83, 0x55, 0x62, 0x1F, 0xC8,
|
||||||
|
// 0x9B, 0x83, 0x62, 0x62, 0xB5, 0x33,
|
||||||
|
// 0x9B, 0x83, 0x6F, 0x62, 0xCD, 0x83,
|
||||||
|
// 0x9B, 0x83, 0x7C, 0x62, 0x34, 0x3C,
|
||||||
|
// 0x9B, 0x83, 0x89, 0x62, 0x84, 0x3E,
|
||||||
|
// 0x9B, 0x83, 0x96, 0x62, 0xDD, 0x28,
|
||||||
|
// 0x9B, 0x83, 0xA2, 0x62, 0x1F, 0xF9,
|
||||||
|
// 0x9B, 0x43, 0x07, 0x0D, 0x0B, 0x00, 0x01, 0x00, 0xE8, 0x03, 0x28, 0x00, 0x00, 0x00, 0x01, 0x2C, 0x00, 0xC4, 0x0A,
|
||||||
|
// 0x9B, 0x83, 0xAF, 0x62, 0x67, 0x49,
|
||||||
|
// 0x9B, 0x83, 0xBC, 0x62, 0x9E, 0xF6
|
||||||
|
// };
|
||||||
|
|
||||||
Console.WriteLine(exception);
|
// for (int i = 0; i < 10000; i++)
|
||||||
Console.WriteLine();
|
// {
|
||||||
|
// if (bytes.FromIrdaMessage(out byte[] message, out int start, out int length))
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"{BitConverter.ToString(message)}");
|
||||||
|
|
||||||
throw exception;
|
// if (message.FromUI1236Message(out message, out start, out length))
|
||||||
}
|
// {
|
||||||
|
// Console.WriteLine($"{BitConverter.ToString(message)}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Console.WriteLine();
|
||||||
|
// }
|
||||||
|
|
||||||
Start(Executable).Wait();
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
static Task Start(Action action, int counter = 0)
|
|
||||||
=> Task.Factory
|
|
||||||
.StartNew(action)
|
|
||||||
.ContinueWith(_task =>
|
|
||||||
{
|
|
||||||
if (_task.Status == TaskStatus.Faulted && counter < 5)
|
|
||||||
{
|
|
||||||
Start(action, counter + 1).Wait();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
193400032 7.79 0.0009349163 7.87 0.0009350077 7.94 0.0009351075 0.15 0.0000001913 588
|
|
||||||
193400032 7.52 0.0009356649 7.59 0.0009358139 7.65 0.0009359014 0.13 0.0000002365 588
|
|
||||||
193400032 7.30 0.0009364027 7.35 0.0009364837 7.42 0.0009365601 0.12 0.0000001574 588
|
|
||||||
193400032 7.12 0.0009369290 7.16 0.0009370587 7.20 0.0009371273 0.08 0.0000001983 588
|
|
||||||
193400032 6.96 0.0009374927 6.99 0.0009375559 7.03 0.0009376381 0.07 0.0000001454 588
|
|
||||||
193400032 6.82 0.0009378943 6.86 0.0009379740 6.90 0.0009380245 0.08 0.0000001302 588
|
|
||||||
193400032 6.70 0.0009382241 6.73 0.0009383260 6.76 0.0009383711 0.06 0.0000001470 588
|
|
||||||
193400032 6.61 0.0009386028 6.63 0.0009386467 6.65 0.0009386776 0.04 0.0000000748 588
|
|
||||||
193400032 6.52 0.0009388800 6.54 0.0009389147 6.57 0.0009389955 0.05 0.0000001155 588
|
|
||||||
193400032 6.45 0.0009390722 6.47 0.0009391250 6.48 0.0009391386 0.03 0.0000000664 588
|
|
||||||
193400032 6.51 0.0009386210 6.54 0.0009386754 6.57 0.0009387576 0.06 0.0000001366 588
|
|
||||||
193400032 6.63 0.0009382142 6.70 0.0009382579 6.74 0.0009383050 0.11 0.0000000908 588
|
|
||||||
193400032 6.78 0.0009378723 6.82 0.0009379105 6.86 0.0009379686 0.08 0.0000000964 588
|
|
||||||
193400032 6.92 0.0009375803 6.96 0.0009376147 6.99 0.0009377037 0.07 0.0000001234 586
|
|
||||||
193400032 7.05 0.0009373287 7.08 0.0009373577 7.11 0.0009374157 0.06 0.0000000870 588
|
|
||||||
193400032 7.16 0.0009371124 7.19 0.0009371349 7.22 0.0009371664 0.06 0.0000000541 588
|
|
||||||
193400032 7.27 0.0009369012 7.30 0.0009369401 7.32 0.0009369628 0.05 0.0000000615 588
|
|
||||||
193400032 7.35 0.0009367571 7.38 0.0009367746 7.41 0.0009368095 0.06 0.0000000524 588
|
|
||||||
193400032 7.44 0.0009365113 7.48 0.0009366082 7.58 0.0009367125 0.14 0.0000002012 588
|
|
||||||
193400032 7.59 0.0009356581 7.64 0.0009357495 7.71 0.0009358800 0.12 0.0000002219 588
|
|
||||||
193400032 7.82 0.0009350038 7.90 0.0009350758 7.99 0.0009351510 0.17 0.0000001472 586
|
|
||||||
193400032 8.06 0.0009344710 8.12 0.0009345301 8.18 0.0009345890 0.12 0.0000001180 588
|
|
||||||
193400032 8.28 0.0009340253 8.34 0.0009340780 8.39 0.0009341763 0.11 0.0000001510 588
|
|
||||||
193400032 8.48 0.0009336423 8.53 0.0009336883 8.58 0.0009338160 0.10 0.0000001736 588
|
|
||||||
193400032 8.66 0.0009333056 8.70 0.0009333429 8.74 0.0009333830 0.08 0.0000000774 588
|
|
||||||
193400032 8.82 0.0009330021 8.85 0.0009330479 8.89 0.0009330852 0.07 0.0000000832 583
|
|
||||||
193400032 8.95 0.0009327554 8.99 0.0009327858 9.03 0.0009328262 0.08 0.0000000708 588
|
|
||||||
193400032 9.09 0.0009324061 9.15 0.0009325165 9.22 0.0009326281 0.13 0.0000002220 588
|
|
||||||
193400032 9.34 0.0009315012 9.42 0.0009316031 9.49 0.0009317885 0.15 0.0000002873 588
|
|
||||||
193400032 9.61 0.0009307933 9.69 0.0009308692 9.79 0.0009309571 0.18 0.0000001638 588
|
|
||||||
193400032 9.89 0.0009302263 9.96 0.0009302874 10.03 0.0009303414 0.14 0.0000001152 588
|
|
||||||
193400032 10.14 0.0009297522 10.20 0.0009298073 10.26 0.0009298848 0.12 0.0000001326 588
|
|
||||||
193400032 10.36 0.0009293589 10.41 0.0009294069 10.46 0.0009295412 0.10 0.0000001824 588
|
|
||||||
193400032 10.55 0.0009290188 10.60 0.0009290568 10.64 0.0009291908 0.09 0.0000001720 588
|
|
||||||
193400032 10.72 0.0009286811 10.76 0.0009287482 10.81 0.0009287849 0.09 0.0000001039 588
|
|
||||||
193400032 10.87 0.0009283086 10.91 0.0009284861 10.95 0.0009285146 0.08 0.0000002060 588
|
|
||||||
193400032 11.01 0.0009281019 11.07 0.0009282108 11.14 0.0009283080 0.13 0.0000002060 588
|
|
||||||
193400032 11.28 0.0009271987 11.38 0.0009272952 11.46 0.0009274956 0.18 0.0000002969 586
|
|
||||||
193400032 11.58 0.0009265027 11.67 0.0009265743 11.76 0.0009266599 0.18 0.0000001572 588
|
|
||||||
193400032 11.86 0.0009259387 11.94 0.0009260042 12.01 0.0009260928 0.15 0.0000001541 588
|
|
||||||
193400032 12.13 0.0009254881 12.18 0.0009255383 12.24 0.0009255912 0.11 0.0000001031 588
|
|
||||||
193400032 12.35 0.0009251070 12.41 0.0009251553 12.48 0.0009252444 0.13 0.0000001374 588
|
|
||||||
193400032 12.55 0.0009247705 12.59 0.0009248055 12.63 0.0009249234 0.08 0.0000001529 588
|
|
||||||
193400032 12.72 0.0009244896 12.76 0.0009245231 12.79 0.0009245660 0.07 0.0000000764 588
|
|
||||||
193400032 12.86 0.0009242402 12.90 0.0009242700 12.94 0.0009243430 0.08 0.0000001028 588
|
|
||||||
193400032 13.00 0.0009238864 13.07 0.0009239841 13.14 0.0009240717 0.14 0.0000001852 588
|
|
||||||
193400032 13.28 0.0009230217 13.38 0.0009231183 13.47 0.0009233080 0.19 0.0000002863 588
|
|
||||||
193400032 13.60 0.0009223489 13.68 0.0009224275 13.76 0.0009225998 0.16 0.0000002509 588
|
|
||||||
193400032 13.89 0.0009218076 13.96 0.0009218558 14.03 0.0009219329 0.14 0.0000001253 588
|
|
||||||
193400032 14.14 0.0009213673 14.20 0.0009214119 14.26 0.0009215478 0.12 0.0000001805 585
|
|
||||||
193400032 14.37 0.0009210025 14.42 0.0009210531 14.47 0.0009211478 0.10 0.0000001453 588
|
|
||||||
193400032 14.56 0.0009207023 14.61 0.0009207381 14.65 0.0009208340 0.09 0.0000001317 588
|
|
||||||
193400032 14.72 0.0009204160 14.77 0.0009204501 14.81 0.0009205388 0.09 0.0000001227 588
|
|
||||||
193400032 14.88 0.0009201998 14.91 0.0009202363 14.95 0.0009203275 0.07 0.0000001277 588
|
|
||||||
193400032 15.01 0.0009198856 15.07 0.0009199785 15.15 0.0009201416 0.14 0.0000002560 588
|
|
||||||
193400032 15.31 0.0009190478 15.38 0.0009191390 15.45 0.0009193003 0.14 0.0000002525 588
|
|
||||||
193400032 15.60 0.0009184094 15.68 0.0009184736 15.76 0.0009186136 0.16 0.0000002042 588
|
|
||||||
193400032 15.89 0.0009178966 15.96 0.0009179494 16.03 0.0009180538 0.14 0.0000001572 588
|
|
||||||
193400032 16.15 0.0009174893 16.22 0.0009175392 16.28 0.0009176070 0.13 0.0000001177 588
|
|
||||||
193400032 16.38 0.0009171583 16.43 0.0009171930 16.49 0.0009172710 0.11 0.0000001127 588
|
|
||||||
193400032 16.58 0.0009168484 16.62 0.0009168799 16.66 0.0009169244 0.08 0.0000000760 588
|
|
||||||
193400032 16.74 0.0009165946 16.78 0.0009166348 16.83 0.0009166869 0.09 0.0000000923 586
|
|
||||||
193400032 16.89 0.0009163918 16.93 0.0009164249 16.97 0.0009165767 0.08 0.0000001849 588
|
|
||||||
193400032 17.03 0.0009161036 17.09 0.0009161932 17.18 0.0009162617 0.15 0.0000001581 588
|
|
||||||
193400032 17.33 0.0009153065 17.40 0.0009153993 17.47 0.0009155825 0.14 0.0000002760 588
|
|
||||||
193400032 17.64 0.0009147272 17.71 0.0009147880 17.82 0.0009149186 0.18 0.0000001914 588
|
|
||||||
193400032 17.92 0.0009142437 17.98 0.0009143042 18.05 0.0009143692 0.13 0.0000001255 588
|
|
||||||
193400032 18.18 0.0009138526 18.23 0.0009139063 18.29 0.0009139520 0.11 0.0000000994 588
|
|
||||||
193400032 18.39 0.0009134828 18.45 0.0009135748 18.50 0.0009136381 0.11 0.0000001553 586
|
|
||||||
193400032 18.59 0.0009132655 18.63 0.0009133065 18.68 0.0009133656 0.09 0.0000001001 588
|
|
||||||
193400032 18.76 0.0009130305 18.80 0.0009130502 18.84 0.0009130861 0.08 0.0000000556 588
|
|
||||||
193400032 18.90 0.0009128155 18.94 0.0009128511 18.98 0.0009129203 0.08 0.0000001048 588
|
|
||||||
193400032 19.04 0.0009125494 19.10 0.0009126398 19.19 0.0009127790 0.15 0.0000002297 588
|
|
||||||
193400032 19.33 0.0009118257 19.40 0.0009119027 19.50 0.0009120472 0.17 0.0000002215 586
|
|
||||||
193400032 19.65 0.0009112872 19.71 0.0009113457 19.79 0.0009114711 0.14 0.0000001839 588
|
|
||||||
193400032 19.92 0.0009108292 19.99 0.0009108767 20.06 0.0009110267 0.14 0.0000001975 588
|
|
||||||
193400032 20.18 0.0009104835 20.24 0.0009105278 20.30 0.0009106393 0.12 0.0000001558 588
|
|
||||||
193400032 20.41 0.0009101556 20.46 0.0009102033 20.51 0.0009102333 0.10 0.0000000777 588
|
|
||||||
193400032 20.60 0.0009099114 20.64 0.0009099454 20.68 0.0009101014 0.08 0.0000001901 588
|
|
||||||
193400032 20.77 0.0009096950 20.81 0.0009097416 20.85 0.0009097936 0.08 0.0000000987 588
|
|
||||||
193400032 20.92 0.0009094771 20.96 0.0009095257 21.00 0.0009095827 0.08 0.0000001056 588
|
|
||||||
193400032 21.06 0.0009092659 21.12 0.0009093396 21.20 0.0009095133 0.14 0.0000002474 588
|
|
||||||
193400032 21.35 0.0009085983 21.42 0.0009086696 21.49 0.0009087657 0.14 0.0000001675 588
|
|
||||||
193400032 21.66 0.0009080864 21.73 0.0009081467 21.83 0.0009082678 0.17 0.0000001815 588
|
|
||||||
193400032 21.94 0.0009076667 22.01 0.0009077207 22.08 0.0009078068 0.14 0.0000001401 588
|
|
||||||
193400032 22.20 0.0009073224 22.26 0.0009073526 22.32 0.0009074466 0.12 0.0000001242 587
|
|
||||||
193400032 22.42 0.0009070449 22.48 0.0009070789 22.53 0.0009071967 0.11 0.0000001518 587
|
|
||||||
193400032 22.62 0.0009068056 22.66 0.0009068392 22.71 0.0009069791 0.09 0.0000001735 588
|
|
||||||
193400032 22.78 0.0009066013 22.83 0.0009066411 22.87 0.0009067711 0.09 0.0000001698 587
|
|
||||||
193400032 22.94 0.0009063945 22.98 0.0009064282 23.01 0.0009065623 0.07 0.0000001678 587
|
|
||||||
193400032 23.07 0.0009061788 23.14 0.0009062498 23.23 0.0009063542 0.16 0.0000001754 588
|
|
||||||
193400032 23.36 0.0009055490 23.43 0.0009056136 23.51 0.0009057026 0.15 0.0000001536 588
|
|
||||||
193400032 23.68 0.0009050370 23.76 0.0009050886 23.86 0.0009051576 0.18 0.0000001206 585
|
|
||||||
193400032 23.98 0.0009046379 24.05 0.0009046829 24.12 0.0009048408 0.14 0.0000002029 588
|
|
||||||
193400032 24.24 0.0009043106 24.30 0.0009043410 24.36 0.0009044145 0.12 0.0000001040 588
|
|
||||||
193400032 24.47 0.0009040457 24.52 0.0009040785 24.58 0.0009041423 0.11 0.0000000966 588
|
|
||||||
193400032 24.66 0.0009038151 24.70 0.0009038422 24.75 0.0009039223 0.09 0.0000001072 588
|
|
||||||
193400032 24.82 0.0009036411 24.86 0.0009036648 24.90 0.0009037129 0.08 0.0000000718 585
|
|
||||||
193400032 24.96 0.0009034793 25.00 0.0009034985 25.05 0.0009035630 0.09 0.0000000837 587
|
|
||||||
193400032 25.08 0.0009032915 25.13 0.0009033586 25.20 0.0009034174 0.12 0.0000001259 588
|
|
||||||
193400032 25.34 0.0009027183 25.43 0.0009027762 25.51 0.0009028513 0.17 0.0000001330 588
|
|
||||||
193400032 25.65 0.0009022703 25.73 0.0009023214 25.80 0.0009023802 0.15 0.0000001099 587
|
|
||||||
193400032 25.94 0.0009019029 26.01 0.0009019473 26.07 0.0009020457 0.13 0.0000001428 588
|
|
||||||
193400032 26.20 0.0009015946 26.26 0.0009016322 26.32 0.0009017231 0.12 0.0000001285 588
|
|
||||||
193400032 26.43 0.0009012783 26.48 0.0009013662 26.53 0.0009013948 0.10 0.0000001166 588
|
|
||||||
193400032 26.62 0.0009010991 26.67 0.0009011434 26.72 0.0009011814 0.10 0.0000000823 588
|
|
||||||
193400032 26.79 0.0009008210 26.83 0.0009009500 26.87 0.0009009772 0.08 0.0000001562 588
|
|
||||||
193400032 26.93 0.0009007905 26.97 0.0009008063 27.00 0.0009008878 0.07 0.0000000972 588
|
|
||||||
193400032 27.05 0.0009005920 27.11 0.0009006550 27.21 0.0009007498 0.16 0.0000001578 588
|
|
||||||
193400032 27.32 0.0009000583 27.41 0.0009001155 27.49 0.0009001743 0.17 0.0000001161 585
|
|
||||||
193400032 27.63 0.0008996459 27.71 0.0008996923 27.78 0.0008997393 0.15 0.0000000934 588
|
|
||||||
193400032 27.92 0.0008993049 27.98 0.0008993438 28.04 0.0008994024 0.12 0.0000000974 588
|
|
||||||
193400032 28.17 0.0008990187 28.24 0.0008990504 28.30 0.0008991146 0.13 0.0000000959 588
|
|
||||||
193400032 28.40 0.0008987781 28.45 0.0008988043 28.50 0.0008988747 0.10 0.0000000965 587
|
|
||||||
193400032 28.60 0.0008985610 28.64 0.0008985974 28.69 0.0008986229 0.09 0.0000000619 588
|
|
||||||
193400032 28.76 0.0008984059 28.80 0.0008984270 28.84 0.0008984596 0.08 0.0000000536 588
|
|
||||||
193400032 28.91 0.0008982606 28.94 0.0008982777 28.98 0.0008983158 0.07 0.0000000552 585
|
|
||||||
193400032 29.03 0.0008980719 29.09 0.0008981342 29.16 0.0008982055 0.13 0.0000001336 588
|
|
||||||
193400032 29.32 0.0008975729 29.39 0.0008976258 29.47 0.0008976888 0.15 0.0000001159 587
|
|
||||||
193400032 29.62 0.0008971886 29.69 0.0008972309 29.76 0.0008972751 0.14 0.0000000864 588
|
|
||||||
193400032 29.91 0.0008968716 29.98 0.0008969078 30.05 0.0008969614 0.14 0.0000000898 587
|
|
||||||
193400032 30.17 0.0008966058 30.23 0.0008966373 30.29 0.0008967292 0.12 0.0000001235 585
|
|
||||||
193400032 30.39 0.0008963822 30.45 0.0008964071 30.50 0.0008964331 0.11 0.0000000508 587
|
|
||||||
193400032 30.59 0.0008961876 30.64 0.0008962144 30.68 0.0008962368 0.09 0.0000000492 588
|
|
||||||
193400032 30.75 0.0008960080 30.80 0.0008960520 30.84 0.0008960712 0.09 0.0000000632 587
|
|
||||||
193400032 30.90 0.0008958998 30.93 0.0008959145 30.97 0.0008959718 0.07 0.0000000720 587
|
|
||||||
193400032 31.02 0.0008957159 31.08 0.0008957753 31.14 0.0008958742 0.12 0.0000001583 587
|
|
||||||
193400032 31.30 0.0008952459 31.38 0.0008952952 31.46 0.0008953865 0.16 0.0000001406 588
|
|
||||||
193400032 31.61 0.0008948823 31.68 0.0008949226 31.76 0.0008949645 0.15 0.0000000822 587
|
|
||||||
193400032 31.90 0.0008945690 31.97 0.0008946172 32.04 0.0008946524 0.14 0.0000000834 588
|
|
||||||
193400032 32.15 0.0008943366 32.22 0.0008943661 32.28 0.0008944434 0.13 0.0000001068 588
|
|
||||||
193400032 32.38 0.0008941287 32.44 0.0008941544 32.49 0.0008942609 0.11 0.0000001322 588
|
|
||||||
193400032 32.57 0.0008939540 32.62 0.0008939765 32.66 0.0008940059 0.09 0.0000000519 587
|
|
||||||
193400032 32.74 0.0008937941 32.78 0.0008938249 32.82 0.0008938430 0.08 0.0000000489 586
|
|
||||||
193400032 32.88 0.0008936732 32.91 0.0008937006 32.95 0.0008937342 0.07 0.0000000610 588
|
|
||||||
193400032 32.99 0.0008935182 33.05 0.0008935736 33.12 0.0008936907 0.13 0.0000001725 588
|
|
||||||
193400032 33.28 0.0008930874 33.36 0.0008931319 33.44 0.0008931785 0.16 0.0000000912 587
|
|
||||||
193400032 33.59 0.0008927542 33.66 0.0008927907 33.74 0.0008928298 0.15 0.0000000757 587
|
|
||||||
193400032 33.87 0.0008924810 33.94 0.0008925120 34.00 0.0008925587 0.13 0.0000000777 588
|
|
||||||
193400032 34.13 0.0008922573 34.18 0.0008922832 34.24 0.0008923304 0.11 0.0000000731 587
|
|
||||||
193400032 34.35 0.0008920682 34.40 0.0008920910 34.45 0.0008921539 0.10 0.0000000856 587
|
|
||||||
193400032 34.53 0.0008919127 34.58 0.0008919303 34.63 0.0008919892 0.10 0.0000000764 587
|
|
||||||
193400032 34.69 0.0008917797 34.73 0.0008917956 34.76 0.0008918235 0.07 0.0000000438 587
|
|
||||||
193400032 34.83 0.0008916563 34.86 0.0008916831 34.90 0.0008917155 0.07 0.0000000593 587
|
|
||||||
193400032 34.95 0.0008915962 34.96 0.0008915981 34.98 0.0008916580 0.03 0.0000000617 587
|
|
||||||
193400032 34.89 0.0008915896 34.92 0.0008916067 34.96 0.0008916442 0.07 0.0000000546 585
|
|
||||||
193400032 34.75 0.0008916466 34.79 0.0008916719 34.83 0.0008916955 0.08 0.0000000489 587
|
|
||||||
193400032 34.59 0.0008917296 34.63 0.0008917712 34.68 0.0008917856 0.09 0.0000000560 587
|
|
||||||
193400032 34.42 0.0008918384 34.46 0.0008918978 34.50 0.0008919153 0.08 0.0000000769 587
|
|
||||||
193400032 34.24 0.0008920280 34.29 0.0008920454 34.33 0.0008920897 0.09 0.0000000617 587
|
|
||||||
193400032 34.07 0.0008921767 34.11 0.0008922079 34.16 0.0008922253 0.09 0.0000000485 587
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,63 +0,0 @@
|
|||||||
193400261 6.02 0.0009392425 6.03 0.0009411937 6.05 0.0009416988 0.03 0.0000024563 576
|
|
||||||
193400261 6.01 0.0009393319 6.02 0.0009412432 6.04 0.0009431653 0.03 0.0000038333 566
|
|
||||||
193400261 6.09 0.0009387801 6.13 0.0009405516 6.18 0.0009425985 0.09 0.0000038184 565
|
|
||||||
193400261 6.28 0.0009381984 6.34 0.0009400291 6.38 0.0009420317 0.10 0.0000038333 565
|
|
||||||
193400261 6.49 0.0009377807 6.54 0.0009396311 6.59 0.0009415991 0.10 0.0000038184 551
|
|
||||||
193400261 6.68 0.0009374377 6.73 0.0009393290 6.77 0.0009412710 0.09 0.0000038333 544
|
|
||||||
193400261 6.85 0.0009371990 6.89 0.0009390768 6.93 0.0009410174 0.08 0.0000038184 560
|
|
||||||
193400261 7.01 0.0009369753 7.05 0.0009388430 7.08 0.0009408086 0.07 0.0000038333 559
|
|
||||||
193400261 7.15 0.0009367664 7.17 0.0009386809 7.20 0.0009405998 0.05 0.0000038333 561
|
|
||||||
193400261 7.25 0.0009365875 7.27 0.0009385313 7.30 0.0009404506 0.05 0.0000038632 528
|
|
||||||
193400261 7.33 0.0009364830 7.36 0.0009383757 7.39 0.0009403164 0.06 0.0000038333 569
|
|
||||||
193400261 7.48 0.0009363786 7.56 0.0009382420 7.62 0.0009401971 0.14 0.0000038184 547
|
|
||||||
193400261 7.77 0.0009362444 7.82 0.0009381664 7.88 0.0009400927 0.11 0.0000038483 445
|
|
||||||
193400261 8.00 0.0009361996 8.05 0.0009381043 8.11 0.0009400181 0.11 0.0000038184 564
|
|
||||||
193400261 8.23 0.0009361102 8.28 0.0009379931 8.34 0.0009399286 0.11 0.0000038184 541
|
|
||||||
193400261 8.45 0.0009360505 8.50 0.0009379356 8.54 0.0009398689 0.09 0.0000038184 533
|
|
||||||
193400261 8.66 0.0009359759 8.70 0.0009378712 8.74 0.0009398093 0.08 0.0000038333 449
|
|
||||||
193400261 9.01 0.0009359163 9.04 0.0009377975 9.08 0.0009397496 0.07 0.0000038333 469
|
|
||||||
193400261 9.62 0.0009367090 9.68 0.0009373762 9.75 0.0009393618 0.13 0.0000026528 587
|
|
||||||
193400261 9.90 0.0009352301 9.95 0.0009370899 10.01 0.0009390486 0.11 0.0000038184 531
|
|
||||||
193400261 10.14 0.0009350064 10.20 0.0009368401 10.25 0.0009388248 0.11 0.0000038184 555
|
|
||||||
193400261 10.38 0.0009347379 10.41 0.0009366516 10.44 0.0009385862 0.06 0.0000038483 256
|
|
||||||
193400261 10.57 0.0009352372 10.62 0.0009365810 10.67 0.0009385414 0.10 0.0000033042 585
|
|
||||||
193400261 10.78 0.0009344843 10.80 0.0009364646 10.82 0.0009383177 0.04 0.0000038333 233
|
|
||||||
193400261 10.98 0.0009344843 11.02 0.0009363802 11.06 0.0009385316 0.08 0.0000040473 642
|
|
||||||
193400261 11.15 0.0009343054 11.23 0.0009361851 11.30 0.0009381238 0.15 0.0000038184 552
|
|
||||||
193400261 11.42 0.0009341264 11.49 0.0009360142 11.57 0.0009379597 0.15 0.0000038333 529
|
|
||||||
193400261 11.71 0.0009339623 11.77 0.0009359739 11.83 0.0009377956 0.12 0.0000038333 328
|
|
||||||
193400261 12.00 0.0009339474 12.07 0.0009358156 12.13 0.0009377807 0.13 0.0000038333 585
|
|
||||||
193400261 12.26 0.0009338131 12.29 0.0009356585 12.32 0.0009376465 0.06 0.0000038333 209
|
|
||||||
193400261 12.96 0.0009337535 12.99 0.0009357100 13.04 0.0009376465 0.08 0.0000038930 819
|
|
||||||
193400261 13.14 0.0009336789 13.18 0.0009356075 13.24 0.0009374973 0.10 0.0000038184 229
|
|
||||||
193400261 13.40 0.0009341445 13.48 0.0009355429 13.54 0.0009374824 0.14 0.0000033379 584
|
|
||||||
193400261 13.69 0.0009335447 13.75 0.0009353696 13.81 0.0009373780 0.12 0.0000038333 335
|
|
||||||
193400261 14.05 0.0009335148 14.07 0.0009353909 14.10 0.0009373631 0.05 0.0000038483 304
|
|
||||||
193400261 14.22 0.0009334701 14.24 0.0009353549 14.26 0.0009372885 0.04 0.0000038184 198
|
|
||||||
193400261 14.43 0.0009334402 14.48 0.0009353251 14.54 0.0009371464 0.11 0.0000037061 584
|
|
||||||
193400261 15.88 0.0009333209 15.92 0.0009352583 16.02 0.0009371543 0.14 0.0000038333 1180
|
|
||||||
193400261 17.11 0.0009331867 17.13 0.0009350471 17.16 0.0009370200 0.05 0.0000038333 199
|
|
||||||
193400261 17.36 0.0009331419 17.44 0.0009351012 17.52 0.0009371924 0.16 0.0000040504 585
|
|
||||||
193400261 17.66 0.0009330972 17.73 0.0009350828 17.79 0.0009369454 0.13 0.0000038483 482
|
|
||||||
193400261 17.95 0.0009330673 18.00 0.0009349876 18.07 0.0009369007 0.12 0.0000038333 348
|
|
||||||
193400261 18.26 0.0009330226 18.28 0.0009350013 18.31 0.0009368858 0.05 0.0000038632 307
|
|
||||||
193400261 18.48 0.0009329779 19.12 0.0009348957 19.23 0.0009368261 0.75 0.0000038483 1029
|
|
||||||
193400261 19.67 0.0009328884 19.73 0.0009347954 19.81 0.0009367664 0.14 0.0000038781 706
|
|
||||||
193400261 20.25 0.0009328436 20.30 0.0009347765 20.37 0.0009367068 0.12 0.0000038632 691
|
|
||||||
193400261 20.85 0.0009328138 20.87 0.0009347445 20.90 0.0009366471 0.05 0.0000038333 430
|
|
||||||
193400261 21.00 0.0009327840 21.01 0.0009347230 21.03 0.0009366024 0.03 0.0000038184 120
|
|
||||||
193400261 21.40 0.0009327541 21.46 0.0009347010 21.54 0.0009366024 0.14 0.0000038483 629
|
|
||||||
193400261 21.69 0.0009327094 21.77 0.0009346280 21.83 0.0009365576 0.14 0.0000038483 560
|
|
||||||
193400261 22.87 0.0009326199 22.91 0.0009345334 22.96 0.0009364532 0.09 0.0000038333 587
|
|
||||||
193400261 23.58 0.0009325751 23.66 0.0009344785 23.74 0.0009364234 0.16 0.0000038483 571
|
|
||||||
193400261 24.91 0.0009325006 24.95 0.0009344148 24.98 0.0009363339 0.07 0.0000038333 580
|
|
||||||
193400261 25.06 0.0009324558 25.38 0.0009344330 25.46 0.0009363041 0.40 0.0000038483 698
|
|
||||||
193400261 26.23 0.0009324111 26.73 0.0009343240 26.82 0.0009362593 0.59 0.0000038483 921
|
|
||||||
193400261 27.63 0.0009323663 27.70 0.0009343291 27.76 0.0009362146 0.13 0.0000038483 535
|
|
||||||
193400261 28.15 0.0009323365 28.21 0.0009342437 28.27 0.0009361698 0.12 0.0000038333 677
|
|
||||||
193400261 28.97 0.0009322917 29.02 0.0009342231 29.07 0.0009361400 0.10 0.0000038483 583
|
|
||||||
193400261 29.86 0.0009322768 29.92 0.0009341635 29.98 0.0009361102 0.12 0.0000038333 562
|
|
||||||
193400261 30.12 0.0009322619 30.17 0.0009342142 30.22 0.0009360803 0.10 0.0000038184 266
|
|
||||||
193400261 31.99 0.0009322172 32.05 0.0009341761 32.12 0.0009362788 0.13 0.0000040616 716
|
|
||||||
193400261 33.17 0.0009322022 33.22 0.0009341488 33.32 0.0009360356 0.15 0.0000038333 1039
|
|
||||||
193400261 34.14 0.0009321724 34.19 0.0009341249 34.25 0.0009360057 0.11 0.0000038333 882
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
|||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 06.47, 0.0009391250, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 07.30, 0.0009369401, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 08.85, 0.0009330479, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 10.91, 0.0009284861, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 12.76, 0.0009245231, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 14.91, 0.0009202363, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 16.62, 0.0009168799, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 18.80, 0.0009130502, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 20.81, 0.0009097416, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 22.98, 0.0009064282, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 24.86, 0.0009036648, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 26.97, 0.0009008063, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 28.94, 0.0008982777, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 30.64, 0.0008962144, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 32.78, 0.0008938249, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400032, 34.73, 0.0008917956, 1);
|
|
||||||
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 34.07, 0.000892907528, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 33.03, 0.000893811517, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 32.06, 0.000894714143, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 31.03, 0.000895775645, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 30.05, 0.000896887993, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 29.00, 0.000898176183, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 28.00, 0.000899393868, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 27.08, 0.000900525206, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 26.00, 0.000901910933, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 25.06, 0.000903268325, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 24.00, 0.000904691165, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 23.01, 0.000906111094, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 22.00, 0.000907550173, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 21.06, 0.000908980642, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 20.01, 0.000910595651, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 19.00, 0.000912284434, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 18.04, 0.000913953382, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 17.00, 0.000915812810, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 16.01, 0.000917596480, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 15.00, 0.000919444201, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 14.00, 0.000921402464, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 13.00, 0.000923525768, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 12.01, 0.000925623590, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 11.01, 0.000927739979, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 10.00, 0.000930060122, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 09.01, 0.000932400030, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 08.00, 0.000934965232, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 07.01, 0.000937490784, 1);
|
|
||||||
INSERT INTO [CordonelTempLuts] ([PcbId], [RefTempC], [AvgTof], [Active]) VALUES (193400261, 06.00, 0.000940210180, 1);
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<Window x:Class="OMNIPruefung.EOLWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Height="450"
|
||||||
|
Width="800">
|
||||||
|
<DataGrid Background="White" HeadersVisibility="None" >
|
||||||
|
|
||||||
|
</DataGrid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace OMNIPruefung
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for EOLWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class EOLWindow : Window
|
||||||
|
{
|
||||||
|
public EOLWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<ContentVM:MainContentVM />
|
<ContentVM:MainContentVM />
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
|
|
||||||
<Grid Margin="0, 3, 0, 0">
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" MinWidth="230" />
|
<ColumnDefinition Width="Auto" MinWidth="230" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
@@ -43,6 +43,5 @@
|
|||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Background="White"/>
|
Background="White"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -57,30 +57,25 @@
|
|||||||
public string PSNR => this[nameof(PSNR)];
|
public string PSNR => this[nameof(PSNR)];
|
||||||
|
|
||||||
public IEnumerable<string> AllKeys => appsettings.AllKeys;
|
public IEnumerable<string> AllKeys => appsettings.AllKeys;
|
||||||
}
|
|
||||||
|
|
||||||
public class ExchangeHubSettings : Appsettings
|
|
||||||
{
|
|
||||||
public string ExchangeHubURL
|
public string ExchangeHubURL
|
||||||
{
|
{
|
||||||
get => base[nameof(this.ExchangeHubURL)];
|
get => this[nameof(this.ExchangeHubURL)];
|
||||||
set => base[nameof(this.ExchangeHubURL)] = value;
|
set => this[nameof(this.ExchangeHubURL)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ExchangeHubOutputDir
|
public string ExchangeHubOutputDir
|
||||||
{
|
{
|
||||||
get => base[nameof(this.ExchangeHubOutputDir)];
|
get => this[nameof(this.ExchangeHubOutputDir)];
|
||||||
set => base[nameof(this.ExchangeHubOutputDir)] = value;
|
set => this[nameof(this.ExchangeHubOutputDir)] = value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EOLSettings : Appsettings
|
internal COMPorts COMPorts
|
||||||
{
|
=> new COMPorts(this[nameof(COMPorts)]
|
||||||
public IEnumerable<string> COMPorts
|
|
||||||
=> this[nameof(COMPorts)]
|
|
||||||
?.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
?.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
?? new string[] { };
|
?? new string[] { });
|
||||||
|
|
||||||
public string OmniDB => this[nameof(OmniDB)];
|
public string OmniDB => this[nameof(OmniDB)];
|
||||||
|
|
||||||
|
internal static readonly Appsettings Current = new Appsettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
namespace OMNIPruefung.Models
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Ports;
|
||||||
|
|
||||||
|
internal class COMPorts : IEnumerable<string>
|
||||||
|
{
|
||||||
|
private readonly string[] comports;
|
||||||
|
private readonly string[] existing;
|
||||||
|
|
||||||
|
public COMPorts(string[] comports)
|
||||||
|
{
|
||||||
|
this.comports = comports;
|
||||||
|
this.existing = SerialPort.GetPortNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(string portName)
|
||||||
|
{
|
||||||
|
return Array.IndexOf(this.existing, portName) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<string> GetEnumerator()
|
||||||
|
{
|
||||||
|
foreach (var portName in this.comports)
|
||||||
|
{
|
||||||
|
yield return portName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return this.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
namespace OMNIPruefung.Models
|
||||||
|
{
|
||||||
|
using OmniPlus;
|
||||||
|
|
||||||
|
public class EOLContentM
|
||||||
|
{
|
||||||
|
private readonly OmniIrdaEOL eol;
|
||||||
|
|
||||||
|
public EOLContentM()
|
||||||
|
{
|
||||||
|
this.eol = new OmniIrdaEOL(Appsettings.Current.OmniDB);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Load()
|
||||||
|
{
|
||||||
|
//var comports = new COMPorts();
|
||||||
|
|
||||||
|
//foreach (var portName in comports)
|
||||||
|
//{
|
||||||
|
// if (comports.Exists(portName))
|
||||||
|
// {
|
||||||
|
// this.eol.AddConnection(portName);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,9 +57,14 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="EOLWindow.xaml.cs">
|
||||||
|
<DependentUpon>EOLWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Helpers\BooleanProgressBackgroundConverter.cs" />
|
<Compile Include="Helpers\BooleanProgressBackgroundConverter.cs" />
|
||||||
<Compile Include="Helpers\BooleanVisibilityConverter.cs" />
|
<Compile Include="Helpers\BooleanVisibilityConverter.cs" />
|
||||||
<Compile Include="Models\Appsettings.cs" />
|
<Compile Include="Models\Appsettings.cs" />
|
||||||
|
<Compile Include="Models\COMPorts.cs" />
|
||||||
|
<Compile Include="Models\EOLContentM.cs" />
|
||||||
<Compile Include="ViewModels\Content\SettingsContentVM.cs" />
|
<Compile Include="ViewModels\Content\SettingsContentVM.cs" />
|
||||||
<Compile Include="ViewModels\Features\OMNIPlusVM.cs" />
|
<Compile Include="ViewModels\Features\OMNIPlusVM.cs" />
|
||||||
<Compile Include="ViewModels\Base\Command.cs" />
|
<Compile Include="ViewModels\Base\Command.cs" />
|
||||||
@@ -93,6 +98,10 @@
|
|||||||
<Compile Include="Views\Options\Option.xaml.cs">
|
<Compile Include="Views\Options\Option.xaml.cs">
|
||||||
<DependentUpon>Option.xaml</DependentUpon>
|
<DependentUpon>Option.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="EOLWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -18,10 +17,10 @@
|
|||||||
|
|
||||||
public class COMContentVM : ContentVM
|
public class COMContentVM : ContentVM
|
||||||
{
|
{
|
||||||
private readonly Dictionary<OmniPlusTestPoint, OmniPlusTest> results
|
private readonly IDictionary<OmniPlusTestPoint, OmniPlusTest> results
|
||||||
= new Dictionary<OmniPlusTestPoint, OmniPlusTest>();
|
= new SortedDictionary<OmniPlusTestPoint, OmniPlusTest>();
|
||||||
|
|
||||||
private OmniPlusConnection connection;
|
private OmniConnection connection;
|
||||||
|
|
||||||
public COMContentVM() : base()
|
public COMContentVM() : base()
|
||||||
{
|
{
|
||||||
@@ -30,6 +29,31 @@
|
|||||||
this.Option.OptionSelected += this.NotifyOptionSelected;
|
this.Option.OptionSelected += this.NotifyOptionSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int nr;
|
||||||
|
public int Nr
|
||||||
|
{
|
||||||
|
get => this.nr;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.nr = value;
|
||||||
|
|
||||||
|
this.NotifyPropertyChanged(nameof(this.Nr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string portName;
|
||||||
|
public string PortName
|
||||||
|
{
|
||||||
|
get => this.portName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.portName = value;
|
||||||
|
this.connection = new OmniIrdaConnection(value);
|
||||||
|
|
||||||
|
this.NotifyPropertyChanged(nameof(this.PortName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int progress;
|
private int progress;
|
||||||
public int Progress
|
public int Progress
|
||||||
{
|
{
|
||||||
@@ -90,43 +114,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nr;
|
|
||||||
public int Nr
|
|
||||||
{
|
|
||||||
get => this.nr;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.nr = value;
|
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.Nr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string portName;
|
|
||||||
public string PortName
|
|
||||||
{
|
|
||||||
get => this.portName;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.portName = value;
|
|
||||||
this.connection = new OmniPlusConnection(value);
|
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.PortName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string testResults;
|
|
||||||
public string TestResults
|
|
||||||
{
|
|
||||||
get => this.testResults;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.testResults = value;
|
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.TestResults));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OMNIPlusVM Meter { get; }
|
public OMNIPlusVM Meter { get; }
|
||||||
|
|
||||||
internal void CancelExecution()
|
internal void CancelExecution()
|
||||||
@@ -149,39 +136,35 @@
|
|||||||
this.Header = $"{this.PortName}";
|
this.Header = $"{this.PortName}";
|
||||||
this.State = this.Header;
|
this.State = this.Header;
|
||||||
|
|
||||||
this.State = $"{this.Header} - wird ermittelt ...";
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Connected = this.connection.Connected;
|
this.connection.Open();
|
||||||
|
|
||||||
if (!this.Connected)
|
this.Connected = true;
|
||||||
{
|
this.Running = true;
|
||||||
this.Connected = this.connection.ConnectIrda();
|
|
||||||
this.Running = this.Connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.IsRunning())
|
if (this.IsRunning())
|
||||||
{
|
{
|
||||||
this.State = "Verbunden";
|
this.Header = $"{this.PortName}";
|
||||||
|
this.State = $"{this.PortName} verbunden";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.connection.Disconnect();
|
this.connection.Close();
|
||||||
|
|
||||||
this.Header = $"({this.PortName} - nicht verbunden!)";
|
this.Header = $"{this.PortName} - nicht verbunden!";
|
||||||
this.State = this.Header;
|
this.State = this.Header;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
this.connection.Disconnect();
|
this.connection.Close();
|
||||||
this.Header = $"({this.PortName} - nicht vorhanden!)";
|
this.Header = $"({this.PortName} - {e.Message}!)";
|
||||||
this.State = this.Header;
|
this.State = this.Header;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(Initialize, cancellationToken);
|
return Task.Factory.StartNew(Initialize, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Task ReadSystemParametersAsync(CancellationToken cancelationToken)
|
internal Task ReadSystemParametersAsync(CancellationToken cancelationToken)
|
||||||
@@ -193,30 +176,15 @@
|
|||||||
if (this.IsRunning())
|
if (this.IsRunning())
|
||||||
{
|
{
|
||||||
var response = this.connection.ViewSystemParameters();
|
var response = this.connection.ViewSystemParameters();
|
||||||
|
this.Running = response.IsValid;
|
||||||
|
this.Header = response.BuildInfo.Value;
|
||||||
|
this.Progress += 10;
|
||||||
|
|
||||||
this.Meter.Add(response);
|
this.Meter.Add(response);
|
||||||
|
|
||||||
this.Header = response.BuildInfo.Value;
|
|
||||||
this.Running = response.IsValid;
|
|
||||||
|
|
||||||
if (this.Running)
|
|
||||||
{
|
|
||||||
this.State = "Systemeigenschaften gelesen und validiert";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.State = "Systemeigenschaften konnten nicht gelesen werden";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Progress += 10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.State += $" (Verbindung unterbrochen)";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(ReadSystemParameters, cancelationToken);
|
return Task.Factory.StartNew(ReadSystemParameters, cancelationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Task SetInputVolumeAsync(OmniPlusType defaults, CancellationToken cancelationToken)
|
internal Task SetInputVolumeAsync(OmniPlusType defaults, CancellationToken cancelationToken)
|
||||||
@@ -225,31 +193,26 @@
|
|||||||
|
|
||||||
void SetInputVolume()
|
void SetInputVolume()
|
||||||
{
|
{
|
||||||
if (this.Connected)
|
if (this.IsRunning())
|
||||||
{
|
{
|
||||||
var response = this.connection.Set(defaults.InputVolume);
|
var response = this.connection.Set(defaults.InputVolume);
|
||||||
this.Running = response.Succeeded;
|
this.Running = response.Succeeded;
|
||||||
|
this.Progress += 10;
|
||||||
|
|
||||||
if (this.Running)
|
if (this.Running)
|
||||||
{
|
{
|
||||||
this.Meter.Add(defaults.InputVolume);
|
this.Meter.Add(defaults.InputVolume);
|
||||||
|
|
||||||
this.State = "Flow-Eigenschaften konfiguriert";
|
this.State = $"{this.Header}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.State = $"Flow-Eigenschaften: ({(int)response.Status} - {response.Status})";
|
this.State = $"{this.Header} - {response.Status}";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Progress += 10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.State += $" (Verbindung unterbrochen)";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(SetInputVolume, cancelationToken);
|
return Task.Factory.StartNew(SetInputVolume, cancelationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Task StartPPCalibrationAsync(OmniPlusTestPoint pp, CancellationToken cancellationToken)
|
internal Task StartPPCalibrationAsync(OmniPlusTestPoint pp, CancellationToken cancellationToken)
|
||||||
@@ -264,28 +227,28 @@
|
|||||||
{
|
{
|
||||||
var rotations = pp.Rotations;
|
var rotations = pp.Rotations;
|
||||||
var duration = pp.Duration;
|
var duration = pp.Duration;
|
||||||
var activationResponse = connection.StartChamberCalibration(pp.Rotations, pp.Duration);
|
var response = connection.StartChamberCalibration(pp.Rotations, pp.Duration);
|
||||||
this.Running = activationResponse.Succeeded && activationResponse.Control == ChamberCalibrationResponse.TEST_ACTIVATED;
|
|
||||||
|
this.Running = response.Succeeded && response.Control == ChamberCalibrationResponse.TEST_ACTIVATED;
|
||||||
|
this.Progress += 10;
|
||||||
|
|
||||||
this.Meter.Add(pp);
|
this.Meter.Add(pp);
|
||||||
|
|
||||||
if (this.Running)
|
if (this.Running)
|
||||||
{
|
{
|
||||||
this.State = $"PP {rotations}/{duration} (rotations/seconds) wurde gestarted.";
|
this.State = $"{this.Header} PP {rotations}/{duration}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.State = $"PP {rotations}/{duration} (rotations/seconds): {(int)activationResponse.Status} - {activationResponse.Status}";
|
this.State = $"{this.Header} PP {rotations}/{duration}, Status:{response.Status}, Control:{response.Control}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Progress += 10;
|
return Task.Factory.StartNew(StartPPCalibration, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(StartPPCalibration, cancellationToken);
|
internal Task StopPPCalibrationAsync(OmniPlusTestPoint pp, double referenceFlowM3S, CancellationToken cancellationToken)
|
||||||
}
|
|
||||||
|
|
||||||
internal Task StopPPCalibrationAsync(OmniPlusTestPoint pp, double referenceV, CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
cancellationToken.Register(this.CancelExecution);
|
cancellationToken.Register(this.CancelExecution);
|
||||||
|
|
||||||
@@ -293,55 +256,40 @@
|
|||||||
{
|
{
|
||||||
if (this.IsRunning())
|
if (this.IsRunning())
|
||||||
{
|
{
|
||||||
var calibrationResult = connection.ViewChamberCalibration();
|
var resonse = connection.ViewChamberCalibration();
|
||||||
this.results[pp].Rotations = calibrationResult.Rotations;
|
|
||||||
this.results[pp].Duration = calibrationResult.DurationSec;
|
|
||||||
this.results[pp].MeterVolume = pp.VolumeM3(this.results[pp]);
|
|
||||||
this.results[pp].VolumeMessured = referenceV;
|
|
||||||
|
|
||||||
this.Running = calibrationResult.Succeeded && calibrationResult.Control == ChamberCalibrationResponse.TEST_COMPLETED;
|
this.results[pp].Rotations = resonse.Rotations;
|
||||||
|
this.results[pp].Duration = resonse.Duration;
|
||||||
|
this.results[pp].MeterFlowM3S = pp.MeterFlowM3S(this.results[pp]);
|
||||||
|
this.results[pp].ReferenceFlowM3S = referenceFlowM3S;
|
||||||
|
|
||||||
|
this.Running = resonse.Succeeded && resonse.Control == ChamberCalibrationResponse.TEST_COMPLETED;
|
||||||
|
|
||||||
this.Meter.Add(this.results[pp]);
|
this.Meter.Add(this.results[pp]);
|
||||||
|
|
||||||
if (this.Running)
|
if (this.Running)
|
||||||
{
|
{
|
||||||
this.State = $"PP {pp.Rotations}/{pp.Duration} (rotations/seconds) wurde durchgeführt.";
|
this.State = $"{this.Header} PP {pp.Rotations}/{pp.Duration} - completed.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.State = $"PP {pp.Rotations}/{pp.Duration} fehlgeschlagen: {(int)calibrationResult.Control} - {calibrationResult.Control}";
|
this.State = $"{this.Header} PP {pp.Rotations}/{pp.Duration} failed: Status:{resonse.Status}, Control:{resonse.Control}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Progress += 10;
|
this.Progress += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(StopPPCalibration, cancellationToken);
|
return Task.Factory.StartNew(StopPPCalibration, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Task FinishInspectionAsync(CancellationToken cancellationToken)
|
internal Task SetRegisterSettingsAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.Register(this.CancelExecution);
|
cancellationToken.Register(this.CancelExecution);
|
||||||
|
|
||||||
void FinishInspection()
|
void SetRegisterSettings()
|
||||||
{
|
{
|
||||||
if (!this.IsRunning())
|
if (this.IsRunning())
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var configurationParameters = this.connection.ViewConfigurationParameters();
|
|
||||||
var canContinue = configurationParameters.Succeeded;
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
this.Meter.Add(configurationParameters);
|
|
||||||
// TODO: Uncomment in production
|
|
||||||
// var systemTimeReset = connection.SetSystemTime();
|
|
||||||
//canContinue = systemTimeReset.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
{
|
||||||
var registerSettings = new RegisterSettings();
|
var registerSettings = new RegisterSettings();
|
||||||
|
|
||||||
@@ -360,168 +308,233 @@
|
|||||||
registerSettings.PulseUpdate = 0x00;
|
registerSettings.PulseUpdate = 0x00;
|
||||||
|
|
||||||
var response = this.connection.Set(registerSettings);
|
var response = this.connection.Set(registerSettings);
|
||||||
canContinue = response.Succeeded;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (canContinue)
|
return Task.Factory.StartNew(SetRegisterSettings, cancellationToken);
|
||||||
{
|
|
||||||
var configurationParametersSet = new ConfigurationParametersSet();
|
|
||||||
configurationParametersSet.ProgrammableID = this.Meter.BuildInfo;
|
|
||||||
configurationParametersSet.FactoryID = this.Meter.BuildInfo;
|
|
||||||
configurationParametersSet.NumberOfReadingDigits = 8;
|
|
||||||
configurationParametersSet.ReadingPreset = "000000000";
|
|
||||||
configurationParametersSet.OptionalUniDirFields = 1;
|
|
||||||
configurationParametersSet.AlarmPercistancePeriodDays = 31;
|
|
||||||
configurationParametersSet.DataLogIntervalMinutes = 60;
|
|
||||||
configurationParametersSet.ManifacturingTime = Epoch20000101.UTCNow - 30000;
|
|
||||||
configurationParametersSet.SystemTime = Epoch20000101.UTCNow;
|
|
||||||
configurationParametersSet.RebootCount = 0;
|
|
||||||
configurationParametersSet.BuildInfo = this.Meter.BuildInfo;
|
|
||||||
|
|
||||||
var response = this.connection.Set(configurationParametersSet);
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (canContinue)
|
internal Task FinishInspectionAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var response = this.connection.ClearDisplay();
|
cancellationToken.Register(this.CancelExecution);
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
void FinishInspection()
|
||||||
{
|
{
|
||||||
var response = this.connection.Set(new LeakAlarm
|
//if (!this.IsRunning())
|
||||||
{
|
|
||||||
FlowRateGal = 0.25F, // 0.25 gpm
|
|
||||||
TimeLimit = 24 * 60 * 60 // 24 hours => 86400sec
|
|
||||||
});
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.Set(new HighFlowAlarm
|
|
||||||
{
|
|
||||||
FlowRateGal = 25F, // 25 gpm
|
|
||||||
TimeLimit = 1 * 60 * 60 // 1 hours => 86400sec
|
|
||||||
});
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.Set(new ReverseFlowAlarm
|
|
||||||
{
|
|
||||||
FlowRateGal = -1F, // -1 gpm
|
|
||||||
TimeLimit = 60 // 1 hours => 86400sec
|
|
||||||
});
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.ClearAlarms();
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var alarmsState = this.connection.ViewAlarmsState();
|
|
||||||
canContinue = alarmsState.Succeeded;
|
|
||||||
//&& alarmsState.UsrEnabled
|
|
||||||
//&& alarmsState.PreEnabledInactive;
|
|
||||||
//TODO: Check alarms
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.EnableNFC();
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var registerSettingsAfter = this.connection.ViewRegisterSettings();
|
|
||||||
//canContinue = registerSettingsAfter.Succeeded
|
|
||||||
// && meter.Compare(registerSettingsAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var systemParametersAfter = this.connection.ViewSystemParameters();
|
|
||||||
canContinue = systemParametersAfter.Succeeded;
|
|
||||||
//&& meter.Compare(systemParametersAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var configurationParametersAfter = this.connection.ViewConfigurationParameters();
|
|
||||||
canContinue = configurationParametersAfter.Succeeded;
|
|
||||||
//&& meter.Compare(configurationParametersAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var alarmsState = this.connection.ViewAlarmsState();
|
|
||||||
canContinue = alarmsState.Succeeded;
|
|
||||||
//&& alarmsState.UsrEnabled
|
|
||||||
//&& alarmsState.PreEnabledInactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.ViewAlarmSettings(0x01);
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.ViewAlarmSettings(0x02);
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
{
|
|
||||||
var response = this.connection.ViewAlarmSettings(0x04);
|
|
||||||
canContinue = response.Succeeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canContinue)
|
|
||||||
{
|
|
||||||
//connection.Set(new FactorySeal
|
|
||||||
//{
|
//{
|
||||||
// Sealed = true,
|
// return;
|
||||||
//});
|
//}
|
||||||
|
|
||||||
//var factorySeal = connection.ViewFactorySeal();
|
//var configurationParameters = this.connection.ViewConfigurationParameters();
|
||||||
//canContinue = factorySeal.Succeeded && factorySeal.Sealed;
|
//var canContinue = configurationParameters.Succeeded;
|
||||||
}
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// this.Meter.Add(configurationParameters);
|
||||||
|
// // TODO: Uncomment in production
|
||||||
|
// // var systemTimeReset = connection.SetSystemTime();
|
||||||
|
// //canContinue = systemTimeReset.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var registerSettings = new RegisterSettings();
|
||||||
|
|
||||||
|
// registerSettings.IntPart = this.Meter.IntPart;
|
||||||
|
// registerSettings.Fraction = this.Meter.Fraction;
|
||||||
|
// registerSettings.Size = this.Meter.Size;
|
||||||
|
// registerSettings.Range = this.Meter.Range;
|
||||||
|
// registerSettings.VolumePerPulseUnit = 0x00;
|
||||||
|
// registerSettings.MeterUnits = (byte)MessurementUnits.USGallons;
|
||||||
|
// registerSettings.FlowUnits = (byte)MessurementUnits.USGallons;
|
||||||
|
// registerSettings.FlowRate = (byte)TimeUnits.Minutes;
|
||||||
|
// registerSettings.FactoryCorrection = this.Meter.FactoryCorrection;
|
||||||
|
// registerSettings.FieldCorrection = 0x00;
|
||||||
|
// registerSettings.PulseWeight = 0x01;
|
||||||
|
// registerSettings.PulseWidth = 0x02;
|
||||||
|
// registerSettings.PulseUpdate = 0x00;
|
||||||
|
|
||||||
|
// var response = this.connection.Set(registerSettings);
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var configurationParametersSet = new ConfigurationParametersSet();
|
||||||
|
// configurationParametersSet.ProgrammableID = this.Meter.BuildInfo;
|
||||||
|
// configurationParametersSet.FactoryID = this.Meter.BuildInfo;
|
||||||
|
// configurationParametersSet.NumberOfReadingDigits = 8;
|
||||||
|
// configurationParametersSet.ReadingPreset = "000000000";
|
||||||
|
// configurationParametersSet.OptionalUniDirFields = 1;
|
||||||
|
// configurationParametersSet.AlarmPercistancePeriodDays = 31;
|
||||||
|
// configurationParametersSet.DataLogIntervalMinutes = 60;
|
||||||
|
// configurationParametersSet.ManifacturingTime = Epoch20000101.UTCNow - 30000;
|
||||||
|
// configurationParametersSet.SystemTime = Epoch20000101.UTCNow;
|
||||||
|
// configurationParametersSet.RebootCount = 0;
|
||||||
|
// configurationParametersSet.BuildInfo = this.Meter.BuildInfo;
|
||||||
|
|
||||||
|
// var response = this.connection.Set(configurationParametersSet);
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.ClearDisplay();
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.Set(new LeakAlarm
|
||||||
|
// {
|
||||||
|
// FlowRateGal = 0.25F, // 0.25 gpm
|
||||||
|
// TimeLimit = 24 * 60 * 60 // 24 hours => 86400sec
|
||||||
|
// });
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.Set(new HighFlowAlarm
|
||||||
|
// {
|
||||||
|
// FlowRateGal = 25F, // 25 gpm
|
||||||
|
// TimeLimit = 1 * 60 * 60 // 1 hours => 86400sec
|
||||||
|
// });
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.Set(new ReverseFlowAlarm
|
||||||
|
// {
|
||||||
|
// FlowRateGal = -1F, // -1 gpm
|
||||||
|
// TimeLimit = 60 // 1 hours => 86400sec
|
||||||
|
// });
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.ClearAlarms();
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var alarmsState = this.connection.ViewAlarmsState();
|
||||||
|
// canContinue = alarmsState.Succeeded;
|
||||||
|
// //&& alarmsState.UsrEnabled
|
||||||
|
// //&& alarmsState.PreEnabledInactive;
|
||||||
|
// //TODO: Check alarms
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.EnableNFC();
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var registerSettingsAfter = this.connection.ViewRegisterSettings();
|
||||||
|
// //canContinue = registerSettingsAfter.Succeeded
|
||||||
|
// // && meter.Compare(registerSettingsAfter);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var systemParametersAfter = this.connection.ViewSystemParameters();
|
||||||
|
// canContinue = systemParametersAfter.Succeeded;
|
||||||
|
// //&& meter.Compare(systemParametersAfter);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var configurationParametersAfter = this.connection.ViewConfigurationParameters();
|
||||||
|
// canContinue = configurationParametersAfter.Succeeded;
|
||||||
|
// //&& meter.Compare(configurationParametersAfter);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var alarmsState = this.connection.ViewAlarmsState();
|
||||||
|
// canContinue = alarmsState.Succeeded;
|
||||||
|
// //&& alarmsState.UsrEnabled
|
||||||
|
// //&& alarmsState.PreEnabledInactive;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.ViewAlarmSettings(0x01);
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.ViewAlarmSettings(0x02);
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// if (canContinue)
|
||||||
|
//{
|
||||||
|
// var response = this.connection.ViewAlarmSettings(0x04);
|
||||||
|
// canContinue = response.Succeeded;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (canContinue)
|
||||||
|
//{
|
||||||
|
// //connection.Set(new FactorySeal
|
||||||
|
// //{
|
||||||
|
// // Sealed = true,
|
||||||
|
// //});
|
||||||
|
|
||||||
|
// //var factorySeal = connection.ViewFactorySeal();
|
||||||
|
// //canContinue = factorySeal.Succeeded && factorySeal.Sealed;
|
||||||
|
//}
|
||||||
|
|
||||||
this.Progress = 100;
|
this.Progress = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.StartNew(FinishInspection, cancellationToken);
|
return Task.Factory.StartNew(FinishInspection, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SaveInspection(StringBuilder results)
|
internal Task GetRegisterSettingsAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (results.Length <= 1)
|
cancellationToken.Register(this.CancelExecution);
|
||||||
|
|
||||||
|
void GetRegisterSettings()
|
||||||
{
|
{
|
||||||
results.AppendLine(string.Join(";", this.Meter.Results.Select(x => x.Key)));
|
if (this.IsRunning())
|
||||||
|
{
|
||||||
|
var response = this.connection.ViewRegisterSettings();
|
||||||
|
|
||||||
|
if (response.Succeeded)
|
||||||
|
{
|
||||||
|
this.Meter.AddResult("<<< Correction factor", $"{response.FactoryCorrection / 10D:0.00} %");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results.AppendLine(string.Join(";", this.Meter.Results.Select(x => x.Value)));
|
return Task.Factory.StartNew(GetRegisterSettings, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal double GetCorrectionFactor()
|
internal double GetCorrectionFactor()
|
||||||
{
|
{
|
||||||
var correction = this.results
|
var deviations = this.results
|
||||||
.OrderBy(x => x.Key.GalPerMin)
|
.OrderBy(x => x.Key.GPM)
|
||||||
.Select(x => x.Value.DifferencePercentage)
|
.Select(x => x.Value.DifferencePercentage())
|
||||||
.ToArray()
|
.ToArray();
|
||||||
.GetCorrectionFactor();
|
|
||||||
|
|
||||||
this.State = $"Korekturfaktor: {correction:0.00} %";
|
var correction = deviations.GetCorrectionFactor();
|
||||||
|
var correctionUnit = 1 + correction / 100;
|
||||||
|
|
||||||
|
this.State = $"{this.Header}, correction: {correction:0.00} %";
|
||||||
|
this.Meter.AddFactoryCorrection(correction);
|
||||||
|
|
||||||
|
foreach (var deviation in deviations)
|
||||||
|
{
|
||||||
|
this.Meter.AddResult($"{deviation:0.00} %", $"{deviation * correctionUnit:0.00} %");
|
||||||
|
}
|
||||||
|
|
||||||
return correction;
|
return correction;
|
||||||
}
|
}
|
||||||
@@ -530,7 +543,7 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.connection?.Disconnect();
|
this.connection?.Close();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -538,30 +551,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsRunning()
|
public bool IsRunning()
|
||||||
{
|
{
|
||||||
if (!this.Running)
|
if (!this.Running)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Connected = this.connection.Connected;
|
|
||||||
|
|
||||||
return this.Connected;
|
return this.Connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task StartNew(Action action, CancellationToken cancellationToken, int counter = 3)
|
|
||||||
{
|
|
||||||
return Task
|
|
||||||
.Factory
|
|
||||||
.StartNew(action, cancellationToken);
|
|
||||||
//.ContinueWith(task =>
|
|
||||||
//{
|
|
||||||
// if (task.Status == TaskStatus.Faulted && counter > 0)
|
|
||||||
// {
|
|
||||||
// StartNew(action, cancellationToken, counter - 1).Wait();
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -23,13 +22,11 @@
|
|||||||
{
|
{
|
||||||
private static readonly string line = new string('=', 500);
|
private static readonly string line = new string('=', 500);
|
||||||
|
|
||||||
private readonly EOLSettings omnisettings;
|
|
||||||
private readonly ExchangeHubSettings hubsettings;
|
|
||||||
private readonly ExchangeConnection exchangeConnection;
|
private readonly ExchangeConnection exchangeConnection;
|
||||||
|
private readonly OmniDatabase dbcontext;
|
||||||
|
|
||||||
private CancellationTokenSource cancellationTokenSource;
|
private CancellationTokenSource cancellationTokenSource;
|
||||||
private CancellationToken cancellationToken;
|
private CancellationToken cancellationToken;
|
||||||
private OmniPlusDatabase dbcontext;
|
|
||||||
private ManualResetEventSlim awaiter;
|
private ManualResetEventSlim awaiter;
|
||||||
private ICollection<Task> tasks;
|
private ICollection<Task> tasks;
|
||||||
private TimersTimer timer;
|
private TimersTimer timer;
|
||||||
@@ -41,22 +38,17 @@
|
|||||||
this.CanStart = true;
|
this.CanStart = true;
|
||||||
this.CanCheck = true;
|
this.CanCheck = true;
|
||||||
this.Option = new EOLOptionVM(this);
|
this.Option = new EOLOptionVM(this);
|
||||||
this.OmniDefaults = new OmniPlusType();
|
this.Option.OptionSelected += this.NotifyOptionSelected;
|
||||||
|
|
||||||
this.tasks = new List<Task>();
|
this.tasks = new List<Task>();
|
||||||
this.omnisettings = new EOLSettings();
|
|
||||||
this.hubsettings = new ExchangeHubSettings();
|
|
||||||
this.exchangeConnection = new ExchangeConnection();
|
this.exchangeConnection = new ExchangeConnection();
|
||||||
this.dbcontext = new OmniPlusDatabase(this.omnisettings.OmniDB);
|
this.dbcontext = new OmniDatabase(Appsettings.Current.OmniDB);
|
||||||
|
this.OmniDefaults = new OmniPlusType();
|
||||||
|
|
||||||
this.LoadComPorts = new Command(this.PrepareConnections);
|
this.LoadComPorts = new Command(this.PrepareConnections);
|
||||||
this.CancelInspection = new Command(this.CancelInspectionHandler);
|
this.CancelInspection = new Command(this.CancelInspectionHandler);
|
||||||
this.StartInspection = new Command(this.StartInspectionHandler);
|
this.StartInspection = new Command(this.StartInspectionHandler);
|
||||||
this.CheckInspection = new Command(this.CheckInspectionHandler);
|
this.CheckInspection = new Command(this.CheckInspectionHandler);
|
||||||
|
|
||||||
this.Option.OptionSelected += this.NotifyOptionSelected;
|
|
||||||
|
|
||||||
this.PrepareConnections();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int size;
|
private int size;
|
||||||
@@ -204,8 +196,7 @@
|
|||||||
this.State = e.ToString();
|
this.State = e.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.exchangeConnection.Disconnect();
|
this.exchangeConnection.Connect(Appsettings.Current.ExchangeHubURL);
|
||||||
this.exchangeConnection.Connect(this.hubsettings.ExchangeHubURL);
|
|
||||||
|
|
||||||
if (this.Size == 0 || this.Type is null)
|
if (this.Size == 0 || this.Type is null)
|
||||||
{
|
{
|
||||||
@@ -230,14 +221,13 @@
|
|||||||
|
|
||||||
this.dbcontext.LoadOmniDefaults((byte)this.Size, this.Type, this.OmniDefaults);
|
this.dbcontext.LoadOmniDefaults((byte)this.Size, this.Type, this.OmniDefaults);
|
||||||
this.NotifyPropertyChanged(nameof(this.OmniDefaults));
|
this.NotifyPropertyChanged(nameof(this.OmniDefaults));
|
||||||
|
|
||||||
this.Text = $"ME OMNI 1.5-2\" {this.Type}";
|
this.Text = $"ME OMNI 1.5-2\" {this.Type}";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var placeNr = 1;
|
var placeNr = 1;
|
||||||
|
|
||||||
foreach (var com in this.omnisettings.COMPorts)
|
foreach (var com in Appsettings.Current.COMPorts)
|
||||||
{
|
{
|
||||||
var comVM = new COMContentVM();
|
var comVM = new COMContentVM();
|
||||||
comVM.ContentSelected += this.NotifyCotnentSelected;
|
comVM.ContentSelected += this.NotifyCotnentSelected;
|
||||||
@@ -271,6 +261,7 @@
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
this.Error = e.ToString();
|
this.Error = e.ToString();
|
||||||
|
this.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.CanStop = false;
|
this.CanStop = false;
|
||||||
@@ -289,8 +280,9 @@
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
this.exchangeConnection.SendStopFlow();
|
||||||
this.exchangeConnection.Disconnect();
|
this.exchangeConnection.Disconnect();
|
||||||
this.awaiter.Set();
|
this.awaiter?.Set();
|
||||||
this.cancellationTokenSource?.Cancel();
|
this.cancellationTokenSource?.Cancel();
|
||||||
this.tasks.Clear();
|
this.tasks.Clear();
|
||||||
|
|
||||||
@@ -300,6 +292,7 @@
|
|||||||
{
|
{
|
||||||
this.Error = e.ToString();
|
this.Error = e.ToString();
|
||||||
this.State = default(string);
|
this.State = default(string);
|
||||||
|
this.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
@@ -334,6 +327,22 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
|
{
|
||||||
|
foreach (var meterVM in metersVM)
|
||||||
|
{
|
||||||
|
tasks.Add(meterVM.SetRegisterSettingsAsync(cancellationToken));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
|
{
|
||||||
|
foreach (var meterVM in metersVM)
|
||||||
|
{
|
||||||
|
tasks.Add(meterVM.GetRegisterSettingsAsync(cancellationToken));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
foreach (var pp in this.OmniDefaults.TestPoints)
|
foreach (var pp in this.OmniDefaults.TestPoints)
|
||||||
{
|
{
|
||||||
if (this.canceled)
|
if (this.canceled)
|
||||||
@@ -344,17 +353,21 @@
|
|||||||
var rotations = pp.Rotations;
|
var rotations = pp.Rotations;
|
||||||
var duration = pp.Duration;
|
var duration = pp.Duration;
|
||||||
|
|
||||||
this.StartFlow(pp.VolumeM3H);
|
this.StartFlow(pp.RequiredFlowM3H);
|
||||||
|
|
||||||
if (this.canceled)
|
if (this.canceled)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.InvokeAsync((tasks, cancellationToken) =>
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
{
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
|
// this.canceled = this.canceled || meterVM.IsRunning();
|
||||||
|
|
||||||
tasks.Add(meterVM.StartPPCalibrationAsync(pp, cancellationToken));
|
tasks.Add(meterVM.StartPPCalibrationAsync(pp, cancellationToken));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -366,20 +379,27 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.WaitUntil((int)(duration * 1.2), true, false);
|
this.WaitUntil(duration, true, false);
|
||||||
|
|
||||||
if (this.canceled)
|
if (this.canceled)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var referenceV = this.GetReferenceVolume();
|
var referenceFlowM3S = this.GetReferenceFlowM3S();
|
||||||
|
|
||||||
|
if (referenceFlowM3S == default(double))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
this.InvokeAsync((tasks, cancellationToken) =>
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
{
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
tasks.Add(meterVM.StopPPCalibrationAsync(pp, referenceV, cancellationToken));
|
// this.canceled = this.canceled || meterVM.IsRunning();
|
||||||
|
|
||||||
|
tasks.Add(meterVM.StopPPCalibrationAsync(pp, referenceFlowM3S, cancellationToken));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -391,37 +411,18 @@
|
|||||||
|
|
||||||
this.exchangeConnection.SendStopFlow();
|
this.exchangeConnection.SendStopFlow();
|
||||||
|
|
||||||
|
if (!this.canceled)
|
||||||
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
meterVM.GetCorrectionFactor();
|
meterVM.GetCorrectionFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (var meterVM in metersVM)
|
|
||||||
{
|
|
||||||
meterVM.SaveInspection(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var directory = Directory.CreateDirectory(".\\Results");
|
|
||||||
var file = Path.Combine(directory.FullName, $"Results_{DateTime.Now:yyyyMMddHHmmss}.csv");
|
|
||||||
|
|
||||||
File.WriteAllText(file, results.ToString());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.State = e.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.canceled)
|
|
||||||
{
|
|
||||||
this.InvokeAsync((tasks, cancellationToken) =>
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
{
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
tasks.Add(meterVM.FinishInspectionAsync(cancellationToken));
|
tasks.Add(meterVM.SetRegisterSettingsAsync(cancellationToken));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -458,7 +459,7 @@
|
|||||||
{
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
tasks.Add(meterVM.SetInputVolumeAsync(this.OmniDefaults, cancellationToken));
|
tasks.Add(meterVM.GetRegisterSettingsAsync(cancellationToken));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -472,7 +473,7 @@
|
|||||||
var rotations = pp.Rotations;
|
var rotations = pp.Rotations;
|
||||||
var duration = pp.Duration;
|
var duration = pp.Duration;
|
||||||
|
|
||||||
this.StartFlow(pp.VolumeM3H);
|
this.StartFlow(pp.RequiredFlowM3H);
|
||||||
|
|
||||||
if (this.canceled)
|
if (this.canceled)
|
||||||
{
|
{
|
||||||
@@ -494,20 +495,27 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.WaitUntil((int)(duration * 1.2), true, false);
|
this.WaitUntil(duration, true, false);
|
||||||
|
|
||||||
if (this.canceled)
|
if (this.canceled)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var referenceV = this.GetReferenceVolume();
|
var referenceFlowM3S = this.GetReferenceFlowM3S();
|
||||||
|
|
||||||
|
if (referenceFlowM3S == default(double))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.WaitUntil((int)(Math.Truncate(duration * 0.2) + 1), true, false);
|
||||||
|
|
||||||
this.InvokeAsync((tasks, cancellationToken) =>
|
this.InvokeAsync((tasks, cancellationToken) =>
|
||||||
{
|
{
|
||||||
foreach (var meterVM in metersVM)
|
foreach (var meterVM in metersVM)
|
||||||
{
|
{
|
||||||
tasks.Add(meterVM.StopPPCalibrationAsync(pp, referenceV, cancellationToken));
|
tasks.Add(meterVM.StopPPCalibrationAsync(pp, referenceFlowM3S, cancellationToken));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -534,7 +542,6 @@
|
|||||||
this.CanStart = true;
|
this.CanStart = true;
|
||||||
this.Error = default(string);
|
this.Error = default(string);
|
||||||
this.State = default(string);
|
this.State = default(string);
|
||||||
|
|
||||||
}, this.cancellationToken);
|
}, this.cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,16 +600,16 @@
|
|||||||
{
|
{
|
||||||
var received = false;
|
var received = false;
|
||||||
var volume = volumeM3H;
|
var volume = volumeM3H;
|
||||||
var timeout = 120; // seconds
|
var timeout = 500; // seconds
|
||||||
|
|
||||||
void referenceVolumeReceived(double value, string _)
|
void FlowStarted(double value, string _)
|
||||||
{
|
{
|
||||||
timeout = -1;
|
timeout = 0;
|
||||||
received = true;
|
received = true;
|
||||||
volume = value;
|
volume = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.exchangeConnection.StartFlow += referenceVolumeReceived;
|
this.exchangeConnection.StartFlow += FlowStarted;
|
||||||
|
|
||||||
this.exchangeConnection.SendStartFlow(volumeM3H);
|
this.exchangeConnection.SendStartFlow(volumeM3H);
|
||||||
|
|
||||||
@@ -624,6 +631,8 @@
|
|||||||
this.State = $"Warten auf Q({volumeM3H:0.0000}): {timeout} Sekunden verbleiben ...";
|
this.State = $"Warten auf Q({volumeM3H:0.0000}): {timeout} Sekunden verbleiben ...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.exchangeConnection.StartFlow -= FlowStarted;
|
||||||
|
|
||||||
if (!this.canceled)
|
if (!this.canceled)
|
||||||
{
|
{
|
||||||
this.State = $"Durchfluss {volume:0.0000} erreicht ...";
|
this.State = $"Durchfluss {volume:0.0000} erreicht ...";
|
||||||
@@ -634,16 +643,16 @@
|
|||||||
{
|
{
|
||||||
var received = false;
|
var received = false;
|
||||||
var reference = 0;
|
var reference = 0;
|
||||||
var timeout = 30; // seconds
|
var timeout = 60; // seconds
|
||||||
|
|
||||||
void referenceVolumeReceived(int seconds, string _)
|
void ReferenceMessurementStarted(int seconds, string _)
|
||||||
{
|
{
|
||||||
timeout = -1;
|
timeout = 0;
|
||||||
received = true;
|
received = true;
|
||||||
reference = seconds;
|
reference = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.exchangeConnection.StartReferenceMessurement += referenceVolumeReceived;
|
this.exchangeConnection.StartReferenceMessurement += ReferenceMessurementStarted;
|
||||||
|
|
||||||
this.exchangeConnection.SendStartReferenceMessurement(duration);
|
this.exchangeConnection.SendStartReferenceMessurement(duration);
|
||||||
|
|
||||||
@@ -665,26 +674,28 @@
|
|||||||
this.State = $"Warten bis RZ gestarted: {timeout} Sekunden verbleiben ...";
|
this.State = $"Warten bis RZ gestarted: {timeout} Sekunden verbleiben ...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.exchangeConnection.StartReferenceMessurement -= ReferenceMessurementStarted;
|
||||||
|
|
||||||
if (!this.canceled)
|
if (!this.canceled)
|
||||||
{
|
{
|
||||||
this.State = $"Referenzmessung gestartet ...";
|
this.State = $"Referenzmessung gestartet ...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double GetReferenceVolume()
|
private double GetReferenceFlowM3S()
|
||||||
{
|
{
|
||||||
var received = false;
|
var received = false;
|
||||||
var referenceV = 0D;
|
var referenceV = 0D;
|
||||||
var timeout = 30; // seconds
|
var timeout = 60; // seconds
|
||||||
|
|
||||||
void referenceVolumeReceived(double value, string _)
|
void ReferenceFlowM3SecReceived(double value, string _)
|
||||||
{
|
{
|
||||||
timeout = -1;
|
timeout = 0;
|
||||||
received = true;
|
received = true;
|
||||||
referenceV = value;
|
referenceV = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.exchangeConnection.StopReferenceMessurement += referenceVolumeReceived;
|
this.exchangeConnection.StopReferenceMessurement += ReferenceFlowM3SecReceived;
|
||||||
|
|
||||||
this.exchangeConnection.SendStopReferenceMessurement();
|
this.exchangeConnection.SendStopReferenceMessurement();
|
||||||
|
|
||||||
@@ -706,6 +717,8 @@
|
|||||||
this.State = $"Warten RZ-Ergebnis: {timeout} Sekunden verbleiben ...";
|
this.State = $"Warten RZ-Ergebnis: {timeout} Sekunden verbleiben ...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.exchangeConnection.StopReferenceMessurement -= ReferenceFlowM3SecReceived;
|
||||||
|
|
||||||
|
|
||||||
if (!this.canceled)
|
if (!this.canceled)
|
||||||
{
|
{
|
||||||
@@ -763,8 +776,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void LogError(string error)
|
private void LogError(string error)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
File.AppendAllText(this.errorLog, error);
|
File.AppendAllText(this.errorLog, error);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
public class ExchangeHubContentVM : ContentVM
|
public class ExchangeHubContentVM : ContentVM
|
||||||
{
|
{
|
||||||
private readonly ExchangeHubSettings hubsettings;
|
|
||||||
private readonly ExchangeConnection connection;
|
private readonly ExchangeConnection connection;
|
||||||
|
|
||||||
public ExchangeHubContentVM() : base()
|
public ExchangeHubContentVM() : base()
|
||||||
@@ -22,44 +21,12 @@
|
|||||||
this.Option.OptionSelected += this.NotifyOptionSelected;
|
this.Option.OptionSelected += this.NotifyOptionSelected;
|
||||||
this.Connect = new Command(this.ConnectHubHandler);
|
this.Connect = new Command(this.ConnectHubHandler);
|
||||||
this.Disconnect = new Command(this.DisconnectHubHandler);
|
this.Disconnect = new Command(this.DisconnectHubHandler);
|
||||||
this.hubsettings = new ExchangeHubSettings();
|
|
||||||
this.connection = new ExchangeConnection();
|
this.connection = new ExchangeConnection();
|
||||||
this.connection.StateChanged += Connection_StateChanged1;
|
this.connection.StateChanged += Connection_StateChanged1;
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.LogContent));
|
this.NotifyPropertyChanged(nameof(this.LogContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string URL
|
|
||||||
{
|
|
||||||
get => this.hubsettings.ExchangeHubURL;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.hubsettings.ExchangeHubURL = value;
|
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.URL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string OutputDir
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(this.hubsettings.ExchangeHubOutputDir))
|
|
||||||
{
|
|
||||||
this.hubsettings.ExchangeHubOutputDir = App.Path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.hubsettings.ExchangeHubOutputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.hubsettings.ExchangeHubOutputDir = value;
|
|
||||||
|
|
||||||
this.NotifyPropertyChanged(nameof(this.OutputDir));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool connected;
|
private bool connected;
|
||||||
public bool Connected
|
public bool Connected
|
||||||
{
|
{
|
||||||
@@ -85,7 +52,7 @@
|
|||||||
{
|
{
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
this.connection.Connect(this.URL);
|
this.connection.Connect(Appsettings.Current.ExchangeHubURL);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,17 +13,15 @@
|
|||||||
this.ContentSelected += this.SetContentSelected;
|
this.ContentSelected += this.SetContentSelected;
|
||||||
this.Options = new ObservableCollection<OptionVM>();
|
this.Options = new ObservableCollection<OptionVM>();
|
||||||
|
|
||||||
var exchangeHubVM = new ExchangeHubContentVM();
|
// var exchangeHubVM = new ExchangeHubContentVM();
|
||||||
exchangeHubVM.ContentSelected += this.SetContentSelected;
|
// exchangeHubVM.ContentSelected += this.SetContentSelected;
|
||||||
|
// this.Options.Add(exchangeHubVM.Option);
|
||||||
|
// this.Nodes.Add(exchangeHubVM);
|
||||||
|
|
||||||
var contentEOL = new EOLContentVM();
|
var contentEOL = new EOLContentVM();
|
||||||
contentEOL.ContentSelected += this.SetContentSelected;
|
contentEOL.ContentSelected += this.SetContentSelected;
|
||||||
|
|
||||||
this.Nodes.Add(exchangeHubVM);
|
|
||||||
this.Nodes.Add(contentEOL);
|
|
||||||
|
|
||||||
this.Options.Add(exchangeHubVM.Option);
|
|
||||||
this.Options.Add(contentEOL.Option);
|
this.Options.Add(contentEOL.Option);
|
||||||
|
this.Nodes.Add(contentEOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContentVM content;
|
private ContentVM content;
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
namespace OMNIPruefung.ViewModels.Features
|
namespace OMNIPruefung.ViewModels.Features
|
||||||
{
|
{
|
||||||
|
using OmniPlus;
|
||||||
using OmniPlus.Features;
|
using OmniPlus.Features;
|
||||||
using OmniPlus.Inspection;
|
using OmniPlus.Inspection;
|
||||||
|
using OMNIPruefung.Models;
|
||||||
using OMNIPruefung.ViewModels.Base;
|
using OMNIPruefung.ViewModels.Base;
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
public class OMNIPlusVM : VM<OMNIPlusVM>
|
public class OMNIPlusVM : VM<OMNIPlusVM>
|
||||||
{
|
{
|
||||||
public ObservableCollection<Result> Results { get; }
|
// TODO: save all in database
|
||||||
= new ObservableCollection<Result>();
|
private readonly OmniDatabase database;
|
||||||
|
|
||||||
|
public OMNIPlusVM()
|
||||||
|
{
|
||||||
|
this.database = new OmniDatabase(Appsettings.Current.OmniDB);
|
||||||
|
this.Results = new ObservableCollection<Result>();
|
||||||
|
}
|
||||||
|
|
||||||
public ushort IntPart { get; internal set; }
|
public ushort IntPart { get; internal set; }
|
||||||
|
|
||||||
@@ -21,25 +31,24 @@
|
|||||||
|
|
||||||
public sbyte FactoryCorrection { get; internal set; }
|
public sbyte FactoryCorrection { get; internal set; }
|
||||||
|
|
||||||
public string BuildInfo { get; internal set; }
|
public ObservableCollection<Result> Results { get; }
|
||||||
|
|
||||||
internal void AddResult(string key, string value)
|
internal void AddResult(string key, string value)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
this.Results.Add(new Result
|
this.Results.Add(new Result
|
||||||
{
|
{
|
||||||
Key = key,
|
Key = key,
|
||||||
Value = value
|
Value = value
|
||||||
});
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Add(SystemParameters response)
|
internal void Add(OmniPlus.Features.SystemParameters response)
|
||||||
{
|
{
|
||||||
this.AddResult("Reading System Parameters", $"{response.Status}");
|
|
||||||
|
|
||||||
if (response.Succeeded)
|
if (response.Succeeded)
|
||||||
{
|
{
|
||||||
this.BuildInfo = response.BuildInfo.Value;
|
|
||||||
|
|
||||||
this.AddResult(nameof(response.VersionAndType), response.VersionAndType.Value);
|
this.AddResult(nameof(response.VersionAndType), response.VersionAndType.Value);
|
||||||
this.AddResult(nameof(response.BuildInfo), response.BuildInfo.Value);
|
this.AddResult(nameof(response.BuildInfo), response.BuildInfo.Value);
|
||||||
this.AddResult(nameof(response.BatteryVoltage), $"{(response.BatteryVoltage.Volts + 0.0001) / 1000:0.0000 V}");
|
this.AddResult(nameof(response.BatteryVoltage), $"{(response.BatteryVoltage.Volts + 0.0001) / 1000:0.0000 V}");
|
||||||
@@ -52,29 +61,32 @@
|
|||||||
|
|
||||||
internal void Add(InputVolume response)
|
internal void Add(InputVolume response)
|
||||||
{
|
{
|
||||||
this.IntPart = response.IntPart;
|
|
||||||
this.Fraction = response.Fraction;
|
|
||||||
this.Size = response.Size;
|
this.Size = response.Size;
|
||||||
this.Range = response.Range;
|
this.Range = response.Range;
|
||||||
|
this.IntPart = response.IntPartFull;
|
||||||
|
this.Fraction = response.Fraction;
|
||||||
|
|
||||||
this.AddResult("Setting ml/r", $"{response.MlPerRotation:0.0000 ml/r}");
|
this.AddResult(nameof(response.Size), $"{response.Size}");
|
||||||
|
this.AddResult(nameof(response.Range), $"{response.Range}");
|
||||||
|
this.AddResult(nameof(response.Direction), $"{response.Direction}");
|
||||||
|
this.AddResult(nameof(response.IntPart), $"{response.IntPart}");
|
||||||
|
this.AddResult(nameof(response.Fraction), $"{response.Fraction}");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Add(OmniPlusTestPoint pp)
|
internal void Add(OmniPlusTestPoint pp)
|
||||||
{
|
{
|
||||||
|
this.AddResult("", $"");
|
||||||
this.AddResult("Test point:", $"{pp.Rotations}/{pp.Duration:0}");
|
this.AddResult("Test point:", $"{pp.Rotations}/{pp.Duration:0}");
|
||||||
this.AddResult("Volume", $"{pp.VolumeM3H:0.0000 m³/h}");
|
this.AddResult("Volume", $"{pp.RequiredFlowM3H:0.00000000 m³/h}");
|
||||||
this.AddResult("Duration", $"{pp.Duration:0 sec.}");
|
|
||||||
this.AddResult("ml/rotation", $"{pp.MlPerRotation:0.0000 ml/r}");
|
|
||||||
this.AddResult("Validation frame", $"{pp.MinDiff:0.00}% - {pp.MaxDiff:0.00}%");
|
this.AddResult("Validation frame", $"{pp.MinDiff:0.00}% - {pp.MaxDiff:0.00}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Add(OmniPlusTest test)
|
internal void Add(OmniPlusTest test)
|
||||||
{
|
{
|
||||||
this.AddResult("Result", $"{test.DifferencePercentage:0.00}%");
|
this.AddResult("Test result:", $"{test.Rotations:0}/{test.Duration:0.0000}");
|
||||||
this.AddResult("Meter volume", $"{test.MeterVolume:0.0000 m³}");
|
this.AddResult("Meter volume", $"{test.MeterFlowM3S:0.00000000 m³}");
|
||||||
this.AddResult("Reference volume", $"{test.VolumeMessured:0.0000 m³}");
|
this.AddResult("Reference volume", $"{test.ReferenceFlowM3S:0.00000000 m³}");
|
||||||
this.AddResult("Test result", $"{test.Rotations}/{test.Duration:0}");
|
this.AddResult("Deviation", $"{test.DifferencePercentage():0.00}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Add(ConfigurationParameters response)
|
internal void Add(ConfigurationParameters response)
|
||||||
@@ -93,8 +105,7 @@
|
|||||||
{
|
{
|
||||||
this.FactoryCorrection = (sbyte)(value * 10);
|
this.FactoryCorrection = (sbyte)(value * 10);
|
||||||
|
|
||||||
this.AddResult("Factory correction %", $"{value:0.00}%");
|
this.AddResult("Correction", $"{value:0.00} %");
|
||||||
this.AddResult("Factory correction", $"{this.FactoryCorrection:0}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,9 +58,9 @@
|
|||||||
<Label Grid.Column="3" Grid.Row="3" Content="min %" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
<Label Grid.Column="3" Grid.Row="3" Content="min %" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
||||||
<Label Grid.Column="4" Grid.Row="3" Content="max %" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" FontWeight="Bold" Margin="0" Padding="0, 5, 0, 0" />
|
<Label Grid.Column="4" Grid.Row="3" Content="max %" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" FontWeight="Bold" Margin="0" Padding="0, 5, 0, 0" />
|
||||||
|
|
||||||
<Label Grid.Column="2" Grid.Row="4" Content="{Binding OmniDefaults.TestPoints[0].VolumeM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
<Label Grid.Column="2" Grid.Row="4" Content="{Binding OmniDefaults.TestPoints[0].RequiredFlowM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
||||||
<Label Grid.Column="2" Grid.Row="5" Content="{Binding OmniDefaults.TestPoints[1].VolumeM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
<Label Grid.Column="2" Grid.Row="5" Content="{Binding OmniDefaults.TestPoints[1].RequiredFlowM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
||||||
<Label Grid.Column="2" Grid.Row="6" Content="{Binding OmniDefaults.TestPoints[2].VolumeM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
<Label Grid.Column="2" Grid.Row="6" Content="{Binding OmniDefaults.TestPoints[2].RequiredFlowM3H}" ContentStringFormat="{}{0:0.0000} m³/h" HorizontalContentAlignment="Right" FontWeight="Bold" Margin="0" Padding="0, 5, 21, 0"/>
|
||||||
|
|
||||||
<Label Grid.Column="3" Grid.Row="4" Content="{Binding OmniDefaults.TestPoints[0].MinDiff}" ContentStringFormat="{}{0:0.00} %" HorizontalContentAlignment="Right" Margin="0" Padding="0, 5, 21, 0" />
|
<Label Grid.Column="3" Grid.Row="4" Content="{Binding OmniDefaults.TestPoints[0].MinDiff}" ContentStringFormat="{}{0:0.00} %" HorizontalContentAlignment="Right" Margin="0" Padding="0, 5, 21, 0" />
|
||||||
<Label Grid.Column="3" Grid.Row="5" Content="{Binding OmniDefaults.TestPoints[1].MinDiff}" ContentStringFormat="{}{0:0.00} %" HorizontalContentAlignment="Right" Margin="0" Padding="0, 5, 21, 0" />
|
<Label Grid.Column="3" Grid.Row="5" Content="{Binding OmniDefaults.TestPoints[1].MinDiff}" ContentStringFormat="{}{0:0.00} %" HorizontalContentAlignment="Right" Margin="0" Padding="0, 5, 21, 0" />
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
internal class IrdaEncoder : SerialDataEncoder
|
|
||||||
{
|
|
||||||
public byte Device2PC { get; } = SerialDataExtensions.IRDA_REG2PC;
|
|
||||||
|
|
||||||
public override bool TryDecode(byte[] encoded, out byte[] decoded)
|
|
||||||
{
|
|
||||||
decoded = encoded.FromIrdaMessage();
|
|
||||||
|
|
||||||
return decoded.Length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool TryEncode(byte[] decoded, out byte[] encoded)
|
|
||||||
{
|
|
||||||
encoded = decoded.ToIrdaMessage();
|
|
||||||
|
|
||||||
return encoded.Length > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
internal class IrdaStream : SerialDataReader
|
|
||||||
{
|
|
||||||
private readonly IrdaEncoder encoder;
|
|
||||||
|
|
||||||
public IrdaStream(SerialPortSettings settings) : base(settings)
|
|
||||||
{
|
|
||||||
this.encoder = new IrdaEncoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WriteBytes(params byte[] bytes)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryEncode(bytes, out byte[] message))
|
|
||||||
{
|
|
||||||
base.WriteBytes(1, 1, 1, 1);
|
|
||||||
|
|
||||||
Thread.Sleep(1);
|
|
||||||
|
|
||||||
base.WriteBytes(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void BeginRead(byte[] bytes)
|
|
||||||
{
|
|
||||||
if (bytes is null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var start = Array.IndexOf(bytes, this.encoder.Device2PC);
|
|
||||||
|
|
||||||
if (start >= 0)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryDecode(bytes, out byte[] message))
|
|
||||||
{
|
|
||||||
this.EnqueueMessage(message);
|
|
||||||
this.RemoveRange(message.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.RemoveRange(bytes.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
namespace OmniPlus.Connections
|
||||||
|
{
|
||||||
|
internal sealed class OmniIrdaEncoder : SerialDataEncoder
|
||||||
|
{
|
||||||
|
public override bool TryDecode(byte[] data, out byte[] message, out int start, out int length)
|
||||||
|
{
|
||||||
|
message = default(byte[]);
|
||||||
|
|
||||||
|
if (data.FromIrdaMessage(out byte[] payload, out start, out length))
|
||||||
|
{
|
||||||
|
if (payload.FromUI1236Message(out message, out start, out length))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryEncode(byte[] data, out byte[] message)
|
||||||
|
{
|
||||||
|
message = data
|
||||||
|
.ToUI1236Message()
|
||||||
|
.ToIrdaMessage();
|
||||||
|
|
||||||
|
return message != null && message.Length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
namespace OmniPlus.Connections
|
||||||
|
{
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
internal sealed class OmniIrdaStream : SerialDataStream
|
||||||
|
{
|
||||||
|
private readonly ManualResetEventSlim waitHandle;
|
||||||
|
|
||||||
|
public OmniIrdaStream(SerialDataEncoder encoder, SerialPortSettings settings) : base(encoder, settings)
|
||||||
|
{
|
||||||
|
this.waitHandle = new ManualResetEventSlim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] Send(params byte[] message)
|
||||||
|
{
|
||||||
|
var response = new byte[0];
|
||||||
|
|
||||||
|
void DataReceived(byte[] data)
|
||||||
|
{
|
||||||
|
response = data;
|
||||||
|
|
||||||
|
this.waitHandle.Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DataReceived += DataReceived;
|
||||||
|
|
||||||
|
this.StartListening();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
if (response != null && response.Length > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.WritePlain(1, 1, 1, 1);
|
||||||
|
|
||||||
|
this.waitHandle.Wait(1);
|
||||||
|
this.waitHandle.Reset();
|
||||||
|
|
||||||
|
this.WriteEncoded(message);
|
||||||
|
|
||||||
|
this.waitHandle.Wait(3000);
|
||||||
|
this.waitHandle.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.StopListening();
|
||||||
|
|
||||||
|
this.DataReceived -= DataReceived;
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace OmniPlus.Connections
|
||||||
|
{
|
||||||
|
internal class OmniUniProEncoder : SerialDataEncoder
|
||||||
|
{
|
||||||
|
public override bool TryDecode(byte[] data, out byte[] message, out int start, out int length)
|
||||||
|
{
|
||||||
|
return data.FromUniProMessage(out message, out start, out length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryEncode(byte[] data, out byte[] message)
|
||||||
|
{
|
||||||
|
message = new byte[0];
|
||||||
|
|
||||||
|
if (data != null && data.Length > 0)
|
||||||
|
{
|
||||||
|
message = data.ToUniProMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return message != null && message.Length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
namespace OmniPlus.Connections
|
||||||
|
{
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
internal class OmniUniProStream : SerialDataStream
|
||||||
|
{
|
||||||
|
private readonly ManualResetEventSlim waitHandle;
|
||||||
|
|
||||||
|
public OmniUniProStream(SerialDataEncoder encoder, SerialPortSettings settings) : base(encoder, settings)
|
||||||
|
{
|
||||||
|
this.waitHandle = new ManualResetEventSlim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] Send(params byte[] message)
|
||||||
|
{
|
||||||
|
var response = new byte[0];
|
||||||
|
|
||||||
|
void DataReceived(byte[] data)
|
||||||
|
{
|
||||||
|
response = data;
|
||||||
|
|
||||||
|
this.waitHandle.Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DataReceived += DataReceived;
|
||||||
|
|
||||||
|
this.StartListening();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
if (response != null && response.Length > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.WriteEncoded(message);
|
||||||
|
|
||||||
|
this.waitHandle.Wait(3000);
|
||||||
|
this.waitHandle.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.StopListening();
|
||||||
|
|
||||||
|
this.DataReceived -= DataReceived;
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.IO.Ports;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
var number = "81623241198";
|
|
||||||
var last = number.Length - 1;
|
|
||||||
var line = string.Empty;
|
|
||||||
|
|
||||||
while (!string.IsNullOrEmpty(line = Console.ReadLine()))
|
|
||||||
{
|
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
var next = number + line[0];
|
|
||||||
var request = new byte[] { };
|
|
||||||
var response = new byte[] { };
|
|
||||||
var settings = new SerialPortSettings
|
|
||||||
{
|
|
||||||
BaudRate = 115200,
|
|
||||||
DataBits = 8,
|
|
||||||
Parity = Parity.None,
|
|
||||||
PortName = "COM1",
|
|
||||||
StopBits = StopBits.One,
|
|
||||||
};
|
|
||||||
var foreground = Console.ForegroundColor;
|
|
||||||
|
|
||||||
using (var stream = new UI1236Stream(settings))
|
|
||||||
{
|
|
||||||
stream.Open();
|
|
||||||
|
|
||||||
request = new byte[] { 0x05 };
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[] { 0x01 };
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[14];
|
|
||||||
request[0] = 0x02;
|
|
||||||
Encoding.ASCII.GetBytes(next).CopyTo(request, 1);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[] { 0x01 };
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[] { 0x03 };
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[22];
|
|
||||||
request[0] = 0x04;
|
|
||||||
Encoding.ASCII.GetBytes($"SEN{next}").CopyTo(request, 1);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
request = new byte[] { 0x03 };
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
|
||||||
Console.WriteLine($">>> {BitConverter.ToString(request)}");
|
|
||||||
response = stream.Write(request);
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGreen;
|
|
||||||
Console.WriteLine($"<<< {BitConverter.ToString(response)}");
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
|
||||||
Console.WriteLine($"... {Encoding.ASCII.GetString(response).Trim('\0', '\r', '\n')}");
|
|
||||||
|
|
||||||
Console.ForegroundColor = foreground;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
{
|
{
|
||||||
internal abstract class SerialDataEncoder
|
internal abstract class SerialDataEncoder
|
||||||
{
|
{
|
||||||
public abstract bool TryDecode(byte[] encoded, out byte[] decoded);
|
public abstract bool TryEncode(byte[] data, out byte[] message);
|
||||||
|
|
||||||
public abstract bool TryEncode(byte[] decoded, out byte[] encoded);
|
public abstract bool TryDecode(byte[] data, out byte[] message, out int start, out int length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
internal static class SerialDataExtensions
|
public static class SerialDataExtensions
|
||||||
{
|
{
|
||||||
public const int BYTE_BITS = 8;
|
public const int BYTE_BITS = 8;
|
||||||
|
|
||||||
@@ -18,13 +18,17 @@
|
|||||||
public const byte UNIPRO_MIN_LENGTH = 4;
|
public const byte UNIPRO_MIN_LENGTH = 4;
|
||||||
|
|
||||||
public const byte UI1236_START = 0x0D;
|
public const byte UI1236_START = 0x0D;
|
||||||
|
public const byte UI1236_LEN_INDEX = 1;
|
||||||
|
public const byte UI1236_DATA_INDEX = 3;
|
||||||
public const byte UI1236_MIN_LENGTH = 5;
|
public const byte UI1236_MIN_LENGTH = 5;
|
||||||
public const byte UI1236_HED_LENGTH = 3;
|
public const byte UI1236_HEAD_LENGTH = 3;
|
||||||
|
|
||||||
public const byte IRDA_START = 0x9B;
|
public const byte IRDA_START = 0x9B;
|
||||||
public const byte IRDA_PING = 0x82;
|
public const byte IRDA_PING = 0x82;
|
||||||
public const byte IRDA_PC2REG = 0x33;
|
public const byte IRDA_PC2REG = 0x33;
|
||||||
public const byte IRDA_REG2PC = 0x43;
|
public const byte IRDA_REG2PC = 0x43;
|
||||||
|
public const byte IRDA_LEN_INDEX = 2;
|
||||||
|
public const byte IRDA_DATA_INDEX = 3;
|
||||||
public const byte IRDA_MIN_LENGTH = 5;
|
public const byte IRDA_MIN_LENGTH = 5;
|
||||||
public const byte IRDA_CRC_LENGTH = 2;
|
public const byte IRDA_CRC_LENGTH = 2;
|
||||||
|
|
||||||
@@ -39,14 +43,27 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] ToUI1236Message(this byte[] bytes)
|
public static byte[] ToUI1236Message(this byte[] bytes)
|
||||||
{
|
{
|
||||||
|
var message = new byte[0];
|
||||||
|
|
||||||
|
if (bytes is null)
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
var bytesLength = bytes.Length;
|
var bytesLength = bytes.Length;
|
||||||
var payloadLength = bytes.Length + UI1236_MIN_LENGTH;
|
|
||||||
payloadLength += payloadLength % OxO2;
|
if (bytesLength == 0)
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
var messageLength = bytes.Length + UI1236_MIN_LENGTH;
|
||||||
|
messageLength += messageLength % OxO2;
|
||||||
|
|
||||||
var index = OxOO;
|
var index = OxOO;
|
||||||
var message = new byte[payloadLength];
|
message = new byte[messageLength];
|
||||||
message[index++] = UI1236_START;
|
message[index++] = UI1236_START;
|
||||||
message[index++] = (byte)(bytesLength + UI1236_HED_LENGTH);
|
message[index++] = (byte)(bytesLength + UI1236_HEAD_LENGTH);
|
||||||
|
|
||||||
UI1236Control control = OxOO;
|
UI1236Control control = OxOO;
|
||||||
control.ReturnResponse = true;
|
control.ReturnResponse = true;
|
||||||
@@ -55,45 +72,13 @@
|
|||||||
bytes.CopyTo(message, index);
|
bytes.CopyTo(message, index);
|
||||||
|
|
||||||
var checksum = message.CalculateCheckSUM(message.Length - OxO2);
|
var checksum = message.CalculateCheckSUM(message.Length - OxO2);
|
||||||
var checksumIndex = bytesLength + UI1236_HED_LENGTH;
|
var checksumIndex = bytesLength + UI1236_HEAD_LENGTH;
|
||||||
message[checksumIndex++] = checksum[OxO1];
|
message[checksumIndex++] = checksum[OxO1];
|
||||||
message[checksumIndex++] = checksum[OxOO];
|
message[checksumIndex++] = checksum[OxOO];
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>UI1236 structure:</para>
|
|
||||||
/// <para> 0. 0x0D - Start byte</para>
|
|
||||||
/// <para> 1. .... - Length: max. 254</para>
|
|
||||||
/// <para> 2. .... - Control byte</para>
|
|
||||||
/// <para>3+n. .... - Payload</para>
|
|
||||||
/// <para>n-2. .... - Checksum 0 </para>
|
|
||||||
/// <para>n-1. .... - Checksum 1 </para>
|
|
||||||
/// </summary>
|
|
||||||
public static byte[] FromUI1236Message(this byte[] bytes)
|
|
||||||
{
|
|
||||||
var payload = new byte[OxOO];
|
|
||||||
|
|
||||||
if (bytes is null)
|
|
||||||
{
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
var payloadLength = bytes.Length - UI1236_MIN_LENGTH;
|
|
||||||
|
|
||||||
if (payloadLength <= OxOO)
|
|
||||||
{
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
payload = new byte[payloadLength];
|
|
||||||
|
|
||||||
Buffer.BlockCopy(bytes, OxO3, payload, OxOO, payloadLength);
|
|
||||||
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>UniPro structure:</para>
|
/// <para>UniPro structure:</para>
|
||||||
/// <para> 0. .... - Start byte</para>
|
/// <para> 0. .... - Start byte</para>
|
||||||
@@ -126,27 +111,56 @@
|
|||||||
/// <para> .. .... - Payload</para>
|
/// <para> .. .... - Payload</para>
|
||||||
/// <para>n-1. .... - Stop byte</para>
|
/// <para>n-1. .... - Stop byte</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] FromUniProMessage(this byte[] bytes)
|
public static bool FromUniProMessage(this byte[] bytes, out byte[] message, out int start, out int length)
|
||||||
{
|
{
|
||||||
var payload = new byte[OxOO];
|
message = default(byte[]);
|
||||||
|
length = default(int);
|
||||||
|
start = default(int);
|
||||||
|
|
||||||
if (bytes is null)
|
if (bytes is null)
|
||||||
{
|
{
|
||||||
return payload;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var payloadLength = bytes.Length - UNIPRO_MIN_LENGTH;
|
var bytesLength = bytes.Length;
|
||||||
|
|
||||||
if (payloadLength <= OxOO)
|
while (start < bytesLength)
|
||||||
{
|
{
|
||||||
return payload;
|
start = Array.IndexOf(bytes, UNIPRO_REG2PC) - 1;
|
||||||
|
|
||||||
|
if (start < 0 || bytes[start] == UNIPRO_START)
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
payload = new byte[payloadLength];
|
start += 2;
|
||||||
|
}
|
||||||
|
|
||||||
Buffer.BlockCopy(bytes, OxO3, payload, OxOO, payloadLength);
|
if (start < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return payload;
|
start += 2;
|
||||||
|
|
||||||
|
if (start >= bytesLength)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = bytes[start] - UNIPRO_MIN_LENGTH;
|
||||||
|
|
||||||
|
if (start + length >= bytesLength)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
start += 1;
|
||||||
|
message = new byte[length];
|
||||||
|
|
||||||
|
Buffer.BlockCopy(bytes, start, message, 0, length);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -161,21 +175,35 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] ToIrdaMessage(this byte[] bytes)
|
public static byte[] ToIrdaMessage(this byte[] bytes)
|
||||||
{
|
{
|
||||||
var payloadLength = bytes.Length;
|
var message = new byte[0];
|
||||||
payloadLength += payloadLength % OxO2;
|
|
||||||
|
if (bytes is null)
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytesLength = bytes.Length;
|
||||||
|
|
||||||
|
if (bytesLength == 0)
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
var messageLength = bytesLength;
|
||||||
|
messageLength += messageLength % OxO2;
|
||||||
|
|
||||||
var index = OxOO;
|
var index = OxOO;
|
||||||
var message = new byte[payloadLength + IRDA_MIN_LENGTH];
|
message = new byte[messageLength + IRDA_MIN_LENGTH];
|
||||||
message[index++] = IRDA_START;
|
message[index++] = IRDA_START;
|
||||||
message[index++] = IRDA_PC2REG;
|
message[index++] = IRDA_PC2REG;
|
||||||
message[index++] = (byte)(payloadLength / OxO2);
|
message[index++] = (byte)(messageLength / OxO2);
|
||||||
|
|
||||||
bytes.CopyTo(message, index);
|
bytes.CopyTo(message, index);
|
||||||
|
|
||||||
var messageLength = message.Length;
|
var _length = message.Length;
|
||||||
var crc16 = message.CalculateCRC8408(1, messageLength - IRDA_CRC_LENGTH);
|
var crc16 = message.CalculateCRC8408(1, _length - IRDA_CRC_LENGTH);
|
||||||
message[messageLength - OxO2] = crc16[OxOO];
|
message[_length - OxO2] = crc16[OxOO];
|
||||||
message[messageLength - OxO1] = crc16[OxO1];
|
message[_length - OxO1] = crc16[OxO1];
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@@ -190,106 +218,111 @@
|
|||||||
/// <para>n-2. .... - CRC16 0 </para>
|
/// <para>n-2. .... - CRC16 0 </para>
|
||||||
/// <para>n-1. .... - CRC16 1 </para>
|
/// <para>n-1. .... - CRC16 1 </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] FromIrdaMessage(this byte[] bytes)
|
public static bool FromIrdaMessage(this byte[] bytes, out byte[] message, out int start, out int length)
|
||||||
{
|
{
|
||||||
var payload = new byte[OxOO];
|
message = default(byte[]);
|
||||||
|
length = default(int);
|
||||||
|
start = default(int);
|
||||||
|
|
||||||
if (bytes is null)
|
if (bytes is null)
|
||||||
{
|
{
|
||||||
return payload;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var payloadLength = bytes.Length - IRDA_MIN_LENGTH;
|
var bytesLength = bytes.Length;
|
||||||
|
|
||||||
if (payloadLength <= OxOO)
|
while (start < bytesLength)
|
||||||
{
|
{
|
||||||
return payload;
|
start = Array.IndexOf(bytes, IRDA_REG2PC, start) - 1;
|
||||||
|
|
||||||
|
if (start < 0 || bytes[start] == IRDA_START)
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
payload = new byte[payloadLength];
|
start += 2;
|
||||||
|
}
|
||||||
|
|
||||||
Buffer.BlockCopy(bytes, OxO3, payload, OxOO, payloadLength);
|
if (start < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return payload;
|
start += 2;
|
||||||
|
|
||||||
|
if (start >= bytesLength)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = bytes[start] * 2;
|
||||||
|
|
||||||
|
if (start + length >= bytesLength)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
start += 1;
|
||||||
|
message = new byte[length];
|
||||||
|
|
||||||
|
Buffer.BlockCopy(bytes, start, message, 0, length);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Irda structure:</para>
|
/// <para>UI1236 structure:</para>
|
||||||
/// <para> 0. .... - Start byte</para>
|
/// <para> 0. 0x0D - Start byte</para>
|
||||||
/// <para> 1. .... - Direction</para>
|
/// <para> 1. .... - Length: max. 254</para>
|
||||||
/// <para> 2. .... - Length / 2</para>
|
/// <para> 2. .... - Control byte</para>
|
||||||
/// <para>3+n. .... - Payload</para>
|
/// <para>3+n. .... - Payload</para>
|
||||||
/// <para>n-3. .... - aligned byte</para>
|
/// <para>n-2. .... - Checksum 0 </para>
|
||||||
/// <para>n-2. .... - CRC16 0 </para>
|
/// <para>n-1. .... - Checksum 1 </para>
|
||||||
/// <para>n-1. .... - CRC16 1 </para>
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] FromIrdaMessage(this byte[] bytes, int start, out int length)
|
public static bool FromUI1236Message(this byte[] bytes, out byte[] message, out int start, out Int32 length)
|
||||||
{
|
{
|
||||||
length = OxOO;
|
message = default(byte[]);
|
||||||
|
length = default(int);
|
||||||
var payload = new byte[length];
|
start = default(int);
|
||||||
|
|
||||||
if (bytes is null)
|
if (bytes is null)
|
||||||
{
|
{
|
||||||
return payload;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bytesLength = bytes.Length;
|
start = Array.IndexOf(bytes, UI1236_START);
|
||||||
var payloadLengthIndex = start + 2;
|
|
||||||
|
|
||||||
if (bytesLength <= payloadLengthIndex)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
return payload;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var payloadLength = bytes[payloadLengthIndex] * 2;
|
start += 1;
|
||||||
length = payloadLength + IRDA_MIN_LENGTH;
|
|
||||||
|
|
||||||
if (payloadLength <= OxOO)
|
if (start >= bytes.Length)
|
||||||
{
|
{
|
||||||
return payload;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
payload = new byte[payloadLength];
|
length = bytes[start] - UI1236_HEAD_LENGTH;
|
||||||
var payloadStart = payloadLengthIndex + 1;
|
|
||||||
|
|
||||||
Buffer.BlockCopy(bytes, payloadStart, payload, 0, payloadLength);
|
if (length <= 0)
|
||||||
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>Irda structure:</para>
|
|
||||||
/// <para> 0. .... - Start byte</para>
|
|
||||||
/// <para> 1. .... - Direction</para>
|
|
||||||
/// <para> 2. .... - Length / 2</para>
|
|
||||||
/// <para>3+n. .... - Payload</para>
|
|
||||||
/// <para>n-3. .... - aligned byte</para>
|
|
||||||
/// <para>n-2. .... - CRC16 0 </para>
|
|
||||||
/// <para>n-1. .... - CRC16 1 </para>
|
|
||||||
/// </summary>
|
|
||||||
public static byte[] FromIrdaMessage(this byte[] bytes, int start)
|
|
||||||
{
|
{
|
||||||
var bytesLength = bytes.Length;
|
return false;
|
||||||
|
|
||||||
if (bytes is null || bytesLength <= start)
|
|
||||||
{
|
|
||||||
return new byte[] { };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _length = bytes[start + 2] * 2;
|
start += 2;
|
||||||
var _start = start + 3;
|
|
||||||
|
|
||||||
if (_start + _length >= bytesLength)
|
if (start + length >= bytes.Length)
|
||||||
{
|
{
|
||||||
return new byte[] { };
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = new byte[_length];
|
message = new byte[length];
|
||||||
|
|
||||||
Buffer.BlockCopy(bytes, _start, data, 0, _length);
|
Buffer.BlockCopy(bytes, start, message, 0, length);
|
||||||
|
|
||||||
return data;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] CalculateCRC8408(this byte[] message, int start, int length)
|
public static byte[] CalculateCRC8408(this byte[] message, int start, int length)
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
internal abstract class SerialDataReader : SerialDataStream
|
|
||||||
{
|
|
||||||
protected bool read;
|
|
||||||
private Thread thread;
|
|
||||||
private List<byte> stream;
|
|
||||||
private Queue<byte[]> messages;
|
|
||||||
protected ManualResetEventSlim awaiter;
|
|
||||||
|
|
||||||
protected SerialDataReader(SerialPortSettings settings) : base(settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsAlive
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (this.thread is null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.thread.IsAlive;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.messages = null;
|
|
||||||
this.stream = null;
|
|
||||||
|
|
||||||
this.thread?.Abort();
|
|
||||||
this.thread = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged(e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void BeginRead(byte[] bytes)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void ClearMessages()
|
|
||||||
{
|
|
||||||
if (this.messages != null)
|
|
||||||
{
|
|
||||||
this.messages.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] DequeueMessage()
|
|
||||||
{
|
|
||||||
if (this.messages != null && this.messages.Count > 0)
|
|
||||||
{
|
|
||||||
return this.messages.Dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void EnqueueMessage(byte[] message)
|
|
||||||
{
|
|
||||||
if (this.messages != null)
|
|
||||||
{
|
|
||||||
this.messages.Enqueue(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void RemoveRange(int length)
|
|
||||||
{
|
|
||||||
if (this.stream != null)
|
|
||||||
{
|
|
||||||
this.stream.RemoveRange(0, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void StartListening()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!this.IsOpen)
|
|
||||||
{
|
|
||||||
base.Open();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.IsAlive)
|
|
||||||
{
|
|
||||||
this.stream = new List<byte>();
|
|
||||||
this.messages = new Queue<byte[]>();
|
|
||||||
this.thread = new Thread(this.BeginRead);
|
|
||||||
this.thread.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.awaiter?.IsSet == true)
|
|
||||||
{
|
|
||||||
this.awaiter.Set();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.awaiter = new ManualResetEventSlim();
|
|
||||||
this.read = true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void StopListening()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.stream.Clear();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.messages.Clear();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.read = false;
|
|
||||||
this.awaiter.Set();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BeginRead()
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged($"{nameof(IrdaStream)} - reading thread started.");
|
|
||||||
|
|
||||||
while (this.IsAlive)
|
|
||||||
{
|
|
||||||
if (!this.read)
|
|
||||||
{
|
|
||||||
this.awaiter.Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
var bytes = this.ReadBytes();
|
|
||||||
|
|
||||||
if (bytes.Length > 0)
|
|
||||||
{
|
|
||||||
this.stream.AddRange(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.BeginRead(this.stream?.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.NotifyStateChanged($"{nameof(IrdaStream)} - reading thread stoped.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +1,36 @@
|
|||||||
namespace OmniPlus.Connections
|
namespace OmniPlus.Connections
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
internal class SerialDataStream : SerialPortStream
|
internal abstract class SerialDataStream : SerialPortStream
|
||||||
{
|
{
|
||||||
public SerialDataStream(SerialPortSettings settings) : base(settings)
|
private readonly ManualResetEventSlim waitHandle;
|
||||||
|
private readonly SerialDataEncoder encoder;
|
||||||
|
private readonly List<byte> buffer;
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationTokenSource;
|
||||||
|
private CancellationToken cancellationToken;
|
||||||
|
private Task readingTask;
|
||||||
|
|
||||||
|
protected SerialDataStream(SerialDataEncoder encoder, SerialPortSettings settings) : base(settings)
|
||||||
{
|
{
|
||||||
|
this.encoder = encoder;
|
||||||
|
this.buffer = new List<byte>();
|
||||||
|
this.waitHandle = new ManualResetEventSlim();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual byte[] ReadBytes()
|
protected event Action<byte[]> DataReceived;
|
||||||
{
|
|
||||||
var bytes = new byte[0];
|
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this.IsOpen)
|
if (this.cancellationTokenSource != null)
|
||||||
{
|
{
|
||||||
var length = this.serialPort.BytesToRead;
|
this.cancellationTokenSource.Cancel();
|
||||||
|
|
||||||
if (length > 1)
|
|
||||||
{
|
|
||||||
bytes = new byte[length];
|
|
||||||
|
|
||||||
this.serialPort.Read(bytes, 0, length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -31,26 +38,160 @@
|
|||||||
this.NotifyStateChanged(e);
|
this.NotifyStateChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
base.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void WriteBytes(params byte[] bytes)
|
public override void Open()
|
||||||
|
{
|
||||||
|
base.Open();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.StartReading();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void StartListening()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this.IsOpen)
|
this.buffer.Clear();
|
||||||
|
this.waitHandle.Set();
|
||||||
|
this.NotifyStateChanged($"--- start listening");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void StopListening()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.waitHandle.Reset();
|
||||||
|
this.buffer.Clear();
|
||||||
|
this.NotifyStateChanged($"--- stop listening");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void WriteEncoded(params byte[] bytes)
|
||||||
|
{
|
||||||
|
this.EnsureOpened();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (this.encoder.TryEncode(bytes, out byte[] message))
|
||||||
|
{
|
||||||
|
this.Write(message, 0, message.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.NotifyStateChanged($">>> {BitConverter.ToString(bytes)}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void WritePlain(params byte[] bytes)
|
||||||
|
{
|
||||||
|
this.EnsureOpened();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.Write(bytes, 0, bytes.Length);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnsureOpened()
|
||||||
|
{
|
||||||
|
if (this.serialPort is null)
|
||||||
|
{
|
||||||
|
this.Open();
|
||||||
|
}
|
||||||
|
else if (!this.serialPort.IsOpen)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
this.Open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReadingTaskHandler()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
this.waitHandle.Wait();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var size = this.serialPort.BytesToRead;
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
var buffer = new byte[size];
|
||||||
|
|
||||||
|
this.serialPort.Read(buffer, 0, size);
|
||||||
|
this.buffer.AddRange(buffer);
|
||||||
|
|
||||||
|
var data = this.buffer.ToArray();
|
||||||
|
|
||||||
|
if (this.encoder.TryDecode(data, out byte[] message, out int start, out int _))
|
||||||
|
{
|
||||||
|
this.DataReceived?.Invoke(message);
|
||||||
|
|
||||||
|
this.NotifyStateChanged($"<<< {BitConverter.ToString(message)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start < 0)
|
||||||
|
{
|
||||||
|
this.buffer.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartReading()
|
||||||
|
{
|
||||||
|
this.cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
this.cancellationToken = this.cancellationTokenSource.Token;
|
||||||
|
this.readingTask = Task.Factory
|
||||||
|
.StartNew(this.ReadingTaskHandler, this.cancellationToken);
|
||||||
|
this.readingTask.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.Exception != null)
|
||||||
|
{
|
||||||
|
this.NotifyStateChanged(task.Exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.StartReading();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Write(byte[] bytes, int start, int length)
|
||||||
{
|
{
|
||||||
var _lock = new object();
|
var _lock = new object();
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
this.serialPort.Write(bytes, 0, bytes.Length);
|
this.serialPort.Write(bytes, 0, length);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.NotifyStateChanged(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
|
|
||||||
internal abstract class SerialPortStream : IDisposable
|
public delegate void StateChanged(object state);
|
||||||
|
|
||||||
|
internal abstract class SerialPortStream
|
||||||
{
|
{
|
||||||
protected SerialPort serialPort;
|
protected SerialPort serialPort;
|
||||||
|
|
||||||
@@ -11,27 +13,17 @@
|
|||||||
|
|
||||||
protected SerialPortStream(SerialPortSettings settings)
|
protected SerialPortStream(SerialPortSettings settings)
|
||||||
{
|
{
|
||||||
|
if (settings is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException($"{nameof(SerialPortSettings)} are required.");
|
||||||
|
}
|
||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action Connected;
|
public event StateChanged StateChanged;
|
||||||
public event Action Disconnected;
|
|
||||||
public event Action<object> StateChanged;
|
|
||||||
|
|
||||||
public bool IsOpen
|
public virtual void Close()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (this.serialPort is null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.serialPort.IsOpen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Dispose()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -41,8 +33,7 @@
|
|||||||
this.serialPort.Dispose();
|
this.serialPort.Dispose();
|
||||||
this.serialPort = null;
|
this.serialPort = null;
|
||||||
|
|
||||||
this.NotifyStateChanged($"{this} - disposed.");
|
this.NotifyStateChanged($"--- {this} - disconnected.");
|
||||||
this.Disconnected?.Invoke();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -53,11 +44,6 @@
|
|||||||
|
|
||||||
public virtual void Open()
|
public virtual void Open()
|
||||||
{
|
{
|
||||||
if (this.serialPort != null)
|
|
||||||
{
|
|
||||||
this.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.serialPort = new SerialPort
|
this.serialPort = new SerialPort
|
||||||
@@ -67,15 +53,12 @@
|
|||||||
Parity = this.settings.Parity,
|
Parity = this.settings.Parity,
|
||||||
PortName = this.settings.PortName,
|
PortName = this.settings.PortName,
|
||||||
StopBits = this.settings.StopBits,
|
StopBits = this.settings.StopBits,
|
||||||
|
DtrEnable = true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.serialPort.Open();
|
this.serialPort.Open();
|
||||||
|
|
||||||
if (this.IsOpen)
|
this.NotifyStateChanged($"--- {this} - connected.");
|
||||||
{
|
|
||||||
this.NotifyStateChanged($"{this} - connected.");
|
|
||||||
this.Connected?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -103,6 +86,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract byte[] Send(params byte[] message);
|
||||||
|
|
||||||
protected void NotifyStateChanged(object state)
|
protected void NotifyStateChanged(object state)
|
||||||
{
|
{
|
||||||
this.StateChanged?.Invoke(state);
|
this.StateChanged?.Invoke(state);
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
internal class UI1236Encoder : SerialDataEncoder
|
|
||||||
{
|
|
||||||
public override bool TryDecode(byte[] encoded, out byte[] decoded)
|
|
||||||
{
|
|
||||||
decoded = encoded.FromUI1236Message();
|
|
||||||
|
|
||||||
return decoded.Length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool TryEncode(byte[] decoded, out byte[] encoded)
|
|
||||||
{
|
|
||||||
encoded = decoded.ToUI1236Message();
|
|
||||||
|
|
||||||
return encoded.Length > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
internal class UI1236Stream : IrdaStream
|
|
||||||
{
|
|
||||||
private readonly string fileName;
|
|
||||||
private readonly UI1236Encoder encoder;
|
|
||||||
|
|
||||||
public UI1236Stream(SerialPortSettings settings) : base(settings)
|
|
||||||
{
|
|
||||||
var directiry = Directory.CreateDirectory(".\\UI1236");
|
|
||||||
this.fileName = Path.Combine(directiry.FullName, $"[{settings.PortName}].txt");
|
|
||||||
this.encoder = new UI1236Encoder();
|
|
||||||
|
|
||||||
File.AppendAllText(Path.Combine(directiry.FullName, $"[{settings.PortName}].txt"), string.Empty);
|
|
||||||
|
|
||||||
this.StateChanged += this.UI1236Stream_StateChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] Write(params byte[] bytes)
|
|
||||||
{
|
|
||||||
this.LogToFile($">>> {BitConverter.ToString(bytes)}");
|
|
||||||
this.StartListening();
|
|
||||||
|
|
||||||
Thread.Sleep(500);
|
|
||||||
|
|
||||||
this.WriteBytes(bytes);
|
|
||||||
|
|
||||||
var response = new byte[0];
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
var message = this.DequeueMessage();
|
|
||||||
|
|
||||||
if (message != null)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryDecode(message, out response))
|
|
||||||
{
|
|
||||||
this.ClearMessages();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.Length > 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.LogToFile($"<<< {BitConverter.ToString(response)}");
|
|
||||||
|
|
||||||
Thread.Sleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.StopListening();
|
|
||||||
|
|
||||||
this.LogToFile($"<<< {BitConverter.ToString(response)}");
|
|
||||||
this.LogToFile(string.Empty);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WriteBytes(params byte[] bytes)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryEncode(bytes, out byte[] message))
|
|
||||||
{
|
|
||||||
base.WriteBytes(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogToFile(string value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.AppendAllText(this.fileName, $"{value}{Environment.NewLine}");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UI1236Stream_StateChanged(object state)
|
|
||||||
{
|
|
||||||
this.LogToFile($"{state}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
internal class UniProEncoder : SerialDataEncoder
|
|
||||||
{
|
|
||||||
public object Device2PC { get; } = SerialDataExtensions.UNIPRO_REG2PC;
|
|
||||||
|
|
||||||
public override bool TryDecode(byte[] encoded, out byte[] decoded)
|
|
||||||
{
|
|
||||||
decoded = encoded.FromUniProMessage();
|
|
||||||
|
|
||||||
return decoded.Length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool TryEncode(byte[] decoded, out byte[] encoded)
|
|
||||||
{
|
|
||||||
encoded = decoded.FromUniProMessage();
|
|
||||||
|
|
||||||
return encoded.Length > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
namespace OmniPlus.Connections
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
internal class UniProStream : SerialDataReader
|
|
||||||
{
|
|
||||||
private readonly UniProEncoder encoder;
|
|
||||||
|
|
||||||
public UniProStream(SerialPortSettings settings) : base(settings)
|
|
||||||
{
|
|
||||||
this.encoder = new UniProEncoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] Write(params byte[] bytes)
|
|
||||||
{
|
|
||||||
this.StartListening();
|
|
||||||
this.WriteBytes(bytes);
|
|
||||||
|
|
||||||
var response = new byte[0];
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
var message = this.DequeueMessage();
|
|
||||||
|
|
||||||
if (message != null)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryDecode(message, out response))
|
|
||||||
{
|
|
||||||
this.ClearMessages();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.Length > 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.StopListening();
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WriteBytes(params byte[] bytes)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryEncode(bytes, out byte[] message))
|
|
||||||
{
|
|
||||||
base.WriteBytes(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void BeginRead(byte[] buffer)
|
|
||||||
{
|
|
||||||
var start = Array.IndexOf(buffer, this.encoder.Device2PC);
|
|
||||||
|
|
||||||
if (start >= 0)
|
|
||||||
{
|
|
||||||
if (this.encoder.TryDecode(buffer, out byte[] message))
|
|
||||||
{
|
|
||||||
this.EnqueueMessage(message);
|
|
||||||
this.RemoveRange(message.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.RemoveRange(buffer.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,8 +29,9 @@
|
|||||||
public void ToASCIIString(byte[] buffer, int start, int end)
|
public void ToASCIIString(byte[] buffer, int start, int end)
|
||||||
{
|
{
|
||||||
var value = string.Empty;
|
var value = string.Empty;
|
||||||
|
var length = buffer.Length;
|
||||||
|
|
||||||
while (start <= end)
|
while (start < length && start <= end)
|
||||||
{
|
{
|
||||||
value += (char)buffer[start];
|
value += (char)buffer[start];
|
||||||
start++;
|
start++;
|
||||||
@@ -62,13 +63,12 @@
|
|||||||
{
|
{
|
||||||
var buffer = ASCII.GetBytes(value);
|
var buffer = ASCII.GetBytes(value);
|
||||||
var bufferLength = buffer.Length;
|
var bufferLength = buffer.Length;
|
||||||
var i = 0;
|
var bufferIndex = 0;
|
||||||
|
var i = 1;
|
||||||
|
|
||||||
while (i < this.length && i < bufferLength)
|
while (i < this.length && i < bufferLength)
|
||||||
{
|
{
|
||||||
this.bytes[i] = buffer[i];
|
this.bytes[i++] = buffer[bufferIndex++];
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,9 +88,9 @@
|
|||||||
get => this.programmableID;
|
get => this.programmableID;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SetASCIIBytes(value, 0, 20);
|
this.SetASCIIBytes(value, 1, 20);
|
||||||
|
|
||||||
this.programmableID = this.bytes.ToASCIIString(0, 20);
|
this.programmableID = this.bytes.ToASCIIString(1, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@
|
|||||||
get => this.factoryID;
|
get => this.factoryID;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SetASCIIBytes(value, 21, 13);
|
this.SetASCIIBytes(value, 22, 33);
|
||||||
|
|
||||||
this.factoryID = this.bytes.ToASCIIString(21, 13);
|
this.factoryID = this.bytes.ToASCIIString(22, 33);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,9 +139,9 @@
|
|||||||
get => this.readingPreset;
|
get => this.readingPreset;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SetASCIIBytes(value, 38, 9);
|
this.SetASCIIBytes(value, 39, 47);
|
||||||
|
|
||||||
this.readingPreset = this.bytes.ToASCIIString(38, 9);
|
this.readingPreset = this.bytes.ToASCIIString(36, 47);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,9 +240,9 @@
|
|||||||
get => this.buildInfo;
|
get => this.buildInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SetASCIIBytes(value, 64, 14);
|
this.SetASCIIBytes(value, 65, 79);
|
||||||
|
|
||||||
this.buildInfo = this.bytes.ToASCIIString(64, 14);
|
this.buildInfo = this.bytes.ToASCIIString(65, 79);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,13 +257,13 @@
|
|||||||
get => this.deviceID;
|
get => this.deviceID;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SetASCIIBytes(value, 80, 9);
|
this.SetASCIIBytes(value, 81, 89);
|
||||||
|
|
||||||
this.deviceID = this.bytes.ToASCIIString(80, 9);
|
this.deviceID = this.bytes.ToASCIIString(81, 89);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetASCIIBytes(string value, int start, int length)
|
private void SetASCIIBytes(string value, int start, int end)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
{
|
{
|
||||||
@@ -276,9 +276,7 @@
|
|||||||
var asciiLength = asciiBytes.Length;
|
var asciiLength = asciiBytes.Length;
|
||||||
var asciiIndex = 0;
|
var asciiIndex = 0;
|
||||||
|
|
||||||
length += start;
|
while (start >= 0 && start <= end && asciiIndex < asciiLength)
|
||||||
|
|
||||||
while (start >= 0 && start < length && asciiIndex < asciiLength)
|
|
||||||
{
|
{
|
||||||
this.bytes[start++] = asciiBytes[asciiIndex++];
|
this.bytes[start++] = asciiBytes[asciiIndex++];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,6 @@
|
|||||||
set => this.SecondsSince = (uint)(value - epoch).TotalSeconds;
|
set => this.SecondsSince = (uint)(value - epoch).TotalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint UTCNow => new Epoch20000101 { DateTime = DateTime.UtcNow }.SecondsSince + 10;
|
public static uint UTCNow => new Epoch20000101 { DateTime = DateTime.UtcNow }.SecondsSince + 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
this.Status = (Status)response[0];
|
this.Status = (Status)response[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseLength > this.length)
|
if (responseLength > 1)
|
||||||
{
|
{
|
||||||
Array.Copy(response, 1, this.bytes, 0, this.length);
|
Array.Copy(response, 1, this.bytes, 0, this.length);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace OmniPlus.Features
|
namespace OmniPlus.Features
|
||||||
{
|
{
|
||||||
internal class Features
|
public class Features
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The View Factory ID command shall cause the slave device to transmit the factory ID.
|
/// The View Factory ID command shall cause the slave device to transmit the factory ID.
|
||||||
|
|||||||
@@ -86,11 +86,11 @@
|
|||||||
return subarray;
|
return subarray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToASCIIString(this byte[] bytes, int start, int length)
|
public static string ToASCIIString(this byte[] bytes, int start, int end)
|
||||||
{
|
{
|
||||||
var asciiString = string.Empty;
|
var asciiString = string.Empty;
|
||||||
|
|
||||||
while (start >= 0 && start < bytes.Length)
|
while (start >= 0 && end < bytes.Length && start < end)
|
||||||
{
|
{
|
||||||
asciiString += (char)bytes[start++];
|
asciiString += (char)bytes[start++];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,6 @@
|
|||||||
set => this.bytes[5] = value;
|
set => this.bytes[5] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double MlPerRotation { get; set; }
|
public ushort IntPartFull => BitConverter.ToUInt16(this.bytes, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
namespace OmniPlus.Features
|
namespace OmniPlus.Features
|
||||||
{
|
{
|
||||||
using OmniPlus.Features.Enums;
|
using OmniPlus.Features.Enums;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Versions B1.24 of this command are supported. Total Forward and Total Reverse are not supported.
|
/// Versions B1.24 of this command are supported. Total Forward and Total Reverse are not supported.
|
||||||
@@ -18,10 +19,14 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ReadingPreset : FeatureRequest
|
public class ReadingPreset : FeatureRequest
|
||||||
{
|
{
|
||||||
const int LENGTH = 2;
|
const int LENGTH = 11;
|
||||||
|
|
||||||
public ReadingPreset() : base(LENGTH)
|
public ReadingPreset() : base(LENGTH)
|
||||||
{
|
{
|
||||||
|
for (int i = 2; i < 11; i++)
|
||||||
|
{
|
||||||
|
this.bytes[i] = (byte)'0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte SensorID
|
public byte SensorID
|
||||||
|
|||||||
@@ -52,14 +52,54 @@
|
|||||||
|
|
||||||
public byte FlowUnits
|
public byte FlowUnits
|
||||||
{
|
{
|
||||||
get => this.bytes[8].GetUint8(0, 4);
|
get
|
||||||
set => FeaturesExtensions.SetUint8(ref this.bytes[8], 0, 4, value);
|
{
|
||||||
|
var src = this.bytes[8].GetBits();
|
||||||
|
var dst = new byte[8];
|
||||||
|
|
||||||
|
Array.Copy(src, 0, dst, 0, 4);
|
||||||
|
|
||||||
|
return dst.ToUint8();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var srcIndex = 0;
|
||||||
|
var srcBits = value.GetBits();
|
||||||
|
var dstBits = this.bytes[8].GetBits();
|
||||||
|
|
||||||
|
for (int dstIndex = 0; dstIndex < 4; dstIndex++)
|
||||||
|
{
|
||||||
|
dstBits[dstIndex] = srcBits[srcIndex++];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bytes[8] = dstBits.ToUint8();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte FlowRate
|
public byte FlowRate
|
||||||
{
|
{
|
||||||
get => this.bytes[8].GetUint8(4, 4);
|
get
|
||||||
set => FeaturesExtensions.SetUint8(ref this.bytes[8], 4, 4, value);
|
{
|
||||||
|
var src = this.bytes[8].GetBits();
|
||||||
|
var dst = new byte[8];
|
||||||
|
|
||||||
|
Array.Copy(src, 4, dst, 0, 4);
|
||||||
|
|
||||||
|
return dst.ToUint8();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var srcIndex = 0;
|
||||||
|
var srcBits = value.GetBits();
|
||||||
|
var dstBits = this.bytes[8].GetBits();
|
||||||
|
|
||||||
|
for (int dstIndex = 4; dstIndex < 8; dstIndex++)
|
||||||
|
{
|
||||||
|
dstBits[dstIndex] = srcBits[srcIndex++];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bytes[8] = dstBits.ToUint8();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sbyte FactoryCorrection
|
public sbyte FactoryCorrection
|
||||||
@@ -82,14 +122,54 @@
|
|||||||
|
|
||||||
public byte PulseWidth
|
public byte PulseWidth
|
||||||
{
|
{
|
||||||
get => this.bytes[12].GetUint8(0, 3);
|
get
|
||||||
set => FeaturesExtensions.SetUint8(ref this.bytes[12], 0, 3, value);
|
{
|
||||||
|
var src = this.bytes[12].GetBits();
|
||||||
|
var dst = new byte[8];
|
||||||
|
|
||||||
|
Array.Copy(src, 0, dst, 0, 3);
|
||||||
|
|
||||||
|
return dst.ToUint8();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var srcIndex = 0;
|
||||||
|
var srcBits = value.GetBits();
|
||||||
|
var dstBits = this.bytes[12].GetBits();
|
||||||
|
|
||||||
|
for (int dstIndex = 0; dstIndex < 3; dstIndex++)
|
||||||
|
{
|
||||||
|
dstBits[dstIndex] = srcBits[srcIndex++];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bytes[12] = dstBits.ToUint8();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte PulseUpdate
|
public byte PulseUpdate
|
||||||
{
|
{
|
||||||
get => this.bytes[12].GetUint8(3, 3);
|
get
|
||||||
set => FeaturesExtensions.SetUint8(ref this.bytes[12], 3, 3, value);
|
{
|
||||||
|
var src = this.bytes[12].GetBits();
|
||||||
|
var dst = new byte[8];
|
||||||
|
|
||||||
|
Array.Copy(src, 3, dst, 0, 3);
|
||||||
|
|
||||||
|
return dst.ToUint8();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var srcIndex = 0;
|
||||||
|
var srcBits = value.GetBits();
|
||||||
|
var dstBits = this.bytes[12].GetBits();
|
||||||
|
|
||||||
|
for (int dstIndex = 3; dstIndex < 6; dstIndex++)
|
||||||
|
{
|
||||||
|
dstBits[dstIndex] = srcBits[srcIndex++];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bytes[12] = dstBits.ToUint8();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
namespace OmniPlus.Inspection
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
|
|
||||||
internal static class OmniPlusExtensions
|
|
||||||
{
|
|
||||||
public static double MlPerRotation(byte intPart, ushort fraction, short correctionFactor)
|
|
||||||
=> (intPart + (double)fraction / ushort.MaxValue) * correctionFactor;
|
|
||||||
|
|
||||||
public static double GPM2M3H(double value)
|
|
||||||
=> value * 3785.411784 / 1000 / 1000 * 60;
|
|
||||||
|
|
||||||
public static double GetCorrectionFactor(this double[] points)
|
|
||||||
{
|
|
||||||
if (points?.Length != 3)
|
|
||||||
{
|
|
||||||
return double.MinValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var min = points[0];
|
|
||||||
var mid = points[1];
|
|
||||||
var max = points[2];
|
|
||||||
|
|
||||||
if (Math.Abs(mid - max) <= 3 && Math.Max(mid, max) - min <= 6.5)
|
|
||||||
{
|
|
||||||
var avgMidMax = (mid + max) / 2;
|
|
||||||
|
|
||||||
if (100 - avgMidMax + min < 95)
|
|
||||||
{
|
|
||||||
return 95 - min;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 100 - avgMidMax;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return double.MaxValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,21 +4,85 @@
|
|||||||
|
|
||||||
public static class OmniPlusFormulas
|
public static class OmniPlusFormulas
|
||||||
{
|
{
|
||||||
public static double MlPerRotation(byte intPart, ushort fraction, short correctionFactor)
|
public static double MilliliterPerRotation(byte intPart, ushort fraction, short correctionFactor)
|
||||||
{
|
{
|
||||||
return (intPart + (double)fraction / ushort.MaxValue) * correctionFactor;
|
const int FRACTION_FACTOR = ushort.MaxValue + 1;
|
||||||
|
const int PULSES_PER_ROTATION = 8;
|
||||||
|
|
||||||
|
var fractionPart = (double)fraction / FRACTION_FACTOR;
|
||||||
|
var mlPlain = intPart + fractionPart;
|
||||||
|
var mlPulse = intPart + fractionPart;
|
||||||
|
var mlr = mlPulse * PULSES_PER_ROTATION;
|
||||||
|
|
||||||
|
return mlr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double GPM2M3H(double value)
|
public static double MilliliterPerRotation(this OmniPlusType type)
|
||||||
{
|
{
|
||||||
return value * 3785.411784 / 1000 / 1000 * 60;
|
return MilliliterPerRotation(type.IntPart, type.Fraction, type.CorrectionFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double GPM2M3H(this double gal_min)
|
||||||
|
{
|
||||||
|
const double ML_IN_GAL = 3785.411784;
|
||||||
|
|
||||||
|
var ml_min = gal_min * ML_IN_GAL;
|
||||||
|
var l_min = ml_min / 1000;
|
||||||
|
var m3_min = l_min / 1000;
|
||||||
|
var m3_h = m3_min * 60;
|
||||||
|
|
||||||
|
return m3_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ushort DurationInSeconds(this ushort rotations, double mlr, double flowM3H)
|
||||||
|
{
|
||||||
|
var ml_h = flowM3H * 1000 * 1000;
|
||||||
|
var ml_s = ml_h / 3600;
|
||||||
|
var s_r = mlr / ml_s * 100;
|
||||||
|
var duration = s_r * rotations;
|
||||||
|
|
||||||
|
return (ushort)(Math.Truncate(duration) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ushort ResponseFlowM3H(this ushort rotations, double mlr, double flowM3H)
|
||||||
|
{
|
||||||
|
var ml_h = flowM3H * 1000 * 1000;
|
||||||
|
var ml_s = ml_h / 3600;
|
||||||
|
var s_r = mlr / ml_s * 100;
|
||||||
|
var duration = s_r * rotations;
|
||||||
|
|
||||||
|
return (ushort)(Math.Truncate(duration) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double DifferencePercentage(this OmniPlusTest test)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return 100 + (test.MeterFlowM3S - test.ReferenceFlowM3S) / test.ReferenceFlowM3S * 100;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double MeterFlowM3S(double rotations, double mlr, double duration)
|
||||||
|
{
|
||||||
|
var seconds = duration * (1D / (short.MaxValue + 1));
|
||||||
|
|
||||||
|
return rotations * mlr / seconds / 1000D / 1000D * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double MeterFlowM3S(this OmniPlusTestPoint point, OmniPlusTest test)
|
||||||
|
{
|
||||||
|
return MeterFlowM3S(test.Rotations, point.MLR, test.Duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double GetCorrectionFactor(this double[] points)
|
public static double GetCorrectionFactor(this double[] points)
|
||||||
{
|
{
|
||||||
if (points?.Length != 3)
|
if (points is null || points.Length != 3)
|
||||||
{
|
{
|
||||||
return double.MinValue;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var min = points[0];
|
var min = points[0];
|
||||||
@@ -39,7 +103,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return double.MaxValue;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,8 @@
|
|||||||
|
|
||||||
public double Duration { get; set; }
|
public double Duration { get; set; }
|
||||||
|
|
||||||
public double MeterVolume { get; set; }
|
public double MeterFlowM3S { get; set; }
|
||||||
|
|
||||||
public double VolumeMessured { get; set; }
|
public double ReferenceFlowM3S { get; set; }
|
||||||
|
|
||||||
public double DifferencePercentage
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return 100 + (this.MeterVolume - this.VolumeMessured) / this.VolumeMessured;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,29 @@
|
|||||||
|
|
||||||
public struct OmniPlusTestPoint : IComparable<OmniPlusTestPoint>
|
public struct OmniPlusTestPoint : IComparable<OmniPlusTestPoint>
|
||||||
{
|
{
|
||||||
public double GalPerMin { get; set; }
|
private double gpm;
|
||||||
|
public double GPM
|
||||||
|
{
|
||||||
|
get => this.gpm;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.gpm = value;
|
||||||
|
this.RequiredFlowM3H = this.gpm.GPM2M3H();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ushort Rotations { get; set; }
|
public ushort rotations;
|
||||||
|
public ushort Rotations
|
||||||
|
{
|
||||||
|
get => this.rotations;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.rotations = value;
|
||||||
|
this.Duration = this.rotations.DurationInSeconds(this.MLR, this.RequiredFlowM3H);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double MLR { get; set; }
|
||||||
|
|
||||||
public ushort Duration { get; set; }
|
public ushort Duration { get; set; }
|
||||||
|
|
||||||
@@ -14,25 +34,11 @@
|
|||||||
|
|
||||||
public double MaxDiff { get; set; }
|
public double MaxDiff { get; set; }
|
||||||
|
|
||||||
public double MlPerRotation { get; set; }
|
public double RequiredFlowM3H { get; private set; }
|
||||||
|
|
||||||
public double VolumeM3H
|
|
||||||
=> OmniPlusExtensions.GPM2M3H(this.GalPerMin);
|
|
||||||
|
|
||||||
public int CompareTo(OmniPlusTestPoint other)
|
public int CompareTo(OmniPlusTestPoint other)
|
||||||
=> this.Rotations.CompareTo(other.Rotations);
|
|
||||||
|
|
||||||
public double VolumeM3(double rotations, double duration)
|
|
||||||
{
|
{
|
||||||
var seconds = duration / 32768;
|
return this.GPM.CompareTo(other.GPM);
|
||||||
var milliliter = rotations * this.MlPerRotation;
|
|
||||||
|
|
||||||
return seconds * milliliter / 1000 / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double VolumeM3(OmniPlusTest test)
|
|
||||||
{
|
|
||||||
return this.VolumeM3(test.Rotations, test.Duration);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,18 +42,6 @@
|
|||||||
|
|
||||||
public short CorrectionFactor { get; set; }
|
public short CorrectionFactor { get; set; }
|
||||||
|
|
||||||
public double MlPerRotation
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var mlPerRotation = OmniPlusExtensions.MlPerRotation(this.IntPart, this.Fraction, this.CorrectionFactor);
|
|
||||||
|
|
||||||
this.InputVolume.MlPerRotation = mlPerRotation;
|
|
||||||
|
|
||||||
return OmniPlusExtensions.MlPerRotation(this.IntPart, this.Fraction, this.CorrectionFactor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputVolume InputVolume { get; }
|
public InputVolume InputVolume { get; }
|
||||||
= new InputVolume();
|
= new InputVolume();
|
||||||
|
|
||||||
|
|||||||
+14
-61
@@ -1,73 +1,19 @@
|
|||||||
namespace OmniPlus
|
namespace OmniPlus
|
||||||
{
|
{
|
||||||
using OmniPlus.Connections;
|
|
||||||
using OmniPlus.Features;
|
using OmniPlus.Features;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO.Ports;
|
|
||||||
|
|
||||||
using static OmniPlus.Features.Features;
|
using static OmniPlus.Features.Features;
|
||||||
|
|
||||||
internal delegate byte[] MessageHandler(params byte[] bytes);
|
public delegate byte[] MessageHandler(params byte[] bytes);
|
||||||
|
public delegate void StateChanged(object state);
|
||||||
|
|
||||||
public sealed class OmniPlusConnection
|
public abstract class OmniConnection
|
||||||
{
|
{
|
||||||
private Func<bool> connected;
|
protected MessageHandler MessageHandler { get; set; }
|
||||||
private readonly UI1236Stream ui1236;
|
|
||||||
private readonly UniProStream unipro;
|
|
||||||
|
|
||||||
public OmniPlusConnection(string portName)
|
public abstract void Close();
|
||||||
{
|
|
||||||
this.ui1236 = new UI1236Stream(new SerialPortSettings
|
|
||||||
{
|
|
||||||
BaudRate = 115200,
|
|
||||||
DataBits = 8,
|
|
||||||
Parity = Parity.None,
|
|
||||||
PortName = portName,
|
|
||||||
StopBits = StopBits.One
|
|
||||||
});
|
|
||||||
this.unipro = new UniProStream(new SerialPortSettings
|
|
||||||
{
|
|
||||||
BaudRate = 2400,
|
|
||||||
DataBits = 8,
|
|
||||||
Parity = Parity.None,
|
|
||||||
PortName = portName,
|
|
||||||
StopBits = StopBits.One
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
internal MessageHandler MessageHandler;
|
public abstract void Open();
|
||||||
|
|
||||||
public bool Connected
|
|
||||||
=> this.connected?.Invoke() ?? false;
|
|
||||||
|
|
||||||
public bool ConnectIrda()
|
|
||||||
{
|
|
||||||
this.unipro.Dispose();
|
|
||||||
this.ui1236.Open();
|
|
||||||
|
|
||||||
this.connected = () => this.ui1236.IsOpen;
|
|
||||||
this.MessageHandler = this.ui1236.Write;
|
|
||||||
|
|
||||||
return this.ui1236.IsOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ConnectUniPro()
|
|
||||||
{
|
|
||||||
this.ui1236.Dispose();
|
|
||||||
this.unipro.Open();
|
|
||||||
|
|
||||||
this.connected = () => this.unipro.IsOpen;
|
|
||||||
this.MessageHandler = this.unipro.Write;
|
|
||||||
|
|
||||||
return this.unipro.IsOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Disconnect()
|
|
||||||
{
|
|
||||||
this.unipro.Dispose();
|
|
||||||
this.ui1236.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FactoryID ViewFactoryID()
|
public FactoryID ViewFactoryID()
|
||||||
{
|
{
|
||||||
@@ -132,7 +78,7 @@
|
|||||||
return new RateResolution(response);
|
return new RateResolution(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Readings ViewReadings(Readings reading)
|
public Readings ViewReadings()
|
||||||
{
|
{
|
||||||
var response = this.MessageHandler.Invoke(VIEW_READINGS);
|
var response = this.MessageHandler.Invoke(VIEW_READINGS);
|
||||||
|
|
||||||
@@ -153,6 +99,13 @@
|
|||||||
return new BuildInfo(response);
|
return new BuildInfo(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChamberCalibrationResponse Set(ChamberCalibrationRequest chamberCalibrationRequest)
|
||||||
|
{
|
||||||
|
var response = this.MessageHandler.Invoke(DEVICE_SPECIFIC, CHAMBER_CALIBRATION);
|
||||||
|
|
||||||
|
return new ChamberCalibrationResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
public SystemParameters ViewSystemParameters()
|
public SystemParameters ViewSystemParameters()
|
||||||
{
|
{
|
||||||
var response = this.MessageHandler.Invoke(DEVICE_SPECIFIC, VIEW_SYSTEM_PARAMETERS);
|
var response = this.MessageHandler.Invoke(DEVICE_SPECIFIC, VIEW_SYSTEM_PARAMETERS);
|
||||||
+6
-6
@@ -8,11 +8,11 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
public class OmniPlusDatabase
|
public class OmniDatabase
|
||||||
{
|
{
|
||||||
private readonly string connectionString;
|
private readonly string connectionString;
|
||||||
|
|
||||||
public OmniPlusDatabase(string omniDatabase)
|
public OmniDatabase(string omniDatabase)
|
||||||
=> this.connectionString = omniDatabase;
|
=> this.connectionString = omniDatabase;
|
||||||
|
|
||||||
public void AddOrUpdate(int position, SystemParameters parameters)
|
public void AddOrUpdate(int position, SystemParameters parameters)
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
omniType.Direction = sqlDataReader.GetValue<byte>(field++);
|
omniType.Direction = sqlDataReader.GetValue<byte>(field++);
|
||||||
omniType.IntPart = sqlDataReader.GetValue<byte>(field++);
|
omniType.IntPart = sqlDataReader.GetValue<byte>(field++);
|
||||||
omniType.Fraction = (ushort)sqlDataReader.GetValue<int>(field++);
|
omniType.Fraction = (ushort)sqlDataReader.GetValue<int>(field++);
|
||||||
omniType.PulsePerRotation = sqlDataReader.GetValue<double>(field++);
|
omniType.PulsePerRotation = sqlDataReader.GetValue<byte>(field++);
|
||||||
omniType.CorrectionFactor = sqlDataReader.GetValue<short>(field++);
|
omniType.CorrectionFactor = sqlDataReader.GetValue<short>(field++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
|
|
||||||
using (var sqlDataReader = sqlCommand.ExecuteReader())
|
using (var sqlDataReader = sqlCommand.ExecuteReader())
|
||||||
{
|
{
|
||||||
var mlPerRotation = omniType.MlPerRotation;
|
var milliliterPerRotation = omniType.MilliliterPerRotation();
|
||||||
|
|
||||||
while (sqlDataReader.Read())
|
while (sqlDataReader.Read())
|
||||||
{
|
{
|
||||||
@@ -176,8 +176,8 @@
|
|||||||
|
|
||||||
omniType.TestPoints.Add(new OmniPlusTestPoint
|
omniType.TestPoints.Add(new OmniPlusTestPoint
|
||||||
{
|
{
|
||||||
MlPerRotation = mlPerRotation,
|
MLR = milliliterPerRotation,
|
||||||
GalPerMin = sqlDataReader.GetValue<double>(field++),
|
GPM = sqlDataReader.GetValue<double>(field++),
|
||||||
Rotations = (ushort)sqlDataReader.GetValue<short>(field++),
|
Rotations = (ushort)sqlDataReader.GetValue<short>(field++),
|
||||||
Duration = (ushort)sqlDataReader.GetValue<short>(field++),
|
Duration = (ushort)sqlDataReader.GetValue<short>(field++),
|
||||||
MinDiff = sqlDataReader.GetValue<double>(field++),
|
MinDiff = sqlDataReader.GetValue<double>(field++),
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
namespace OmniPlus
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using ExchangeHub;
|
||||||
|
|
||||||
|
public class OmniExchange
|
||||||
|
{
|
||||||
|
private readonly ExchangeConnection connection;
|
||||||
|
|
||||||
|
public OmniExchange()
|
||||||
|
{
|
||||||
|
this.connection = new ExchangeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Connect(string url)
|
||||||
|
{
|
||||||
|
this.connection.Connect(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disconnect()
|
||||||
|
{
|
||||||
|
this.connection.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopFlow()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
namespace OmniPlus
|
||||||
|
{
|
||||||
|
using OmniPlus.Connections;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Ports;
|
||||||
|
|
||||||
|
public sealed class OmniIrdaConnection : OmniConnection
|
||||||
|
{
|
||||||
|
private readonly OmniIrdaStream stream;
|
||||||
|
private readonly string stateFile;
|
||||||
|
|
||||||
|
public OmniIrdaConnection(string portName)
|
||||||
|
{
|
||||||
|
this.stateFile = this.GetOrCreateStateFile(portName);
|
||||||
|
this.stream = new OmniIrdaStream(
|
||||||
|
encoder: new OmniIrdaEncoder(),
|
||||||
|
settings: new SerialPortSettings
|
||||||
|
{
|
||||||
|
BaudRate = 115200,
|
||||||
|
DataBits = 8,
|
||||||
|
Parity = Parity.None,
|
||||||
|
PortName = portName,
|
||||||
|
StopBits = StopBits.One
|
||||||
|
});
|
||||||
|
this.stream.StateChanged += this.OnStateChanged;
|
||||||
|
this.MessageHandler = this.stream.Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
this.stream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Open()
|
||||||
|
{
|
||||||
|
this.stream.Open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStateChanged(object state)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.AppendAllText(this.stateFile, $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fffffff}] {state}{Environment.NewLine}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.AppendAllText(this.stateFile, $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fffffff}] {e}");
|
||||||
|
}
|
||||||
|
catch (Exception _)
|
||||||
|
{
|
||||||
|
// TODO: throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOrCreateStateFile(string portName)
|
||||||
|
{
|
||||||
|
var stateFile = $"{portName}_{DateTime.Now:yyyy_MM_dd}.txt";
|
||||||
|
var directory = Directory.CreateDirectory(".\\OmniIrda");
|
||||||
|
stateFile = Path.Combine(directory.FullName, stateFile);
|
||||||
|
|
||||||
|
File.AppendAllText(stateFile, string.Empty);
|
||||||
|
|
||||||
|
return stateFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
namespace OmniPlus
|
||||||
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public sealed class OmniIrdaEOL
|
||||||
|
{
|
||||||
|
private readonly IDictionary<int, OmniConnection> connections;
|
||||||
|
private readonly IDictionary<int, OmniMeter> meters;
|
||||||
|
private readonly OmniExchange exchangeHub;
|
||||||
|
private readonly OmniDatabase database;
|
||||||
|
|
||||||
|
public OmniIrdaEOL(string connectionString)
|
||||||
|
{
|
||||||
|
this.connections = new Dictionary<int, OmniConnection>();
|
||||||
|
this.meters = new Dictionary<int, OmniMeter>();
|
||||||
|
this.exchangeHub = new OmniExchange();
|
||||||
|
this.database = new OmniDatabase(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddConnection(string portName)
|
||||||
|
{
|
||||||
|
var nr = this.connections.Count + 1;
|
||||||
|
this.connections[nr] = new OmniIrdaConnection(portName);
|
||||||
|
this.meters[nr] = new OmniMeter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
foreach (var connection in this.connections.Values)
|
||||||
|
{
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.connections.Clear();
|
||||||
|
this.meters.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace OmniPlus
|
||||||
|
{
|
||||||
|
public class OmniMeter
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,19 +46,16 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Connections\IrdaEncoder.cs" />
|
<Compile Include="Connections\OmniIrdaEncoder.cs" />
|
||||||
<Compile Include="Connections\IrdaStream.cs" />
|
<Compile Include="Connections\OmniIrdaStream.cs" />
|
||||||
<Compile Include="Connections\Program.cs" />
|
<Compile Include="Connections\OmniUniProEncoder.cs" />
|
||||||
|
<Compile Include="Connections\OmniUniProStream.cs" />
|
||||||
<Compile Include="Connections\SerialDataEncoder.cs" />
|
<Compile Include="Connections\SerialDataEncoder.cs" />
|
||||||
<Compile Include="Connections\SerialDataExtensions.cs" />
|
<Compile Include="Connections\SerialDataExtensions.cs" />
|
||||||
<Compile Include="Connections\SerialDataReader.cs" />
|
|
||||||
<Compile Include="Connections\SerialDataStream.cs" />
|
<Compile Include="Connections\SerialDataStream.cs" />
|
||||||
<Compile Include="Connections\SerialPortSettings.cs" />
|
<Compile Include="Connections\SerialPortSettings.cs" />
|
||||||
<Compile Include="Connections\SerialPortStream.cs" />
|
<Compile Include="Connections\SerialPortStream.cs" />
|
||||||
<Compile Include="Connections\UI1236Encoder.cs" />
|
<Compile Include="Connections\UI1236Control.cs" />
|
||||||
<Compile Include="Connections\UI1236Stream.cs" />
|
|
||||||
<Compile Include="Connections\UniProEncoder.cs" />
|
|
||||||
<Compile Include="Connections\UniProStream.cs" />
|
|
||||||
<Compile Include="Features\Enums\MessurementUnits.cs" />
|
<Compile Include="Features\Enums\MessurementUnits.cs" />
|
||||||
<Compile Include="Features\Enums\ReadingSettings.cs" />
|
<Compile Include="Features\Enums\ReadingSettings.cs" />
|
||||||
<Compile Include="Features\Enums\Status.cs" />
|
<Compile Include="Features\Enums\Status.cs" />
|
||||||
@@ -98,14 +95,16 @@
|
|||||||
<Compile Include="Features\SystemTime.cs" />
|
<Compile Include="Features\SystemTime.cs" />
|
||||||
<Compile Include="Features\VersionAndType.cs" />
|
<Compile Include="Features\VersionAndType.cs" />
|
||||||
<Compile Include="Inspection\OmniPlusFormulas.cs" />
|
<Compile Include="Inspection\OmniPlusFormulas.cs" />
|
||||||
<Compile Include="OmniPlusConnection.cs" />
|
<Compile Include="OmniConnection.cs" />
|
||||||
<Compile Include="OmniPlusConnectionsPool.cs" />
|
<Compile Include="OmniExchange.cs" />
|
||||||
<Compile Include="OmniPlusDatabase.cs" />
|
<Compile Include="OmniIrdaEOL.cs" />
|
||||||
<Compile Include="Inspection\OmniPlusExtensions.cs" />
|
<Compile Include="OmniIrdaConnection.cs" />
|
||||||
|
<Compile Include="OmniMeter.cs" />
|
||||||
|
<Compile Include="OmniDatabase.cs" />
|
||||||
<Compile Include="Inspection\OmniPlusTest.cs" />
|
<Compile Include="Inspection\OmniPlusTest.cs" />
|
||||||
<Compile Include="Inspection\OmniPlusTestPoint.cs" />
|
<Compile Include="Inspection\OmniPlusTestPoint.cs" />
|
||||||
<Compile Include="Inspection\OmniPlusType.cs" />
|
<Compile Include="Inspection\OmniPlusType.cs" />
|
||||||
<Compile Include="Connections\UI1236Control.cs" />
|
<Compile Include="OmniUniProConnection.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -115,6 +114,11 @@
|
|||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\ExchangeHub\ExchangeHub.csproj">
|
||||||
|
<Project>{6033FF0C-CF32-4BC5-8EFE-4774CCDC663D}</Project>
|
||||||
|
<Name>ExchangeHub</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,498 +0,0 @@
|
|||||||
using OmniPlus.Features;
|
|
||||||
using OmniPlus.Inspection;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace OmniPlus
|
|
||||||
{
|
|
||||||
public class OmniPlusConnectionsPool : IDisposable
|
|
||||||
{
|
|
||||||
public event Action Done;
|
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<int, OmniPlusConnection> connections;
|
|
||||||
private readonly ConcurrentDictionary<int, OmniPlusMeter> meters;
|
|
||||||
private readonly CancellationTokenSource cancellationTokenSource;
|
|
||||||
private readonly CancellationToken cancellationToken;
|
|
||||||
private readonly OmniPlusExchangeSlave exchangeSlave;
|
|
||||||
private readonly OmniPlusDatabase database;
|
|
||||||
private readonly OmniPlusType omniType;
|
|
||||||
|
|
||||||
private byte size;
|
|
||||||
private string variant;
|
|
||||||
private BackgroundWorker background;
|
|
||||||
|
|
||||||
public OmniPlusConnectionsPool(string dbConnectionString, string signalRURL)
|
|
||||||
{
|
|
||||||
this.connections = new ConcurrentDictionary<int, OmniPlusConnection>();
|
|
||||||
this.meters = new ConcurrentDictionary<int, OmniPlusMeter>();
|
|
||||||
this.cancellationTokenSource = new CancellationTokenSource();
|
|
||||||
this.exchangeSlave = new OmniPlusExchangeSlave(signalRURL);
|
|
||||||
this.database = new OmniPlusDatabase(dbConnectionString);
|
|
||||||
this.omniType = new OmniPlusType();
|
|
||||||
|
|
||||||
this.size = 5;
|
|
||||||
this.variant = "C2";
|
|
||||||
this.cancellationToken = this.cancellationTokenSource.Token;
|
|
||||||
this.cancellationToken.Register(this.CancellationCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
this.exchangeSlave.Dispose();
|
|
||||||
|
|
||||||
// Disposes all OmniPlus connections.
|
|
||||||
foreach (var connectionKVP in this.connections)
|
|
||||||
{
|
|
||||||
connectionKVP.Value?.Disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clears collected connections and their meters.
|
|
||||||
this.connections.Clear();
|
|
||||||
this.meters.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeInspection(params string[] portNames)
|
|
||||||
{
|
|
||||||
OmniPlusConnection connection;
|
|
||||||
OmniPlusMeter meter;
|
|
||||||
int position = 1;
|
|
||||||
bool connected;
|
|
||||||
|
|
||||||
foreach (var portName in portNames)
|
|
||||||
{
|
|
||||||
connection = new OmniPlusConnection(portName);
|
|
||||||
connected = connection.ConnectIrda();
|
|
||||||
|
|
||||||
if (connected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connection.Disconnect();
|
|
||||||
connection = default(OmniPlusConnection);
|
|
||||||
meter = default(OmniPlusMeter);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.connections.TryAdd(position, connection);
|
|
||||||
|
|
||||||
position++;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.database.LoadOmniDefaults(this.size, this.variant, this.omniType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CancelExecution()
|
|
||||||
=> this.cancellationTokenSource.Cancel(false);
|
|
||||||
|
|
||||||
//public void StartInspection()
|
|
||||||
//{
|
|
||||||
// foreach (var position in this.connections.Keys)
|
|
||||||
// {
|
|
||||||
// this.StartOmniInitialization(position);
|
|
||||||
|
|
||||||
// //foreach (var point in this.omniType.TestPoints)
|
|
||||||
// //{
|
|
||||||
// // this.StartOmniInspection(position, point);
|
|
||||||
// //}
|
|
||||||
|
|
||||||
// //this.CalculateCorrectionFactor(position);
|
|
||||||
|
|
||||||
// this.FinishOmniInspection(position);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public void StartInspection()
|
|
||||||
{
|
|
||||||
this.background = new BackgroundWorker();
|
|
||||||
|
|
||||||
this.background.DoWork += this.StartInspection;
|
|
||||||
|
|
||||||
this.background.RunWorkerAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartInspection(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
var connectionsCount = this.connections.Count;
|
|
||||||
var tasks = new Task[connectionsCount];
|
|
||||||
|
|
||||||
foreach (var position in this.connections.Keys)
|
|
||||||
{
|
|
||||||
tasks[position - 1] = Task.Factory.StartNew(() => this.StartOmniInitialization(position), this.cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var point in this.omniType.TestPoints)
|
|
||||||
{
|
|
||||||
// TODO: 600 = 10min * 60sec - change for production.
|
|
||||||
|
|
||||||
//if (!this.exchangeSlave.SetQAndWaitUntilReached(point.VolumeM3H))
|
|
||||||
//{
|
|
||||||
// this.CancelExecution();
|
|
||||||
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
|
|
||||||
tasks = new Task[connectionsCount];
|
|
||||||
|
|
||||||
foreach (var position in this.connections.Keys)
|
|
||||||
{
|
|
||||||
tasks[position - 1] = Task.Factory.StartNew(() => this.StartOmniInspection(position, point), this.cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
//var volume = this.exchangeSlave.RequestRefV();
|
|
||||||
|
|
||||||
//foreach (var position in this.connections.Keys)
|
|
||||||
//{
|
|
||||||
// this.SetPointDifference(position, point, volume);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var position in this.connections.Keys)
|
|
||||||
{
|
|
||||||
this.CalculateCorrectionFactor(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks = new Task[connectionsCount];
|
|
||||||
|
|
||||||
foreach (var position in this.connections.Keys)
|
|
||||||
{
|
|
||||||
tasks[position - 1] = Task.Factory.StartNew(() => this.FinishOmniInspection(position), this.cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Done?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartOmniInitialization(int position)
|
|
||||||
{
|
|
||||||
if (this.TryGetOmni(position, out var connection, out var meter))
|
|
||||||
{
|
|
||||||
var systemParameters = connection.ViewSystemParameters();
|
|
||||||
|
|
||||||
// connection.Set(this.omniType.InputVolume).Succeeded;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartOmniInspection(int position, OmniPlusTestPoint point)
|
|
||||||
{
|
|
||||||
var header = $"{point.VolumeM3H:0.0000}m³/h";
|
|
||||||
|
|
||||||
if (this.TryGetOmni(position, out var connection, out var meter) /*&& meter.Initialized && meter.CanCalibrate*/)
|
|
||||||
{
|
|
||||||
var activationResponse = connection.StartChamberCalibration(point.Rotations, point.Duration);
|
|
||||||
|
|
||||||
if (activationResponse.Succeeded)
|
|
||||||
{
|
|
||||||
var calibrationResult = new ChamberCalibrationResponse();
|
|
||||||
var duration = point.Duration + 3;
|
|
||||||
|
|
||||||
this.NotifyWhileThreadSleep(position, header, point.Duration + 3);
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
calibrationResult = connection.ViewChamberCalibration();
|
|
||||||
|
|
||||||
if (calibrationResult.Succeeded)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // activation failed
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // not connected
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetPointDifference(int position, OmniPlusTestPoint point, double volume)
|
|
||||||
{
|
|
||||||
//var header = $"{point.VolumeM3H:0.0000}m³/h";
|
|
||||||
|
|
||||||
//if (this.TryGetOmni(position, out var _, out var meter) && meter.Initialized && meter.CanCalibrate)
|
|
||||||
//{
|
|
||||||
// var difference = meter.AddCalibrationVolume(point, volume);
|
|
||||||
|
|
||||||
// this.StateChanged?.Invoke(position, 0, header, $"{difference:0.00}%");
|
|
||||||
//}
|
|
||||||
//else // not connected
|
|
||||||
//{
|
|
||||||
// this.StateChanged?.Invoke(position, 0, header, null);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CalculateCorrectionFactor(int position)
|
|
||||||
{
|
|
||||||
//if (this.TryGetOmni(position, out var _, out var meter) && meter.Initialized && meter.CanCalibrate)
|
|
||||||
//{
|
|
||||||
// var correctionFactor = meter.GetCorrectionFactor();
|
|
||||||
|
|
||||||
// this.StateChanged?.Invoke(position, meter.CanCalibrate ? 1 : -1, CORRECTION, $"{correctionFactor:0.00}%");
|
|
||||||
//}
|
|
||||||
//else // not connected
|
|
||||||
//{
|
|
||||||
// this.StateChanged?.Invoke(position, 0, CORRECTION, null);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FinishOmniInspection(int position)
|
|
||||||
{
|
|
||||||
//if (this.TryGetOmni(position, out var connection, out var meter)/* && meter.Calibrated*/)
|
|
||||||
//{
|
|
||||||
// var configurationParameters = connection.ViewConfigurationParameters();
|
|
||||||
// var canContinue = configurationParameters.Succeeded;
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// meter.AddConfigurationParameters(configurationParameters);
|
|
||||||
// this.database.AddOrUpdate(position, configurationParameters);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// // TODO: Uncomment in production
|
|
||||||
// //var systemTimeReset = connection.SetSystemTime();
|
|
||||||
// //canContinue = systemTimeReset.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var registerSettings = new RegisterSettings();
|
|
||||||
|
|
||||||
// registerSettings.IntPart = this.omniType.IntPart;
|
|
||||||
// registerSettings.Fraction = this.omniType.Fraction;
|
|
||||||
// registerSettings.Size = this.omniType.Size;
|
|
||||||
// registerSettings.Range = this.omniType.Range;
|
|
||||||
// registerSettings.VolumePerPulseUnit = 0x00;
|
|
||||||
// registerSettings.MeterUnits = (byte)MessurementUnits.USGallons;
|
|
||||||
// registerSettings.FlowUnits = (byte)MessurementUnits.USGallons;
|
|
||||||
// registerSettings.FlowRate = (byte)TimeUnits.Minutes;
|
|
||||||
// registerSettings.FactoryCorrection = meter.FactoryCorrection;
|
|
||||||
// registerSettings.FieldCorrection = 0x00;
|
|
||||||
// registerSettings.PulseWeight = 0x01;
|
|
||||||
// registerSettings.PulseWidth = 0x02;
|
|
||||||
// registerSettings.PulseUpdate = 0x00;
|
|
||||||
|
|
||||||
// var response = connection.Set(registerSettings);
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// meter.AddRegisterSettings(registerSettings);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var configurationParametersSet = new ConfigurationParametersSet();
|
|
||||||
// configurationParametersSet.ProgrammableID = "816232411983";
|
|
||||||
// configurationParametersSet.FactoryID = "816232411983";
|
|
||||||
// configurationParametersSet.NumberOfReadingDigits = 8; // meter.ReadingDigits;
|
|
||||||
// configurationParametersSet.ReadingPreset = "000000000";
|
|
||||||
// configurationParametersSet.OptionalUniDirFields = 1; // meter.OptionalUniDirFields;
|
|
||||||
// configurationParametersSet.AlarmPercistancePeriodDays = 31;
|
|
||||||
// configurationParametersSet.DataLogIntervalMinutes = 60;
|
|
||||||
// configurationParametersSet.ManifacturingTime = Epoch20000101.UTCNow - 30000; // meter.ManifacturingTime;
|
|
||||||
// configurationParametersSet.SystemTime = Epoch20000101.UTCNow;
|
|
||||||
// configurationParametersSet.RebootCount = 0;
|
|
||||||
// configurationParametersSet.BuildInfo = "816232411983"; // meter.BuildInfo;
|
|
||||||
// // configurationParametersSet.DeviceID = "OMNI-01";
|
|
||||||
|
|
||||||
// var response = connection.Set(configurationParametersSet);
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.ClearDisplay();
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.Set(new LeakAlarm
|
|
||||||
// {
|
|
||||||
// FlowRateGal = 0.25F, // 0.25 gpm
|
|
||||||
// TimeLimit = 24 * 60 * 60 // 24 hours => 86400sec
|
|
||||||
// });
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.Set(new HighFlowAlarm
|
|
||||||
// {
|
|
||||||
// FlowRateGal = 25F, // 25 gpm
|
|
||||||
// TimeLimit = 1 * 60 * 60 // 1 hours => 86400sec
|
|
||||||
// });
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.Set(new ReverseFlowAlarm
|
|
||||||
// {
|
|
||||||
// FlowRateGal = -1F, // -1 gpm
|
|
||||||
// TimeLimit = 60 // 1 hours => 86400sec
|
|
||||||
// });
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.ClearAlarms();
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var alarmsState = connection.ViewAlarmsState();
|
|
||||||
// canContinue = alarmsState.Succeeded;
|
|
||||||
// //&& alarmsState.UsrEnabled
|
|
||||||
// //&& alarmsState.PreEnabledInactive;
|
|
||||||
// //TODO: Check alarms
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.EnableNFC();
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var registerSettingsAfter = connection.ViewRegisterSettings();
|
|
||||||
// canContinue = registerSettingsAfter.Succeeded
|
|
||||||
// && meter.Compare(registerSettingsAfter);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var systemParametersAfter = connection.ViewSystemParameters();
|
|
||||||
// canContinue = systemParametersAfter.Succeeded;
|
|
||||||
// //&& meter.Compare(systemParametersAfter);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var configurationParametersAfter = connection.ViewConfigurationParameters();
|
|
||||||
// canContinue = configurationParametersAfter.Succeeded;
|
|
||||||
// //&& meter.Compare(configurationParametersAfter);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var alarmsState = connection.ViewAlarmsState();
|
|
||||||
// canContinue = alarmsState.Succeeded;
|
|
||||||
// //&& alarmsState.UsrEnabled
|
|
||||||
// //&& alarmsState.PreEnabledInactive;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.ViewAlarmSettings(0x01);
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.ViewAlarmSettings(0x02);
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// var response = connection.ViewAlarmSettings(0x04);
|
|
||||||
// canContinue = response.Succeeded;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (canContinue)
|
|
||||||
// {
|
|
||||||
// //connection.Set(new FactorySeal
|
|
||||||
// //{
|
|
||||||
// // Sealed = true,
|
|
||||||
// //});
|
|
||||||
|
|
||||||
// //var factorySeal = connection.ViewFactorySeal();
|
|
||||||
// //canContinue = factorySeal.Succeeded && factorySeal.Sealed;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//else // meter or connection not in use
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns only connected connections and meters.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position">The position of connection and meter.</param>
|
|
||||||
/// <param name="connection"><see cref="OmniPlusConnection"/></param>
|
|
||||||
/// <param name="meter"><see cref="OmniPlusMeter"/></param>
|
|
||||||
/// <returns>Returns true if connection and meter are found and are not null and the meter is connected, otherwise false.</returns>
|
|
||||||
private bool TryGetOmni(int position, out OmniPlusConnection connection, out OmniPlusMeter meter)
|
|
||||||
{
|
|
||||||
var connectionFound = this.connections.TryGetValue(position, out connection);
|
|
||||||
var meterFound = this.meters.TryGetValue(position, out meter);
|
|
||||||
|
|
||||||
return connectionFound
|
|
||||||
&& connection != null
|
|
||||||
&& meterFound
|
|
||||||
&& meter != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NotifyWhileThreadSleep(int position, string header, int duration)
|
|
||||||
{
|
|
||||||
//var seconds = 0;
|
|
||||||
//var timer = new System.Timers.Timer(1000)
|
|
||||||
//{
|
|
||||||
// Enabled = true,
|
|
||||||
// AutoReset = true,
|
|
||||||
//};
|
|
||||||
//timer.Elapsed += (_, _1) =>
|
|
||||||
//{
|
|
||||||
// this.StateChanged?.Invoke(position, 0, header, $"{seconds++}/{duration}");
|
|
||||||
//};
|
|
||||||
|
|
||||||
//timer.Start();
|
|
||||||
|
|
||||||
//Thread.Sleep(duration * 1000);
|
|
||||||
|
|
||||||
//timer.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CancellationCallback()
|
|
||||||
{
|
|
||||||
// TODO: Update database.
|
|
||||||
this.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class OmniPlusExchangeSlave
|
|
||||||
{
|
|
||||||
private String signalRURL;
|
|
||||||
|
|
||||||
public OmniPlusExchangeSlave(String signalRURL)
|
|
||||||
{
|
|
||||||
this.signalRURL = signalRURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Dispose()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class OmniPlusMeter
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -45,119 +45,37 @@ CREATE TABLE [OmniTestPoints] (
|
|||||||
INSERT INTO [OmniTestPoints]
|
INSERT INTO [OmniTestPoints]
|
||||||
([OmniTypeId], [OmniVariant], [GalPerMin], [Rotations], [Duration], [MinDiff], [MaxDiff])
|
([OmniTypeId], [OmniVariant], [GalPerMin], [Rotations], [Duration], [MinDiff], [MaxDiff])
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
VALUES ( 1, 'C2', 200.00, 900, 36, NULL, NULL)
|
VALUES ( 1, 'C2', 160.00, 700, 35, 98.5, 101.5)
|
||||||
, ( 1, 'C2', 160.00, 700, 35, 98.5, 101.5)
|
|
||||||
, ( 1, 'C2', 150.00, 600, 32, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 2.00, 8, 32, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 1.50, 6, 32, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 1.25, 6, 38, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 1.00, 4, 32, 98.5, 101.5)
|
, ( 1, 'C2', 1.00, 4, 32, 98.5, 101.5)
|
||||||
, ( 1, 'C2', 0.75, 4, 43, NULL, NULL)
|
|
||||||
, ( 1, 'C2', 0.25, 4, 127, 95.0, 101.5)
|
, ( 1, 'C2', 0.25, 4, 127, 95.0, 101.5)
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 1, 'F2', 200.00, 900, 36, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 160.00, 700, 35, 98.5, 101.5)
|
, ( 1, 'F2', 160.00, 700, 35, 98.5, 101.5)
|
||||||
, ( 1, 'F2', 150.00, 600, 32, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 2.00, 8, 32, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 1.50, 6, 32, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 1.25, 6, 38, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 1.00, 4, 32, 98.5, 101.5)
|
, ( 1, 'F2', 1.00, 4, 32, 98.5, 101.5)
|
||||||
, ( 1, 'F2', 0.75, 4, 43, NULL, NULL)
|
|
||||||
, ( 1, 'F2', 0.25, 4, 127, 95.0, 101.5)
|
, ( 1, 'F2', 0.25, 4, 127, 95.0, 101.5)
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 1, 'R2', 200.00, 900, 36, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 160.00, 700, 35, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 150.00, 600, 32, 98.5, 101.5)
|
, ( 1, 'R2', 150.00, 600, 32, 98.5, 101.5)
|
||||||
, ( 1, 'R2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 2.00, 8, 32, 98.5, 101.5)
|
, ( 1, 'R2', 2.00, 8, 32, 98.5, 101.5)
|
||||||
, ( 1, 'R2', 1.50, 6, 32, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 1.25, 6, 38, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 1.00, 4, 32, NULL, NULL)
|
|
||||||
, ( 1, 'R2', 0.75, 4, 43, 95.0, 101.5)
|
, ( 1, 'R2', 0.75, 4, 43, 95.0, 101.5)
|
||||||
, ( 1, 'R2', 0.25, 4, 127, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 1, 'T2', 200.00, 900, 36, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 160.00, 700, 35, 98.5, 101.5)
|
, ( 1, 'T2', 160.00, 700, 35, 98.5, 101.5)
|
||||||
, ( 1, 'T2', 150.00, 600, 32, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 2.00, 8, 32, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 1.50, 6, 32, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 1.25, 6, 38, 98.5, 101.5)
|
, ( 1, 'T2', 1.25, 6, 38, 98.5, 101.5)
|
||||||
, ( 1, 'T2', 1.00, 4, 32, NULL, NULL)
|
|
||||||
, ( 1, 'T2', 0.75, 4, 43, 95.0, 101.5)
|
, ( 1, 'T2', 0.75, 4, 43, 95.0, 101.5)
|
||||||
, ( 1, 'T2', 0.25, 4, 127, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 2, 'C2', 200.00, 1000, 40, NULL, NULL)
|
|
||||||
, ( 2, 'C2', 160.00, 800, 40, 98.5, 101.5)
|
, ( 2, 'C2', 160.00, 800, 40, 98.5, 101.5)
|
||||||
, ( 2, 'C2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 2, 'C2', 1.50, 8, 43, NULL, NULL)
|
|
||||||
, ( 2, 'C2', 1.00, 4, 32, 98.5, 101.5)
|
, ( 2, 'C2', 1.00, 4, 32, 98.5, 101.5)
|
||||||
, ( 2, 'C2', 0.25, 4, 127, 95.0, 101.5)
|
, ( 2, 'C2', 0.25, 4, 127, 95.0, 101.5)
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 2, 'F2', 200.00, 1000, 40, NULL, NULL)
|
|
||||||
, ( 2, 'F2', 160.00, 800, 40, 98.5, 101.5)
|
, ( 2, 'F2', 160.00, 800, 40, 98.5, 101.5)
|
||||||
, ( 2, 'F2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 2, 'F2', 1.50, 8, 43, NULL, NULL)
|
|
||||||
, ( 2, 'F2', 1.00, 4, 32, 98.5, 101.5)
|
, ( 2, 'F2', 1.00, 4, 32, 98.5, 101.5)
|
||||||
, ( 2, 'F2', 0.25, 4, 127, 95.0, 101.5)
|
, ( 2, 'F2', 0.25, 4, 127, 95.0, 101.5)
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 2, 'R2', 200.00, 1000, 40, 98.5, 101.5)
|
, ( 2, 'R2', 200.00, 1000, 40, 98.5, 101.5)
|
||||||
, ( 2, 'R2', 160.00, 800, 40, NULL, NULL)
|
|
||||||
, ( 2, 'R2', 2.50, 10, 32, 98.5, 101.5)
|
, ( 2, 'R2', 2.50, 10, 32, 98.5, 101.5)
|
||||||
, ( 2, 'R2', 1.50, 8, 43, NULL, NULL)
|
|
||||||
, ( 2, 'R2', 1.00, 4, 32, 95.0, 101.5)
|
, ( 2, 'R2', 1.00, 4, 32, 95.0, 101.5)
|
||||||
, ( 2, 'R2', 0.25, 4, 127, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
, ( 2, 'T2', 200.00, 1000, 40, 98.5, 101.5)
|
, ( 2, 'T2', 200.00, 1000, 40, 98.5, 101.5)
|
||||||
, ( 2, 'T2', 160.00, 800, 40, NULL, NULL)
|
|
||||||
, ( 2, 'T2', 2.50, 10, 32, NULL, NULL)
|
|
||||||
, ( 2, 'T2', 1.50, 8, 43, 98.5, 101.5)
|
, ( 2, 'T2', 1.50, 8, 43, 98.5, 101.5)
|
||||||
, ( 2, 'T2', 1.00, 4, 32, 95.0, 101.5)
|
, ( 2, 'T2', 1.00, 4, 32, 95.0, 101.5);
|
||||||
, ( 2, 'T2', 0.25, 4, 127, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
|
||||||
, ( 3, NULL, 500.00, 700, 38, NULL, NULL)
|
|
||||||
, ( 3, NULL, 400.00, 580, 40, NULL, NULL)
|
|
||||||
, ( 3, NULL, 350.00, 450, 35, NULL, NULL)
|
|
||||||
, ( 3, NULL, 20.00, 30, 41, NULL, NULL)
|
|
||||||
, ( 3, NULL, 10.00, 16, 44, NULL, NULL)
|
|
||||||
, ( 3, NULL, 2.50, 4, 44, NULL, NULL)
|
|
||||||
, ( 3, NULL, 2.00, 4, 55, NULL, NULL)
|
|
||||||
, ( 3, NULL, 1.50, 4, 73, NULL, NULL)
|
|
||||||
, ( 3, NULL, 0.50, 4, 217, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
|
||||||
, ( 4, NULL, 1000.00, 1200, 33, NULL, NULL)
|
|
||||||
, ( 4, NULL, 800.00, 1100, 38, NULL, NULL)
|
|
||||||
, ( 4, NULL, 30.00, 40, 37, NULL, NULL)
|
|
||||||
, ( 4, NULL, 3.00, 4, 37, NULL, NULL)
|
|
||||||
, ( 4, NULL, 2.00, 4, 55, NULL, NULL)
|
|
||||||
, ( 4, NULL, 1.50, 4, 73, NULL, NULL)
|
|
||||||
, ( 4, NULL, 0.75, 4, 145, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
|
||||||
, ( 5, NULL, 2000.00, 800, 39, NULL, NULL)
|
|
||||||
, ( 5, NULL, 1600.00, 660, 40, NULL, NULL)
|
|
||||||
, ( 5, NULL, 50.00, 20, 39, NULL, NULL)
|
|
||||||
, ( 5, NULL, 5.00, 4, 77, NULL, NULL)
|
|
||||||
, ( 5, NULL, 4.00, 4, 96, NULL, NULL)
|
|
||||||
, ( 5, NULL, 3.00, 4, 127, NULL, NULL)
|
|
||||||
, ( 5, NULL, 2.50, 4, 153, NULL, NULL)
|
|
||||||
, ( 5, NULL, 1.50, 4, 254, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
|
||||||
, ( 6, NULL, 3500.00, 500, 34, NULL, NULL)
|
|
||||||
, ( 6, NULL, 2700.00, 400, 36, NULL, NULL)
|
|
||||||
, ( 6, NULL, 7.00, 4, 136, NULL, NULL)
|
|
||||||
, ( 6, NULL, 5.00, 4, 191, NULL, NULL)
|
|
||||||
, ( 6, NULL, 4.00, 4, 238, NULL, NULL)
|
|
||||||
, ( 6, NULL, 3.00, 4, 317, NULL, NULL)
|
|
||||||
, ( 6, NULL, 2.50, 4, 381, NULL, NULL)
|
|
||||||
------------------------------------------------------------------------------------------
|
|
||||||
, ( 7, NULL, 5500.00, 550, 36, NULL, NULL)
|
|
||||||
, ( 7, NULL, 4000.00, 400, 36, NULL, NULL)
|
|
||||||
, ( 7, NULL, 2500.00, 260, 37, NULL, NULL)
|
|
||||||
, ( 7, NULL, 14.00, 4, 102, NULL, NULL)
|
|
||||||
, ( 7, NULL, 5.00, 4, 284, NULL, NULL)
|
|
||||||
, ( 7, NULL, 3.50, 4, 406, NULL, NULL);
|
|
||||||
|
|
||||||
CREATE TABLE [OmniTestStates] (
|
CREATE TABLE [OmniTestStates] (
|
||||||
[Position] INT NOT NULL,
|
[Position] INT NOT NULL,
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
namespace OmniPlus
|
||||||
|
{
|
||||||
|
using OmniPlus.Connections;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Ports;
|
||||||
|
|
||||||
|
public class OmniUniProConnection : OmniConnection
|
||||||
|
{
|
||||||
|
private readonly OmniUniProStream stream;
|
||||||
|
private readonly string stateFile;
|
||||||
|
|
||||||
|
public OmniUniProConnection(string portName)
|
||||||
|
{
|
||||||
|
this.stateFile = this.GetOrCreateStateFile(portName);
|
||||||
|
this.stream = new OmniUniProStream(
|
||||||
|
encoder: new OmniUniProEncoder(),
|
||||||
|
settings: new SerialPortSettings
|
||||||
|
{
|
||||||
|
BaudRate = 2400,
|
||||||
|
DataBits = 8,
|
||||||
|
Parity = Parity.None,
|
||||||
|
PortName = portName,
|
||||||
|
StopBits = StopBits.One
|
||||||
|
});
|
||||||
|
this.stream.StateChanged += this.OnStateChanged;
|
||||||
|
this.MessageHandler = this.stream.Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
this.stream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Open()
|
||||||
|
{
|
||||||
|
this.stream.Open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStateChanged(object state)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.AppendAllText(this.stateFile, $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] {state}{Environment.NewLine}");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
// TODO: throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOrCreateStateFile(string portName)
|
||||||
|
{
|
||||||
|
var stateFile = $"{portName}_{DateTime.Now:yyyy_MM_dd}.txt";
|
||||||
|
var directory = Directory.CreateDirectory(".\\OmniUniPro");
|
||||||
|
stateFile = Path.Combine(directory.FullName, stateFile);
|
||||||
|
|
||||||
|
File.AppendAllText(stateFile, string.Empty);
|
||||||
|
|
||||||
|
return stateFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,9 +19,8 @@
|
|||||||
protected string GroupName
|
protected string GroupName
|
||||||
{
|
{
|
||||||
get => this.Context
|
get => this.Context
|
||||||
?.QueryString
|
.QueryString
|
||||||
?.Get(ExchangeConnection.GROUP_KEY)
|
.Get(ExchangeConnection.GROUP_KEY);
|
||||||
?? ExchangeConnection.GROUP_KEY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disposed(string groupName)
|
public void Disposed(string groupName)
|
||||||
|
|||||||
Reference in New Issue
Block a user