Commit ee7a2073 authored by reza's avatar reza

v2

parent 75bdc47f
......@@ -5,6 +5,7 @@ using System.Threading;
using System.Management;
using System.Collections;
using System.Text;
using CenterSpace.NMath.Core;
using System.Threading.Tasks;
namespace I8Devices
......@@ -72,6 +73,7 @@ namespace I8Devices
public class Settings
{
public bool test_signal { get; set; }
public bool leadoff_mode { get; set; }
private int _sampling_rate = 250;
public int sampling_rate
......@@ -107,6 +109,7 @@ namespace I8Devices
public Settings()
{
test_signal = false;
leadoff_mode = false;
sampling_rate = 2000;
gain = 24;
}
......@@ -136,6 +139,7 @@ namespace I8Devices
settingMode_flag = true;
if (debug_mode) Console.WriteLine("DLL: Sampling rate= " + mysetting.sampling_rate);
if (debug_mode) Console.WriteLine("DLL: Test Mode= " + mysetting.test_signal);
if (debug_mode) Console.WriteLine("DLL: Lead off= " + mysetting.leadoff_mode);
if (debug_mode) Console.WriteLine("DLL: Gain= " + mysetting.gain);
if (debug_mode) Console.Write("DLL: Channels On/Off=");
foreach (var chon in mysetting.channels_on)
......@@ -150,6 +154,7 @@ namespace I8Devices
else sendBuffer[4] = Convert.ToByte('n');
sendBuffer[5] = Convert.ToByte(48+ (mysetting.sampling_rate/250)); // '1'=250, '2'=500, '4'=1000, '8'=2000
sendBuffer[6] = Convert.ToByte(' '); // disable lead-off (enable = 'L')
sendBuffer[6] = mysetting.leadoff_mode ? Convert.ToByte('L') : Convert.ToByte(' ');
sendBuffer[7] = Convert.ToByte('C'); // SRB1 connected to all Nchs
sendBuffer[8] = 0x01; //Bias Derivation to 3-0 Pchs 0xD Register ADS
sendBuffer[9] = 0x03; //Bias Derivation to 7-4 Pchs 0xE Register ADS
......@@ -464,7 +469,7 @@ namespace I8Devices
_serialPort.Read(last_data_recieve, 0, 74);
sample_count++;
double[] data_converted = new double[25];
double[] data_converted = new double[26];
data_converted[0] = sample_count;
data_converted[1] = last_data_recieve[24]; // key inputs
int i = 2;
......@@ -477,7 +482,7 @@ namespace I8Devices
i = 10;
for (int k = i; k < 16 + i; k++)
{
data_converted[k] = (65536 * last_data_recieve[3 * (k) - 4]) + (256 * last_data_recieve[3 * (k) - 3]) + last_data_recieve[3 * (k) - 2];
data_converted[k] = (65536 * last_data_recieve[(3*k) - 4]) + (256 * last_data_recieve[(3*k) - 3]) + last_data_recieve[(3*k) - 2];
if (data_converted[k] > 8388607) data_converted[k] = data_converted[k] - 16777216;
data_converted[k] = data_converted[k] * 0.536;
}
......@@ -576,4 +581,45 @@ namespace I8Devices
}
}
}
class FFTExample
{
static void Main(string[] args)
{
Console.WriteLine();
#region forward 1D real 1024 point FFT
//
// Simple example to compute a forward 1D real 1024 point FFT
//
// Create some random signal data.
RandomNumberGenerator rand = new RandGenMTwist(4230987);
var data = new DoubleVector(1024, rand);
// Compute the FFT
// This will create a complex conjugate symmetric packed result.
var fft1024 = new DoubleForward1DFFT(1024);
DoubleVector fftresult = fft1024.FFT(data);
// Ask the FFT instance for the correct reader, to unpacked the result.
DoubleSymmetricSignalReader reader = fft1024.GetSignalReader(data);
// The reader provides random access to any element in the pack fft result.
DoubleComplex thirdelement = reader[2];
Console.WriteLine();
Console.WriteLine("1D real forward 1024 point FFT computed.");
Console.WriteLine("-----------------------------------\n");
#endregion
Console.WriteLine();
Console.WriteLine("Finished. Press Enter Key.");
Console.Read();
}
}
}
......@@ -12,6 +12,8 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -31,6 +33,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Solver.Foundation, Version=3.0.2.10889, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Solver.Foundation.3.1.0\lib\Microsoft.Solver.Foundation.dll</HintPath>
</Reference>
<Reference Include="NMath, Version=6.2.0.58, Culture=neutral, PublicKeyToken=873235918a322639, processorArchitecture=MSIL">
<HintPath>packages\CenterSpace.NMath.6.2.0.58\lib\net40\NMath.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
......@@ -45,5 +53,15 @@
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\CenterSpace.NMath.6.2.0.58\build\CenterSpace.NMath.targets" Condition="Exists('packages\CenterSpace.NMath.6.2.0.58\build\CenterSpace.NMath.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\CenterSpace.NMath.6.2.0.58\build\CenterSpace.NMath.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\CenterSpace.NMath.6.2.0.58\build\CenterSpace.NMath.targets'))" />
</Target>
</Project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
cee0fd5b63109db6e056c9435087b6a76047a0ed
4ac7b559401062f04fdb3bc3e454c50b83208835
......@@ -4,9 +4,22 @@ C:\Users\i8-tech\Desktop\csharp_dlls\infinite8dll\I8Library1\obj\Debug\I8Library
C:\Users\i8-tech\Desktop\csharp_dlls\infinite8dll\I8Library1\obj\Debug\I8Library1.csproj.CoreCompileInputs.cache
C:\Users\i8-tech\Desktop\csharp_dlls\infinite8dll\I8Library1\obj\Debug\I8Library1.dll
C:\Users\i8-tech\Desktop\csharp_dlls\infinite8dll\I8Library1\obj\Debug\I8Library1.pdb
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x64\libiomp5md.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x64\NMathKernelx64.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x64\nmath_native_x64.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x64\nmath_sf_x64.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x86\libiomp5md.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x86\NMathKernelx86.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x86\nmath_native_x86.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\x86\nmath_sf_x86.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\I8Library1.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\I8Library1.pdb
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\Microsoft.Solver.Foundation.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\NMath.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\Microsoft.Solver.Foundation.xml
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\bin\Debug\NMath.xml
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\obj\Debug\I8Library1.csprojAssemblyReference.cache
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\obj\Debug\I8Library1.csproj.CoreCompileInputs.cache
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\obj\Debug\I8Library1.csproj.CopyComplete
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\obj\Debug\I8Library1.dll
C:\Users\i8-tech\Desktop\Softwares\dll\I8Library1\obj\Debug\I8Library1.pdb
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CenterSpace.NMath" version="6.2.0.58" targetFramework="net472" />
<package id="Microsoft.Solver.Foundation" version="3.1.0" targetFramework="net472" />
</packages>
\ No newline at end of file
......@@ -17,22 +17,28 @@ def read_data():
if __name__ == "__main__":
myAwsomeHolyShitImDyingForThisDevice = Device()
# myAwsomeHolyShitImDyingForThisDevice.debug_mode = True
myAwsomeHolyShitImDyingForThisDevice.debug_mode = True
if myAwsomeHolyShitImDyingForThisDevice.connect():
# time.sleep(1)
time.sleep(1)
mysetting = Settings()
mysetting.test_signal = 234
mysetting.sampling_rate = 885.5
mysetting.leadoff_mode = False
mysetting.channels_on[7] = False
mysetting.gain = 3
#
print(myAwsomeHolyShitImDyingForThisDevice.writeSetting(mysetting))
# mysetting = Settings()
# mysetting.test_signal = 234
# mysetting.sampling_rate = 885.5
# mysetting.channels_on[7] = False
# mysetting.gain = 3
mysetting.gain = 5
#
# print(myAwsomeHolyShitImDyingForThisDevice.writeSetting(mysetting))
print(myAwsomeHolyShitImDyingForThisDevice.writeSetting(mysetting))
# myAwsomeHolyShitImDyingForThisDevice.start()
# all_data = read_data()
# t ime.sleep(0.5)
# time.sleep(0.5)
......@@ -42,7 +48,7 @@ if __name__ == "__main__":
# for j in range(lastData.Length):
# all_data.append(lastData[j])
myAwsomeHolyShitImDyingForThisDevice.stop()
# myAwsomeHolyShitImDyingForThisDevice.stop()
# time.sleep(0.5)
# print('len(all_data)::: ', len(all_data))
# myAwsomeHolyShitImDyingForThisDevice.debug_mode = True
......
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