Commit 4e9d8471 authored by reza's avatar reza

aa

parent 7e8d3d22
......@@ -89,7 +89,7 @@ namespace I8Devices
}
private int _gain = 250;
private int _Exgain = 250;
private int _exgain = 250;
public int gain
{
get => _gain;
......@@ -105,18 +105,18 @@ namespace I8Devices
}
}
public int Exgain
public int exgain
{
get => _Exgain;
get => _exgain;
set
{
if (value <= 1) _gain = 1;
else if ((value > 1) && (value <= 2)) _gain = 2;
else if ((value > 2) && (value <= 4)) _gain = 4;
else if ((value > 4) && (value <= 6)) _gain = 6;
else if ((value > 6) && (value <= 8)) _gain = 8;
else if ((value > 8) && (value <= 12)) _gain = 12;
else if ((value > 12)) _gain = 24;
if (value <= 1) _exgain = 1;
else if ((value > 1) && (value <= 2)) _exgain = 2;
else if ((value > 2) && (value <= 4)) _exgain = 4;
else if ((value > 4) && (value <= 6)) _exgain = 6;
else if ((value > 6) && (value <= 8)) _exgain = 8;
else if ((value > 8) && (value <= 12)) _exgain = 12;
else if ((value > 12)) _exgain = 24;
}
}
......@@ -257,8 +257,7 @@ namespace I8Devices
sendBuffer[6] = mysetting.leadoff_mode ? Convert.ToByte('L') : Convert.ToByte(' '); // lead-off enable/disable
sendBuffer[7] = Convert.ToByte('C'); // SRB1 connected to all Nchs
sendBuffer[8] = Convert.ToByte(mysetting.gain);
sendBuffer[9] = Convert.ToByte(mysetting.Exgain);
sendBuffer[9] = Convert.ToByte(mysetting.exgain);
sendBuffer[10] = 0x00; //reserved
sendBuffer[11] = 0x00; //reserved
sendBuffer[12] = 0x00; //reserved
......@@ -278,13 +277,12 @@ namespace I8Devices
if (debug_mode) Console.WriteLine("DLL: sendBuffer[12] " + sendBuffer[12]);
BitArray Exch_arr = new BitArray(mysetting.Exchannels_on);
byte[] Exch_data = new byte[80];
Exch_arr.CopyTo(Exch_data, 0);
sendBuffer[18] = Exch_data[0]; // channels 1 to 8 on/off status
Console.WriteLine("DLL: sendBuffer[18] " + sendBuffer[18]);
_serialPort.Open();
_serialPort.Write(sendBuffer, 0, sendBuffer.Length);
......@@ -521,7 +519,7 @@ namespace I8Devices
}
else if (settingMode_flag)
{
byte[] rec_data = new byte[32];
byte[] rec_data = new byte[32];
_serialPort.Read(rec_data, 0, 32);
if (Convert.ToByte(rec_data[31]) == 144) // Indicate I8Device ID
{
......@@ -529,6 +527,16 @@ namespace I8Devices
if (Convert.ToByte(rec_data[27]) == 48) // Indicate Fascin8 device
{
if (debug_mode) Console.WriteLine("DLL: Fascin8 writing setiing done succesfully.");
if (debug_mode)
{
int c = 0;
foreach (var b in rec_data)
{
//sb.Append(b + ", ");
Console.WriteLine(c.ToString("X") + "- " + ((byte)b).ToString("X"));
c++; if (c > 23) break;
}
}
}
else if (Convert.ToByte(rec_data[27]) == 47) // Indicate Ultim8 device
{
......@@ -555,6 +563,7 @@ namespace I8Devices
{
if (device_name == "Fascin8" && _serialPort.IsOpen && _serialPort.BytesToRead > 73)
{
/*
byte[] last_data_recieve = new byte[74];
_serialPort.Read(last_data_recieve, 0, 74);
sample_count++;
......@@ -579,6 +588,29 @@ namespace I8Devices
receiveBuffer.Add(data_converted);
newData_count ++;
// if (debug_mode) Console.WriteLine("DLL: Sample number " + sample_count + " has been received :)");
*/
byte[] last_data_recieve = new byte[80];
_serialPort.Read(last_data_recieve, 0, 80);
double[] data_converted = new double[30];
data_converted[0] = sample_count; // dll sample count
data_converted[1] = (65536 * last_data_recieve[0]) + (256 * last_data_recieve[1]) + last_data_recieve[2]; // firmware sample count
data_converted[2] = 0; //reserverd
data_converted[3] = last_data_recieve[3]; // Device ID
data_converted[4] = last_data_recieve[4]; // user input keys
data_converted[5] = 0; //reserverd
int i = 6, p = 8;
for (int k = i; k < 24 + i; k++)
{
data_converted[k] = (65536 * last_data_recieve[3 * (k - i) + p + 0]) + (256 * last_data_recieve[3 * (k - i) + p + 1]) +
last_data_recieve[3 * (k - i) + p + 2];
if (data_converted[k] > 8388607) data_converted[k] = data_converted[k] - 16777216;
data_converted[k] = data_converted[k] * 0.536;
}
receiveBuffer.Add(data_converted);
sample_count++;
newData_count++;
}
else if (device_name == "Ultim8" && _serialPort.IsOpen && _serialPort.BytesToRead > 25)
{
......
......@@ -8,11 +8,12 @@ from I8Devices import Device, Settings
def read_data():
dataList = []
for i in range(1000):
lastData = myAwsomeHolyShitImDyingForThisDevice.getData(5)
for i in range(10):
lastData = myAwsomeHolyShitImDyingForThisDevice.getData(1)
for j in range(lastData.Length):
# dataList.append(lastData.GetValue(j))
dataList.append(lastData[j])
print(lastData[j][0])
return dataList
if __name__ == "__main__":
......@@ -24,14 +25,14 @@ if __name__ == "__main__":
time.sleep(1)
mysetting = Settings()
mysetting.test_signal = 234
mysetting.sampling_rate = 885.5
mysetting.test_signal = False
mysetting.sampling_rate = 250
mysetting.leadoff_mode = False
mysetting.channels_on[15] = False
mysetting.Exchannels_on[0] = False
mysetting.channels_on[1] = False
mysetting.Exchannels_on[1] = True
mysetting.gain = 12
mysetting.gain = 24
mysetting.exgain = 24
#
print(myAwsomeHolyShitImDyingForThisDevice.set(mysetting))
......@@ -40,8 +41,8 @@ if __name__ == "__main__":
# #
# print(myAwsomeHolyShitImDyingForThisDevice.writeSetting(mysetting))
# myAwsomeHolyShitImDyingForThisDevice.start()
# all_data = read_data()
myAwsomeHolyShitImDyingForThisDevice.start()
all_data = read_data()
# time.sleep(0.5)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment