Browse Source

24.05.2023

master
Денис Кузнецов 3 years ago
parent
commit
8d696a9628
  1. BIN
      CurrentInstructionPointer.png
  2. BIN
      CursorFile.png
  3. BIN
      CursorFile32.png
  4. BIN
      StartLogging.png
  5. BIN
      StartLogging32.png
  6. BIN
      StopLogging.png
  7. BIN
      StopLogging32.png
  8. 371
      piv.cs
  9. 247
      util.cs

BIN
CurrentInstructionPointer.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

BIN
CursorFile.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

BIN
CursorFile32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
StartLogging.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

BIN
StartLogging32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
StopLogging.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

BIN
StopLogging32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

371
piv.cs

@ -1,8 +1,4 @@ @@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
/// <summary>
/// Ноавя версия ПИВ 1.22
@ -14,7 +10,7 @@ namespace PIV @@ -14,7 +10,7 @@ namespace PIV
{
public static Byte START = 0x3A;
public const Byte STARTTOBON = 0x3C;
public const Byte STARTTOBON0322 = 0x3D;
public const Byte STARTTOBON0322 = 0x3F;
public const Byte STARTTOBON0323 = 0x3E;
public enum ADDR : UInt16
{
@ -334,6 +330,11 @@ namespace PIV @@ -334,6 +330,11 @@ namespace PIV
Kod_Oshibki = BitConverter.ToUInt16(Data, 81);
CRC16 = BitConverter.ToUInt16(Data, 83);
*/ }
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Новый класс пакет 0322 в БОН
@ -344,9 +345,9 @@ namespace PIV @@ -344,9 +345,9 @@ namespace PIV
private static UInt16 _len_data = _len_pack - 8;
private static UInt16 _len_crc = _len_pack - 2;
private static Byte _num_pack = 2;
private static Byte _dir_pack = 2;
private static Byte _addr_pack = 3;
private static UInt16 _num_pack = 2;
private static UInt16 _dir_pack = 2;
private static UInt16 _addr_pack = 3;
private static UInt16 _id_pack = 0x0322;
private static UInt32 _schetchik;
@ -427,9 +428,9 @@ namespace PIV @@ -427,9 +428,9 @@ namespace PIV
_addr_pack = (Byte)((value & 0xFF00) >> 8);
}
}
public static Byte num_pack { get => _num_pack; set => _num_pack = value; }
public static Byte dir_pack1 { get => _dir_pack; set => _dir_pack = value; }
public static Byte addr_pack { get => _addr_pack; set => _addr_pack = value; }
public static UInt16 num_pack { get => _num_pack; set => _num_pack = value; }
public static UInt16 dir_pack1 { get => _dir_pack; set => _dir_pack = value; }
public static UInt16 addr_pack { get => _addr_pack; set => _addr_pack = value; }
/// <summary>
/// Счетчик
/// </summary>
@ -624,6 +625,11 @@ namespace PIV @@ -624,6 +625,11 @@ namespace PIV
public static void GetData()
{
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Новый класс пакет 0323 в БОН
@ -807,6 +813,11 @@ namespace PIV @@ -807,6 +813,11 @@ namespace PIV
Vremya_ustar = BitConverter.ToInt32(Data, 44);
CRC16 = BitConverter.ToUInt16(Data, 48);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
public static class OES2BVM
{
@ -854,10 +865,10 @@ namespace PIV @@ -854,10 +865,10 @@ namespace PIV
{
get
{
_rejim = (UInt16)(_r_ioes);
_rejim = (UInt16)(_r_ioes << 0);
_rejim |= (UInt16)(_r_zahvat << 1);
_rejim |= (UInt16)(_r_rejimoes << 3);
_rejim |= (UInt16)(_r_sostoes << 5);
_rejim |= (UInt16)(_r_rejimoes << 2);
_rejim |= (UInt16)(_r_sostoes << 4);
_rejim |= (UInt16)(_r_vsktk << 6);
_rejim |= (UInt16)(_r_rks << 7);
_rejim |= (UInt16)(_r_eizo_recv << 8);
@ -867,7 +878,7 @@ namespace PIV @@ -867,7 +878,7 @@ namespace PIV
set
{
_rejim = value;
_r_ioes = (UInt16)(value & 0x0001);
_r_ioes = (UInt16)((value & 0x0001) >> 0);
_r_zahvat = (UInt16)((value & 0x0002) >> 1);
_r_rejimoes = (UInt16)((value & 0x000C) >> 2);
_r_sostoes = (UInt16)((value & 0x0030) >> 4);
@ -927,6 +938,10 @@ namespace PIV @@ -927,6 +938,10 @@ namespace PIV
public static float usAZ;
public static float usUM;
public static UInt16 CRC16;
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, 30);
}
public static Byte[] Data = new Byte[32];
public static void MakeData()
@ -961,9 +976,18 @@ namespace PIV @@ -961,9 +976,18 @@ namespace PIV
usUM = BitConverter.ToSingle(Data, 26);
CRC16 = BitConverter.ToUInt16(Data, 30);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
public static class BVM2OES
{
private const UInt16 _len_pack = 42;
private static UInt16 _len_data = _len_pack - 8;
private static UInt16 _len_crc = _len_pack - 2;
private static Byte _num_pack = 1;
private static Byte _dir_pack = 1;
private static Byte _addr_pack = 2;
@ -1081,8 +1105,12 @@ namespace PIV @@ -1081,8 +1105,12 @@ namespace PIV
public static Int16 Xrks;
public static Int16 Yrks;
public static UInt16 CRC16;
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, _len_crc);
}
public static Byte[] Data = new Byte[42];
public static Byte[] Data = new Byte[_len_pack];
public static void MakeData()
{
Array.Copy(BitConverter.GetBytes(Start), 0, Data, 0, 1);
@ -1126,6 +1154,11 @@ namespace PIV @@ -1126,6 +1154,11 @@ namespace PIV
Yrks = BitConverter.ToInt16(Data, 38);
CRC16 = BitConverter.ToUInt16(Data, 40);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
public static class BON2BVM
{
@ -1413,6 +1446,11 @@ namespace PIV @@ -1413,6 +1446,11 @@ namespace PIV
Kod_Oshibki = BitConverter.ToUInt16(Data, 81);
CRC16 = BitConverter.ToUInt16(Data, 83);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Новый класс пакет обмена данных ИНС от БОН
@ -1653,6 +1691,11 @@ namespace PIV @@ -1653,6 +1691,11 @@ namespace PIV
public static UInt16 CRC16;
public static Byte[] Data = new Byte[_len_pack];
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, _len_crc);
}
/// <summary>
/// Функция формирования массива с пакетом
/// </summary>
@ -1733,6 +1776,11 @@ namespace PIV @@ -1733,6 +1776,11 @@ namespace PIV
Vremya_ustar = BitConverter.ToInt32(Data, 68);
CRC16 = BitConverter.ToUInt16(Data, 72);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Новый класс пакет обмена данных СНС от БОН
@ -1866,6 +1914,11 @@ namespace PIV @@ -1866,6 +1914,11 @@ namespace PIV
public static UInt16 CRC16;
public static Byte[] Data = new Byte[_len_pack];
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, _len_crc);
}
/// <summary>
/// Функция формирования массива с пакетом
/// </summary>
@ -1929,6 +1982,11 @@ namespace PIV @@ -1929,6 +1982,11 @@ namespace PIV
public static UInt16 CRC16;
public static Byte[] Data = new Byte[8];
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, 6);
}
/// <summary>
/// Функция формирования массива с пакетом
/// </summary>
@ -1962,9 +2020,9 @@ namespace PIV @@ -1962,9 +2020,9 @@ namespace PIV
private static UInt16 _len_data = _len_pack - 8;
private static UInt16 _len_crc = _len_pack - 2;
private static Byte _num_pack = 1;
private static Byte _dir_pack = 2;
private static Byte _addr_pack = 3;
private static UInt16 _num_pack = 1;
private static UInt16 _dir_pack = 2;
private static UInt16 _addr_pack = 3;
private static UInt16 _id_pack = 0;
public static Byte Start = CONST.START;
@ -1978,25 +2036,30 @@ namespace PIV @@ -1978,25 +2036,30 @@ namespace PIV
{
get
{
_id_pack = (ushort)(_addr_pack << 8);
_id_pack |= (ushort)(_dir_pack << 4);
_id_pack |= (ushort)_num_pack;
_id_pack = (UInt16)(_addr_pack << 8);
_id_pack |= (UInt16)(_dir_pack << 4);
_id_pack |= (UInt16)_num_pack;
return _id_pack;
}
set
{
_id_pack = value;
_num_pack = (Byte)(value & 0x000F);
_dir_pack = (Byte)((value & 0x00F0) >> 4);
_addr_pack = (Byte)((value & 0xFF00) >> 8);
_num_pack = (UInt16)(value & 0x000F);
_dir_pack = (UInt16)((value & 0x00F0) >> 4);
_addr_pack = (UInt16)((value & 0xFF00) >> 8);
}
}
public static Byte num_pack { get => _num_pack; set => _num_pack = value; }
public static Byte dir_pack1 { get => _dir_pack; set => _dir_pack = value; }
public static Byte addr_pack { get => _addr_pack; set => _addr_pack = value; }
public static UInt16 num_pack { get => _num_pack; set => _num_pack = value; }
public static UInt16 dir_pack1 { get => _dir_pack; set => _dir_pack = value; }
public static UInt16 addr_pack { get => _addr_pack; set => _addr_pack = value; }
public static UInt16 CRC16;
public static Byte[] Data = new Byte[_len_pack];
public static UInt16 CalcCRC()
{
return CONST.CRC16(ref Data, _len_crc);
}
/// <summary>
/// Функция формирования массива с пакетом
/// </summary>
@ -2006,6 +2069,7 @@ namespace PIV @@ -2006,6 +2069,7 @@ namespace PIV
Array.Copy(BitConverter.GetBytes(Address), 0, Data, 1, 2);
Array.Copy(BitConverter.GetBytes(Code), 0, Data, 3, 1);
Array.Copy(BitConverter.GetBytes(Lenght), 0, Data, 4, 2);
Array.Copy(BitConverter.GetBytes(Id_Pack), 0, Data, 6, 2);
UInt16 _crc16 = CONST.CRC16(ref Data, _len_crc);
Array.Copy(BitConverter.GetBytes(_crc16), 0, Data, _len_crc, 2);
}
@ -2021,6 +2085,11 @@ namespace PIV @@ -2021,6 +2085,11 @@ namespace PIV
Id_Pack = BitConverter.ToUInt16(Data, 6);
CRC16 = BitConverter.ToUInt16(Data, _len_crc);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Служебный класс для пересчета угловых координат
@ -2331,17 +2400,249 @@ namespace PIV @@ -2331,17 +2400,249 @@ namespace PIV
/// <summary>
/// Функция извлечения данных из массива
/// </summary>
static Byte[] Data = new Byte[8];
public static void GetData(Byte[] arr)
{
Byte[] data = new Byte[8];
Array.Copy(arr, data, 8);
Start = data[0];
Address = (UInt16)(data[2] << 8 | data[1]);
Code = data[3];
Lenght = BitConverter.ToUInt16(data, 4);
Id_Pack = BitConverter.ToUInt16(data, 6);
Array.Copy(arr, Data, 8);
Start = Data[0];
Address = (UInt16)(Data[2] << 8 | Data[1]);
Code = Data[3];
Lenght = BitConverter.ToUInt16(Data, 4);
Id_Pack = BitConverter.ToUInt16(Data, 6);
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
/// <summary>
/// Новый класс пакет 0322 в БОН
/// </summary>
public static class sTOBON0322
{
private const UInt16 _len_pack = 49;
private static UInt16 _infoword = 0;
private static UInt16 _i_vstr_kontr = 0;
private static UInt16 _i_neispr_bon = 0;
private static UInt16 _i_vystavka = 0;
private static UInt16 _i_gotovnost = 0;
private static UInt16 _i_ots_massiv_NV = 0;
private static UInt16 _i_rejim_nav = 0;
private static UInt16 _i_korr_nosit = 0;
private static UInt16 _i_korr_sns = 0;
private static UInt16 _dostovernost = 0;
private static UInt16 _d_kren_tangaj = 0;
private static UInt16 _d_kurs = 0;
private static UInt16 _d_ugl_sk = 0;
private static UInt16 _d_lin_usk = 0;
private static UInt16 _d_in_coord = 0;
private static UInt16 _d_baro = 0;
private static UInt16 _d_inerc_sk = 0;
private static UInt16 _d_vrem_rabot = 0;
private static Int16 _kren;
private static Int16 _tangaj;
private static Int16 _kurs;
private static Int16 _vost_sk;
private static Int16 _sev_sk;
private static Int16 _vert_sk;
private static UInt16 _modul_sk;
private static Int32 _shirota;
private static Int32 _dolgota;
private static Int32 _vysota;
private static Int32 _vysota_baro;
private static Int16 _usx;
private static Int16 _usy;
private static Int16 _usz;
private static Int16 _uskx;
private static Int16 _usky;
private static Int16 _uskz;
private static UInt16 _kod_oshibki;
private static UInt16 _ko_nedop_dvij;
private static UInt16 _ko_sboy;
private static UInt16 _ko_ots_dannyh_sns;
private static UInt16 _ko_ots_dannyh_bch;
private static UInt16 _ko_prev_dop_gyro;
private static UInt16 _ko_prev_dop_axel;
public static Byte Start = CONST.STARTTOBON0322;
/// <summary>
/// Слово информационное
/// </summary>
public static UInt16 InfoWord
{
get
{
_infoword = (UInt16)(_i_vstr_kontr << 0);
_infoword |= (UInt16)(_i_neispr_bon << 1);
_infoword |= (UInt16)(_i_vystavka << 2);
_infoword |= (UInt16)(_i_gotovnost << 3);
_infoword |= (UInt16)(_i_ots_massiv_NV << 4);
_infoword |= (UInt16)(_i_rejim_nav << 5);
_infoword |= (UInt16)(_i_korr_nosit << 6);
_infoword |= (UInt16)(_i_korr_sns << 7);
return _infoword;
}
set
{
_infoword = value;
_i_vstr_kontr = (UInt16)(value & 0x01 >> 0);
_i_neispr_bon = (UInt16)((value & 0x02) >> 1);
_i_vystavka = (UInt16)((value & 0x04) >> 2);
_i_gotovnost = (UInt16)((value & 0x08) >> 3);
_i_ots_massiv_NV = (UInt16)((value & 0x10) >> 4);
_i_rejim_nav = (UInt16)((value & 0x20) >> 5);
_i_korr_nosit = (UInt16)((value & 0x40) >> 6);
_i_korr_sns = (UInt16)((value & 0x80) >> 7);
}
}
public static UInt16 I_vstr_kontr { get => _i_vstr_kontr; set => _i_vstr_kontr = value; }
public static UInt16 I_neispr_bon { get => _i_neispr_bon; set => _i_neispr_bon = value; }
public static UInt16 I_vystavka { get => _i_vystavka; set => _i_vystavka = value; }
public static UInt16 I_gotovnost { get => _i_gotovnost; set => _i_gotovnost = value; }
public static UInt16 I_ots_massiv_NV { get => _i_ots_massiv_NV; set => _i_ots_massiv_NV = value; }
public static UInt16 I_rejim_nav { get => _i_rejim_nav; set => _i_rejim_nav = value; }
public static UInt16 I_korr_nosit { get => _i_korr_nosit; set => _i_korr_nosit = value; }
public static UInt16 I_korr_sns { get => _i_korr_sns; set => _i_korr_sns = value; }
/// <summary>
/// Достоверность данных
/// </summary>
public static UInt16 Dostovernost
{
get
{
_dostovernost = (UInt16)(_d_kren_tangaj);
_dostovernost |= (UInt16)(_d_kurs << 1);
_dostovernost |= (UInt16)(_d_ugl_sk << 2);
_dostovernost |= (UInt16)(_d_lin_usk << 3);
_dostovernost |= (UInt16)(_d_in_coord << 4);
_dostovernost |= (UInt16)(_d_baro << 5);
_dostovernost |= (UInt16)(_d_inerc_sk << 6);
_dostovernost |= (UInt16)(_d_vrem_rabot << 7);
return _dostovernost;
}
set
{
_dostovernost = value;
_d_kren_tangaj = (UInt16)((value & 0x0001) >> 0);
_d_kurs = (UInt16)((value & 0x0002) >> 1);
_d_ugl_sk = (UInt16)((value & 0x0004) >> 2);
_d_lin_usk = (UInt16)((value & 0x0008) >> 3);
_d_in_coord = (UInt16)((value & 0x0010) >> 4);
_d_baro = (UInt16)((value & 0x0020) >> 5);
_d_inerc_sk = (UInt16)((value & 0x0040) >> 6);
_d_vrem_rabot = (UInt16)((value & 0x0080) >> 7);
}
}
public static UInt16 D_kren_tangaj { get => _d_kren_tangaj; set => _d_kren_tangaj = value; }
public static UInt16 D_kurs { get => _d_kurs; set => _d_kurs = value; }
public static UInt16 D_ugl_sk { get => _d_ugl_sk; set => _d_ugl_sk = value; }
public static UInt16 D_lin_usk { get => _d_lin_usk; set => _d_lin_usk = value; }
public static UInt16 D_in_coord { get => _d_in_coord; set => _d_in_coord = value; }
public static UInt16 D_baro { get => _d_baro; set => _d_baro = value; }
public static UInt16 D_inerc_sk { get => _d_inerc_sk; set => _d_inerc_sk = value; }
public static UInt16 D_vrem_rabot { get => _d_vrem_rabot; set => _d_vrem_rabot = value; }
public static Int16 Kren { get => _kren; set => _kren = value; }
public static Int16 Tangaj { get => _tangaj; set => _tangaj = value; }
public static Int16 Kurs { get => _kurs; set => _kurs = value; }
public static Int16 Vost_sk { get => _vost_sk; set => _vost_sk = value; }
public static Int16 Sev_sk { get => _sev_sk; set => _sev_sk = value; }
public static Int16 Vert_sk { get => _vert_sk; set => _vert_sk = value; }
public static UInt16 Modul_sk { get => _modul_sk; set => _modul_sk = value; }
public static Int32 Shirota { get => _shirota; set => _shirota = value; }
public static Int32 Dolgota { get => _dolgota; set => _dolgota = value; }
public static Int32 Vysota { get => _vysota; set => _vysota = value; }
public static Int32 Vysota_baro { get => _vysota_baro; set => _vysota_baro = value; }
public static Int16 UsX { get => _usx; set => _usx = value; }
public static Int16 UsY { get => _usy; set => _usy = value; }
public static Int16 UsZ { get => _usz; set => _usz = value; }
public static Int16 UskX { get => _uskx; set => _uskx = value; }
public static Int16 UskY { get => _usky; set => _usky = value; }
public static Int16 UskZ { get => _uskz; set => _uskz = value; }
/// <summary>
/// Код ошибки БИНС
/// </summary>
public static UInt16 Kod_Oshibki
{
get
{
_kod_oshibki = (UInt16)(_ko_nedop_dvij << 2);
_kod_oshibki |= (UInt16)(_ko_sboy << 3);
_kod_oshibki |= (UInt16)(_ko_ots_dannyh_sns << 4);
_kod_oshibki |= (UInt16)(_ko_ots_dannyh_bch << 5);
_kod_oshibki |= (UInt16)(_ko_prev_dop_gyro << 6);
_kod_oshibki |= (UInt16)(_ko_prev_dop_axel << 7);
return _kod_oshibki;
}
set
{
_kod_oshibki = value;
_ko_nedop_dvij = (UInt16)((value & 0x0004) >> 2);
_ko_sboy = (UInt16)((value & 0x0008) >> 3);
_ko_ots_dannyh_sns = (UInt16)((value & 0x0010) >> 4);
_ko_ots_dannyh_bch = (UInt16)((value & 0x0020) >> 5);
_ko_prev_dop_gyro = (UInt16)((value & 0x0040) >> 6);
_ko_prev_dop_axel = (UInt16)((value & 0x0080) >> 7);
}
}
public static UInt16 Ko_nedop_dvij { get => _ko_nedop_dvij; set => _ko_nedop_dvij = value; }
public static UInt16 Ko_sboy { get => _ko_sboy; set => _ko_sboy = value; }
public static UInt16 Ko_ots_dannyh_sns { get => _ko_ots_dannyh_sns; set => _ko_ots_dannyh_sns = value; }
public static UInt16 Ko_ots_dannyh_bch { get => _ko_ots_dannyh_bch; set => _ko_ots_dannyh_bch = value; }
public static UInt16 Ko_prev_dop_gyro { get => _ko_prev_dop_gyro; set => _ko_prev_dop_gyro = value; }
public static UInt16 Ko_prev_dop_axel { get => _ko_prev_dop_axel; set => _ko_prev_dop_axel = value; }
/// <summary>
/// Время устаревания информации от комплекса
/// </summary>
public static Byte[] Data = new Byte[_len_pack];
/// <summary>
/// Функция формирования массива с пакетом
/// </summary>
public static void MakeData()
{
Array.Copy(BitConverter.GetBytes(Start), 0, Data, 0, 1);
Array.Copy(BitConverter.GetBytes(InfoWord), 0, Data, 1, 2);
Array.Copy(BitConverter.GetBytes(Dostovernost), 0, Data, 3, 2);
Array.Copy(BitConverter.GetBytes(Kren), 0, Data, 5, 2);
Array.Copy(BitConverter.GetBytes(Tangaj), 0, Data, 7, 2);
Array.Copy(BitConverter.GetBytes(Kurs), 0, Data, 9, 2);
Array.Copy(BitConverter.GetBytes(Vost_sk), 0, Data, 11, 2);
Array.Copy(BitConverter.GetBytes(Sev_sk), 0, Data, 13, 2);
Array.Copy(BitConverter.GetBytes(Vert_sk), 0, Data, 15, 2);
Array.Copy(BitConverter.GetBytes(Modul_sk), 0, Data, 17, 2);
Array.Copy(BitConverter.GetBytes(Shirota), 0, Data, 19, 4);
Array.Copy(BitConverter.GetBytes(Dolgota), 0, Data, 23, 4);
Array.Copy(BitConverter.GetBytes(Vysota), 0, Data, 27, 4);
Array.Copy(BitConverter.GetBytes(Vysota_baro), 0, Data, 31, 4);
Array.Copy(BitConverter.GetBytes(UsX), 0, Data, 35, 2);
Array.Copy(BitConverter.GetBytes(UsY), 0, Data, 37, 2);
Array.Copy(BitConverter.GetBytes(UsZ), 0, Data, 39, 2);
Array.Copy(BitConverter.GetBytes(UskX), 0, Data, 41, 2);
Array.Copy(BitConverter.GetBytes(UskY), 0, Data, 43, 2);
Array.Copy(BitConverter.GetBytes(UskZ), 0, Data, 45, 2);
Array.Copy(BitConverter.GetBytes(Kod_Oshibki), 0, Data, 47, 2);
}
/// <summary>
/// Функция извлечения данных из массива
/// </summary>
public static void GetData()
{
}
public static void ClearData()
{
for (int i = 0; i < Data.Length; i++)
Data[i] = 0;
}
}
}

247
util.cs

@ -9,7 +9,8 @@ using System.Windows.Forms; @@ -9,7 +9,8 @@ using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.ComponentModel;
using System.Drawing.Imaging;
using System.Globalization;
using static System.Net.Mime.MediaTypeNames;
namespace UTIL
{
@ -339,92 +340,6 @@ namespace UTIL @@ -339,92 +340,6 @@ namespace UTIL
}
}
public class AdvancedRadioButton : CheckBox
{
public enum Level { Parent, Form };
[Category("AdvancedRadioButton"),
Description("Gets or sets the level that specifies which RadioButton controls are affected."),
DefaultValue(Level.Parent)]
public Level GroupNameLevel { get; set; }
[Category("AdvancedRadioButton"),
Description("Gets or sets the name that specifies which RadioButton controls are mutually exclusive.")]
public string GroupName { get; set; }
protected override void OnCheckedChanged(EventArgs e)
{
base.OnCheckedChanged(e);
if (Checked)
{
var arbControls = (dynamic)null;
switch (GroupNameLevel)
{
case Level.Parent:
if (this.Parent != null)
arbControls = GetAll(this.Parent, typeof(AdvancedRadioButton));
break;
case Level.Form:
Form form = this.FindForm();
if (form != null)
arbControls = GetAll(this.FindForm(), typeof(AdvancedRadioButton));
break;
}
if (arbControls != null)
foreach (Control control in arbControls)
if (control != this &&
(control as AdvancedRadioButton).GroupName == this.GroupName)
(control as AdvancedRadioButton).Checked = false;
}
}
protected override void OnClick(EventArgs e)
{
if (!Checked)
base.OnClick(e);
}
protected override void OnPaint(PaintEventArgs pevent)
{
CheckBoxRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this);
RadioButtonState radioButtonState;
if (Checked)
{
radioButtonState = RadioButtonState.CheckedNormal;
if (Focused)
radioButtonState = RadioButtonState.CheckedHot;
if (!Enabled)
radioButtonState = RadioButtonState.CheckedDisabled;
}
else
{
radioButtonState = RadioButtonState.UncheckedNormal;
if (Focused)
radioButtonState = RadioButtonState.UncheckedHot;
if (!Enabled)
radioButtonState = RadioButtonState.UncheckedDisabled;
}
Size glyphSize = RadioButtonRenderer.GetGlyphSize(pevent.Graphics, radioButtonState);
Rectangle rect = pevent.ClipRectangle;
rect.Width -= glyphSize.Width;
rect.Location = new Point(rect.Left + glyphSize.Width, rect.Top);
RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, rect.Height / 2 - glyphSize.Height / 2), rect, this.Text, this.Font, this.Focused, radioButtonState);
}
private IEnumerable<Control> GetAll(Control control, Type type)
{
var controls = control.Controls.Cast<Control>();
return controls.SelectMany(ctrl => GetAll(ctrl, type))
.Concat(controls)
.Where(c => c.GetType() == type);
}
}
public class GKalman
{
double _err_measure = 0.0F;
@ -554,5 +469,163 @@ namespace UTIL @@ -554,5 +469,163 @@ namespace UTIL
public byte green;
public byte red;
}
public static class Util
{
public static String Val(Object value)
{
// Console.WriteLine(value.GetType());
// String tmp = value.GetType().ToString().Split(new Char[] { '.' })[1];
String tmp;
tmp = value.GetType().ToString();
Console.WriteLine(tmp);
tmp = value.GetType().ToString().Split(new Char[] { '.' })[1];
Console.WriteLine(tmp);
switch (tmp)
{
case "Double":
case "Single":
case "Decimal":
// return Math.Round(Convert.ToDouble(value), 2).ToString("+0.00;-0.00;+0.00");
case "UInt64":
case "UInt32":
case "UInt16":
case "Byte":
// return value.ToString();
// return $"{value:+0;+0;+0}";
case "Int64":
case "Int32":
case "Int16":
case "SByte":
// return $"{value:+0;-0;+0}";
// return value.ToString();
case "String":
// return $"{value}";
// return value.ToString();
case "Hex":
// return $"{value}";
// return value.ToString();
default:
break;
}
return "";
}
public static T minmax<T>(T min, T max, T val)
{
dynamic dmin = min;
dynamic dmax = max;
dynamic dval = val;
if (dval <= dmin)
return dmin;
if (dval > dmax)
return dmax;
return dval;
}
public struct Hex<T>
{
private T _Value;
public static implicit operator Hex<T>(T value)
{
return new Hex<T> { _Value = value };
}
public static implicit operator T(Hex<T> value)
{
return value._Value;
}
public override string ToString()
{
if (_Value.GetType() == typeof(UInt64))
return $"{_Value:X016}";
if (_Value.GetType() == typeof(UInt32))
return $"{_Value:X08}";
if (_Value.GetType() == typeof(UInt16))
return $"{_Value:X04}";
if (_Value.GetType() == typeof(Byte))
return $"{_Value:X02}";
return _Value.ToString();
}
}
public struct Hex0x<T>
{
private T _Value;
private CultureInfo ci;// = new CultureInfo("ru-Ru");
public static implicit operator Hex0x<T>(T value)
{
return new Hex0x<T> { _Value = value };
}
public static implicit operator T(Hex0x<T> value)
{
return value._Value;
}
public override string ToString()
{
if (_Value.GetType() == typeof(UInt64))
return $"0x{_Value:X016}";
if (_Value.GetType() == typeof(UInt32))
return $"0x{_Value:X08}";
if (_Value.GetType() == typeof(UInt16))
return $"0x{_Value:X04}";
if (_Value.GetType() == typeof(Byte))
return $"0x{_Value:X02}";
return _Value.ToString();
}
}
public static String printtime(Boolean ms)
{
if (ms == true)
return DateTime.Now.ToString("HH:mm:ss:fff");
else
return DateTime.Now.ToString("HH:mm:ss");
}
}
public class CircularBuffer<T>
{
T[] _buffer;
Int32 _head;
Int32 _tail;
Int32 _length;
Int32 _bufferSize;
Object _lock = new object();
public CircularBuffer(Int32 bufferSize)
{
_buffer = new T[bufferSize];
_bufferSize = bufferSize;
_head = bufferSize - 1;
}
public bool IsEmpty
{
get { return _length == 0; }
}
public bool IsFull
{
get { return _length == _bufferSize; }
}
public T Dequeue()
{
lock (_lock)
{
if (IsEmpty) throw new InvalidOperationException("Queue exhausted");
T dequeued = _buffer[_tail];
_tail = NextPosition(_tail);
_length--;
return dequeued;
}
}
private int NextPosition(int position)
{
return (position + 1) % _bufferSize;
}
public void Enqueue(T toAdd)
{
lock (_lock)
{
_head = NextPosition(_head);
_buffer[_head] = toAdd;
if (IsFull)
_tail = NextPosition(_tail);
else
_length++;
}
}
}
}

Loading…
Cancel
Save