work
This commit is contained in:
70
DataClient/ByteConverter.cs
Normal file
70
DataClient/ByteConverter.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using DataClient.Struct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DataClient
|
||||
{
|
||||
public static class ByteConverter
|
||||
{
|
||||
public static TechCycle[] BytesToTechcycles(byte[] arr)
|
||||
{
|
||||
var res = new List<TechCycle>();
|
||||
try
|
||||
{
|
||||
var str = new List<byte>();
|
||||
for (var i = 0; i < arr.Length; i++)
|
||||
if (arr[i] == 0x0a)
|
||||
{
|
||||
res.Add(BytesToTechcycle(str.ToArray()));
|
||||
str.Clear();
|
||||
}
|
||||
else
|
||||
str.Add(arr[i]);
|
||||
} catch { throw; }
|
||||
return res.ToArray();
|
||||
}
|
||||
public static TechCycle BytesToTechcycle(byte[] arr)
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
var enc = Encoding.GetEncoding(866);
|
||||
var exc = new ArgumentException("Wrong structure in byte array.");
|
||||
var flag = 0;
|
||||
var str = new List<byte>();
|
||||
var res = new TechCycle();
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < arr.Length; i++)
|
||||
if (arr[i] == 0x09)
|
||||
switch (flag)
|
||||
{
|
||||
case 0:
|
||||
var idxStr = enc.GetString(str.ToArray());
|
||||
if (idxStr == "00") res.Operation = TechCycle.Oper.end_cycle_manual;
|
||||
else if (int.TryParse(idxStr, out int idx)) res.index = (sbyte?)idx;
|
||||
str.Clear();
|
||||
flag++;
|
||||
break;
|
||||
case 1:
|
||||
var timestr = enc.GetString(str.ToArray());
|
||||
var rgx = new Regex(@"^([0-1]\d{1}|[2][0-3]):([0-5]\d{1}):([0-5]\d{1})$");
|
||||
if (!rgx.IsMatch(timestr)) throw exc;
|
||||
str.Clear();
|
||||
flag++;
|
||||
break;
|
||||
default: throw exc;
|
||||
}
|
||||
else str.Add(arr[i]);
|
||||
if (flag != 2) throw exc;
|
||||
var unixTimeStr = enc.GetString(str.ToArray());
|
||||
if (!int.TryParse(unixTimeStr, out int unixTime)) throw exc;
|
||||
res.start = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(unixTime).ToLocalTime();
|
||||
return res;
|
||||
}
|
||||
catch { throw; }
|
||||
}
|
||||
}
|
||||
}
|
13
DataClient/Config/analog/default.json
Normal file
13
DataClient/Config/analog/default.json
Normal file
@@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Test",
|
||||
"short_name": "Test",
|
||||
"measure": "kg",
|
||||
"precision": 1,
|
||||
"min": -100,
|
||||
"max": 100,
|
||||
"default": 0,
|
||||
"logarithm": false
|
||||
}
|
||||
]
|
3
DataClient/Config/discret/default.json
Normal file
3
DataClient/Config/discret/default.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
@@ -368,15 +368,24 @@ namespace DataClient
|
||||
catch { My_Close(needCloseConeection); throw; }
|
||||
var str = date.ToString("yyyyMMdd") + "." + vdp.ToString("D2") + (idx % 16).ToString("X1");
|
||||
|
||||
try { if(SendBytes(CreateCode((uint)code, str))) throw new IOException("Can't send bytes to server."); }
|
||||
try { if(!SendBytes(CreateCode((uint)code, str))) throw new IOException("Can't send bytes to server."); }
|
||||
catch { My_Close(needCloseConeection); throw; }
|
||||
var res = new List<byte>();
|
||||
var endCycle = false;
|
||||
try
|
||||
{
|
||||
double cycleAwait = 0;
|
||||
int cycleCount = 0;
|
||||
var updateCycle = false;
|
||||
do
|
||||
{
|
||||
var tmp = ReceiveBytes(1);
|
||||
if (updateCycle)
|
||||
{
|
||||
RetryInterval = cycleAwait;
|
||||
RetryCount = cycleCount;
|
||||
updateCycle = false;
|
||||
}
|
||||
switch (tmp[0])
|
||||
{
|
||||
case 0x00:
|
||||
@@ -390,6 +399,14 @@ namespace DataClient
|
||||
case 0x02:
|
||||
stat.fullSize = BitConverter.ToUInt32(ReceiveBytes(4));
|
||||
break;
|
||||
case 0x03:
|
||||
//Need Brake for 5 seconds. (Await alrady create in ReceiveBytes function...)//
|
||||
updateCycle = true;
|
||||
cycleAwait = RetryInterval;
|
||||
RetryInterval = 1;
|
||||
cycleCount = RetryCount;
|
||||
RetryCount = 5;
|
||||
break;
|
||||
default:
|
||||
ReceiveBytes();
|
||||
throw new ArgumentException("Wront flag when get files.");
|
||||
@@ -570,8 +587,5 @@ namespace DataClient
|
||||
finally { My_Close(needCloseConeection); }
|
||||
return pasp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataClient
|
||||
namespace DataClient.Struct
|
||||
{
|
||||
class FileConverter
|
||||
{
|
||||
}
|
||||
class Analog
|
||||
{
|
||||
}
|
||||
}
|
@@ -40,31 +40,6 @@ namespace DataClient.Struct
|
||||
public Status stat = Status.wait;
|
||||
}
|
||||
|
||||
public class TechCycle
|
||||
{
|
||||
public enum Operation : short
|
||||
{
|
||||
end_cycle_manual_ = -1,
|
||||
end_cycle = 0,
|
||||
unload_load = 1,
|
||||
vac_priv = 2,
|
||||
priv = 5,
|
||||
cool_priv = 6,
|
||||
look_priv = 7,
|
||||
vac_plav = 8,
|
||||
melt_bath = 9,
|
||||
plav = 10,
|
||||
VUR = 11,
|
||||
cool_plav = 12,
|
||||
unload_kit = 13,
|
||||
vac_oplav = 14,
|
||||
oplav = 15,
|
||||
cool_oplav = 16,
|
||||
flow_metal = 17,
|
||||
check_protect = 25
|
||||
}
|
||||
public DateTime start;
|
||||
public Operation index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
41
DataClient/Struct/TechCycle.cs
Normal file
41
DataClient/Struct/TechCycle.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataClient.Struct
|
||||
{
|
||||
public class TechCycle
|
||||
{
|
||||
|
||||
public enum Oper : sbyte
|
||||
{
|
||||
errno = sbyte.MinValue,
|
||||
end_cycle_manual = -1,
|
||||
end_cycle = 0,
|
||||
unload_load = 1,
|
||||
vac_priv = 2,
|
||||
priv = 5,
|
||||
cool_priv = 6,
|
||||
look_priv = 7,
|
||||
vac_plav = 8,
|
||||
melt_bath = 9,
|
||||
plav = 10,
|
||||
VUR = 11,
|
||||
cool_plav = 12,
|
||||
unload_kit = 13,
|
||||
vac_oplav = 14,
|
||||
oplav = 15,
|
||||
cool_oplav = 16,
|
||||
flow_metal = 17,
|
||||
check_protect = 25
|
||||
}
|
||||
public DateTime start;
|
||||
public sbyte? index;
|
||||
public Oper Operation {
|
||||
get { return (index.HasValue && Enum.IsDefined(typeof(Oper), index.Value)) ? (Oper)index : Oper.errno; }
|
||||
set { index = (sbyte)value; }
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,24 +1,25 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj": {}
|
||||
"D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj": {
|
||||
"D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj": {
|
||||
"version": "0.0.3",
|
||||
"restore": {
|
||||
"projectUniqueName": "F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"projectUniqueName": "D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"projectName": "DataClient",
|
||||
"projectPath": "F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\",
|
||||
"outputPath": "F:\\GIT\\ASCKU_PC\\DataClient\\obj\\",
|
||||
"projectPath": "D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"packagesPath": "C:\\Users\\google\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\GIT\\ASCKU_PC\\DataClient\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\"
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Users\\google\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
|
||||
@@ -74,7 +75,7 @@
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.300\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,14 +5,15 @@
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Admin\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\</NuGetPackageFolders>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\google\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.10.0</NuGetToolVersion>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.9.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\Admin\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Users\google\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft\Xamarin\NuGet\" />
|
||||
<SourceRoot Include="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
|
Binary file not shown.
@@ -1 +1 @@
|
||||
898e6554eebd2f3d6753598716680015b14c74de
|
||||
e010c6259d9b17fd3c989d08c8f3519898d03bc0
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -361,25 +361,27 @@
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\": {},
|
||||
"C:\\Users\\google\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {}
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {},
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "0.0.3",
|
||||
"restore": {
|
||||
"projectUniqueName": "F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"projectUniqueName": "D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"projectName": "DataClient",
|
||||
"projectPath": "F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\",
|
||||
"outputPath": "F:\\GIT\\ASCKU_PC\\DataClient\\obj\\",
|
||||
"projectPath": "D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"packagesPath": "C:\\Users\\google\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\GIT\\ASCKU_PC\\DataClient\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\"
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Users\\google\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
|
||||
@@ -435,7 +437,7 @@
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.300\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "lCVOnkDSpCDkY6mFU39PPTK/8UioIwkzLSm5l9U0BI9kmvrQU3GBEeKlZLkvo3I3Vmgv8BfwOMFxbII4ikrnzA==",
|
||||
"dgSpecHash": "fLzCMyL0TTYR6ScHYw8lseE4tuHRjlfRhsrbzgdqw/qeVRrQYigyT797G0cUiPOmrt1GVD0KWz3n3AZIE22bzQ==",
|
||||
"success": true,
|
||||
"projectFilePath": "F:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"projectFilePath": "D:\\GIT\\ASCKU_PC\\DataClient\\DataClient.csproj",
|
||||
"expectedPackageFiles": [
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.configuration.abstractions\\5.0.0\\microsoft.extensions.configuration.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.dependencyinjection\\5.0.0\\microsoft.extensions.dependencyinjection.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\5.0.0\\microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.logging\\5.0.0\\microsoft.extensions.logging.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\5.0.0\\microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.options\\5.0.0\\microsoft.extensions.options.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.primitives\\5.0.0\\microsoft.extensions.primitives.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\newtonsoft.json\\13.0.1\\newtonsoft.json.13.0.1.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\nlog\\4.7.10\\nlog.4.7.10.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\nlog.extensions.logging\\1.7.2\\nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.configuration.abstractions\\5.0.0\\microsoft.extensions.configuration.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.dependencyinjection\\5.0.0\\microsoft.extensions.dependencyinjection.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\5.0.0\\microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.logging\\5.0.0\\microsoft.extensions.logging.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\5.0.0\\microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.options\\5.0.0\\microsoft.extensions.options.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.primitives\\5.0.0\\microsoft.extensions.primitives.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\newtonsoft.json\\13.0.1\\newtonsoft.json.13.0.1.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\nlog\\4.7.10\\nlog.4.7.10.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\nlog.extensions.logging\\1.7.2\\nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
],
|
||||
"logs": []
|
||||
}
|
Reference in New Issue
Block a user