Skip to content

Commit

Permalink
Bug fix for float to double value conversion, json export
Browse files Browse the repository at this point in the history
Bug fix for float to double value conversion, json export
  • Loading branch information
xeonfusion committed Nov 8, 2019
1 parent a8cf1f9 commit 8165759
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
18 changes: 11 additions & 7 deletions VSCaptureMP/VSCaptureMP/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of VitalSignsCaptureMP v1.005.
* This file is part of VitalSignsCaptureMP v1.006.
* Copyright (C) 2017-19 John George K., [email protected]
VitalSignsCaptureMP is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -183,10 +183,11 @@ public static void CreateWaveformSet(int nWaveSetType, List<byte> WaveTrtype)
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL_III")))));
break;
case 2:
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x05))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x14))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x06))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x18))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL_II")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART_ABP")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PULS_OXIM_PLETH")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_VEN_CENT")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_RESP")))));
Expand Down Expand Up @@ -227,11 +228,12 @@ public static void CreateWaveformSet(int nWaveSetType, List<byte> WaveTrtype)
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
break;
case 8:
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x05))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x14))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x06))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x18))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PULS_OXIM_PLETH")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART_ABP")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_VEN_CENT")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_AWAY_CO2")))));
break;
Expand Down Expand Up @@ -1094,8 +1096,8 @@ public static double FloattypeToValue(uint fvalue)
double value = 0;
if (fvalue != DataConstants.FLOATTYPE_NAN)
{
uint exponentbits = (fvalue >> 24);
uint mantissabits = (fvalue << 8);
int exponentbits = (int)(fvalue >> 24);
int mantissabits = (int)(fvalue << 8);
mantissabits = (mantissabits >> 8);

sbyte signedexponentbits = (sbyte)exponentbits; // Get Two's complement signed byte
Expand Down Expand Up @@ -1561,6 +1563,8 @@ public void PostJSONDataToServer(string postData)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_jsonposturl);
request.Method = "POST";

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Expand Down
6 changes: 5 additions & 1 deletion VSCaptureMP/VSCaptureMP/Class2.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of VitalSignsCaptureMP v1.005.
* This file is part of VitalSignsCaptureMP v1.006.
* Copyright (C) 2017-19 John George K., [email protected]
* Portions of code (C) 2015 Richard L. Grier
Expand Down Expand Up @@ -2757,6 +2757,10 @@ public class DataConstants
public const int MSMT_STATE_AL_INHIBITED = 0x0001;

public const int FLOATTYPE_NAN = 0x007FFFFF;
public const int FLOATTYPE_NRes = 0x800000;
public const int FLOATTYPE_POSITIVE_INFINITY = 0x7FFFFE;
public const int FLOATTYPE_NEGATIVE_INFINITY = 0x800002;


//MetricCategory
public const byte MCAT_UNSPEC = 0;
Expand Down
20 changes: 12 additions & 8 deletions VSCaptureMP/VSCaptureMP/Class3.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of VitalSignsCaptureMP v1.005.
* This file is part of VitalSignsCaptureMP v1.006.
* Copyright (C) 2017-19 John George K., [email protected]
VitalSignsCaptureMP is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -508,10 +508,11 @@ public static void CreateWaveformSet(int nWaveSetType, List<byte> WaveTrtype)
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL_III")))));
break;
case 2:
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x05))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x14))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x06))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x18))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL_II")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART_ABP")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PULS_OXIM_PLETH")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_VEN_CENT")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_RESP")))));
Expand Down Expand Up @@ -552,11 +553,12 @@ public static void CreateWaveformSet(int nWaveSetType, List<byte> WaveTrtype)
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
break;
case 8:
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x05))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x14))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x06))); //count
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianshortus(0x18))); //length
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_ECG_ELEC_POTL")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PULS_OXIM_PLETH")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART_ABP")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_ART")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_PRESS_BLD_VEN_CENT")))));
WaveTrtype.AddRange(BitConverter.GetBytes(correctendianuint((uint)(Enum.Parse(typeof(DataConstants.WavesIDLabels), "NLS_NOM_AWAY_CO2")))));
break;
Expand Down Expand Up @@ -905,7 +907,7 @@ public void PollPacketDecoder(byte[] packetbuffer, int headersize)
}
}

if(m_dataexportset == 2) ExportNumValListToJSON("Numeric");
if (m_dataexportset == 2) ExportNumValListToJSON("Numeric");
ExportDataToCSV();
ExportWaveToCSV();
}
Expand Down Expand Up @@ -1417,8 +1419,8 @@ public static double FloattypeToValue(uint fvalue)
double value = 0;
if (fvalue != DataConstants.FLOATTYPE_NAN)
{
uint exponentbits = (fvalue >> 24);
uint mantissabits = (fvalue << 8);
int exponentbits = (int)(fvalue >> 24);
int mantissabits = (int)(fvalue << 8);
mantissabits = (mantissabits >> 8);

sbyte signedexponentbits = (sbyte)exponentbits; // Get Two's complement signed byte
Expand Down Expand Up @@ -1883,6 +1885,8 @@ public void PostJSONDataToServer(string postData)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_jsonposturl);
request.Method = "POST";

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Expand Down
14 changes: 7 additions & 7 deletions VSCaptureMP/VSCaptureMP/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of VitalSignsCaptureMP v1.005.
* This file is part of VitalSignsCaptureMP v1.006.
* Copyright (C) 2017-19 John George K., [email protected]
VitalSignsCaptureMP is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -271,13 +271,13 @@ public static void ConnectviaLAN(string[] args)
Console.WriteLine("Waveform data export options:");
Console.WriteLine("0. None");
Console.WriteLine("1. ECG I, II, III");
Console.WriteLine("2. ECG II, ABP, PLETH, CVP, RESP");
Console.WriteLine("2. ECG II, ABP, ART IBP, PLETH, CVP, RESP");
Console.WriteLine("3. ECG AVR, ECG AVL, ECG AVF");
Console.WriteLine("4. ECG V1, ECG V2, ECG V3");
Console.WriteLine("5. ECG V4, ECG V5, ECG V6");
Console.WriteLine("6. EEG1, EEG2, EEG3, EEG4");
Console.WriteLine("7. ABP, ART IBP");
Console.WriteLine("8. Compound ECG, PLETH, ABP, CVP, CO2");
Console.WriteLine("8. Compound ECG, PLETH, ABP, ART IBP, CVP, CO2");
Console.WriteLine("9. All");

Console.WriteLine();
Expand Down Expand Up @@ -337,6 +337,8 @@ public static void ConnectviaLAN(string[] args)
Console.WriteLine();
Console.WriteLine("Press Escape button to Stop");

if (nDataExportset > 0 && nDataExportset < 3) _MPudpclient.m_dataexportset = nDataExportset;

if (nCSVset > 0 && nCSVset < 4) _MPudpclient.m_csvexportset = nCSVset;

if (nWavescaleSet == 1) _MPudpclient.m_calibratewavevalues = false;
Expand All @@ -350,8 +352,6 @@ public static void ConnectviaLAN(string[] args)
_MPudpclient.m_DeviceID = DeviceID;
_MPudpclient.m_jsonposturl = JSONPostUrl;

if (nDataExportset > 0 && nDataExportset < 3) _MPudpclient.m_dataexportset = nDataExportset;

try
{
_MPudpclient.Connect(_MPudpclient.m_remoteIPtarget);
Expand Down Expand Up @@ -579,13 +579,13 @@ public static void ConnectviaMIB(string[] args)
Console.WriteLine("Waveform data export priority options:");
Console.WriteLine("0. None");
Console.WriteLine("1. ECG I, II, III");
Console.WriteLine("2. ECG II, ABP, PLETH, CVP, RESP");
Console.WriteLine("2. ECG II, ABP, ART IBP, PLETH, CVP, RESP");
Console.WriteLine("3. ECG AVR, ECG AVL, ECG AVF");
Console.WriteLine("4. ECG V1, ECG V2, ECG V3");
Console.WriteLine("5. ECG V4, ECG V5, ECG V6");
Console.WriteLine("6. EEG1, EEG2, EEG3, EEG4");
Console.WriteLine("7. ABP, ART IBP");
Console.WriteLine("8. Compound ECG, PLETH, ABP, CVP, CO2");
Console.WriteLine("8. Compound ECG, PLETH, ABP, ART IBP, CVP, CO2");
Console.WriteLine("9. All");

Console.WriteLine();
Expand Down

0 comments on commit 8165759

Please sign in to comment.