picoscopereader hinzugefügt

This commit is contained in:
BlubbFish 2017-03-09 20:49:20 +00:00
commit 2b0b5201b5
18 changed files with 5679 additions and 0 deletions

20
PicoSopeReader.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PicoSopeReader", "PicoSopeReader\PicoSopeReader.csproj", "{DB1DED6E-A9EA-4075-8500-21D1686A64C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB1DED6E-A9EA-4075-8500-21D1686A64C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB1DED6E-A9EA-4075-8500-21D1686A64C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB1DED6E-A9EA-4075-8500-21D1686A64C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB1DED6E-A9EA-4075-8500-21D1686A64C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

478
PicoSopeReader/Imports.cs Normal file
View File

@ -0,0 +1,478 @@
/**************************************************************************
*
* Filename: Imports.cs
*
* Copyright: Pico Technology Limited 2007
*
* Author: MJL
*
* Description:
* This file contains all the .NET wrapper calls needed to support
* the console example. It also has the enums and structs required
* by the (wrapped) function calls.
*
* History:
* 14Dec06 MJL Created
*
* Revision Info: "file %n date %f revision %v"
* ""
*
***************************************************************************/
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace PicoSopeReader
{
class Imports
{
#region constants
public const string _DRIVER_FILENAME = "ps5000.dll";
public const int MaxValue = 32512;
#endregion
#region Driver enums
public enum Channel : int
{
ChannelA,
ChannelB,
ChannelC,
ChannelD,
External,
Aux,
None,
}
public enum Range : int
{
Range_10MV,
Range_20MV,
Range_50MV,
Range_100MV,
Range_200MV,
Range_500MV,
Range_1V,
Range_2V,
Range_5V,
Range_10V,
Range_20V,
Range_50V,
}
public enum ReportedTimeUnits : int
{
FemtoSeconds,
PicoSeconds,
NanoSeconds,
MicroSeconds,
MilliSeconds,
Seconds,
}
public enum SiggenWaveType : int
{
Sine,
Square,
Triangle,
RampUp,
RampDown,
SinXOverX,
Gaussian,
HalfSine,
DcVoltage,
MAX_WAVE_TYPES
}
public enum SiggenSweepType : int
{
Up,
Down,
UpDown,
DownUp
}
public enum SiggenTrigType : int
{
Rising,
Falling,
GateHigh,
GateLow
}
public enum SiggenTrigSource : int
{
None,
ScopeTrigger,
AuxIn,
ExtIn,
SoftwareTrigger
}
public enum SiggenIndexMode : int
{
Single,
Dual,
Quad,
}
public enum EtsMode : int
{
Off,
Fast,
Slow,
}
public enum ThresholdMode : int
{
Level,
Window
}
public enum ThresholdDirection : int
{
// Values for level threshold mode
//
Above,
Below,
Rising,
Falling,
RisingOrFalling,
// Values for window threshold mode
//
Inside = Above,
Outside = Below,
Enter = Rising,
Exit = Falling,
EnterOrExit = RisingOrFalling,
None = Rising,
}
public enum DownSamplingMode : int
{
None,
Aggregate
}
public enum PulseWidthType : int
{
None,
LessThan,
GreaterThan,
InRange,
OutOfRange
}
public enum TriggerState : int
{
DontCare,
True,
False,
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TriggerChannelProperties
{
public short ThresholdMajor;
public short ThresholdMinor;
public ushort Hysteresis;
public Channel Channel;
public ThresholdMode ThresholdMode;
public TriggerChannelProperties(
short thresholdMajor,
short thresholdMinor,
ushort hysteresis,
Channel channel,
ThresholdMode thresholdMode)
{
this.ThresholdMajor = thresholdMajor;
this.ThresholdMinor = thresholdMinor;
this.Hysteresis = hysteresis;
this.Channel = channel;
this.ThresholdMode = thresholdMode;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TriggerConditions
{
public TriggerState ChannelA;
public TriggerState ChannelB;
public TriggerState ChannelC;
public TriggerState ChannelD;
public TriggerState External;
public TriggerState Aux;
public TriggerState Pwq;
public TriggerConditions(
TriggerState channelA,
TriggerState channelB,
TriggerState channelC,
TriggerState channelD,
TriggerState external,
TriggerState aux,
TriggerState pwq)
{
this.ChannelA = channelA;
this.ChannelB = channelB;
this.ChannelC = channelC;
this.ChannelD = channelD;
this.External = external;
this.Aux = aux;
this.Pwq = pwq;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PwqConditions
{
public TriggerState ChannelA;
public TriggerState ChannelB;
public TriggerState ChannelC;
public TriggerState ChannelD;
public TriggerState External;
public TriggerState Aux;
public PwqConditions(
TriggerState channelA,
TriggerState channelB,
TriggerState channelC,
TriggerState channelD,
TriggerState external,
TriggerState aux)
{
this.ChannelA = channelA;
this.ChannelB = channelB;
this.ChannelC = channelC;
this.ChannelD = channelD;
this.External = external;
this.Aux = aux;
}
}
#endregion
#region Driver Imports
#region Callback delegates
public delegate void ps5000BlockReady(short handle, short status, IntPtr pVoid);
public delegate void ps5000StreamingReady(
short handle,
int noOfSamples,
uint startIndex,
short ov,
uint triggerAt,
short triggered,
short autoStop,
IntPtr pVoid);
public delegate void ps5000DataReady(
short handle,
int noOfSamples,
short overflow,
uint triggerAt,
short triggered,
IntPtr pVoid);
#endregion
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000OpenUnit")]
public static extern short OpenUnit(out short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000CloseUnit")]
public static extern short CloseUnit(short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000RunBlock")]
public static extern short RunBlock(
short handle,
int noOfPreTriggerSamples,
int noOfPostTriggerSamples,
uint timebase,
short oversample,
out int timeIndisposedMs,
ushort segmentIndex,
ps5000BlockReady lpPs5000BlockReady,
IntPtr pVoid);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000Stop")]
public static extern short Stop(short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetChannel")]
public static extern short SetChannel(
short handle,
Channel channel,
short enabled,
short dc,
Range range);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBuffers")]
public static extern short SetDataBuffers(
short handle,
Channel channel,
short[] bufferMax,
short[] bufferMin,
int bufferLth);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBuffer")]
public static extern short SetDataBuffer(
short handle,
Channel channel,
short[] buffer,
long bufferLth);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetEts")]
public static extern short SetEts(
short handle,
EtsMode mode,
short etsCycles,
short etsInterleave,
out int sampleTimePicoseconds);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelDirections")]
public static extern short SetTriggerChannelDirections(
short handle,
ThresholdDirection channelA,
ThresholdDirection channelB,
ThresholdDirection channelC,
ThresholdDirection channelD,
ThresholdDirection ext,
ThresholdDirection aux);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetTimebase")]
public static extern short GetTimebase(
short handle,
uint timebase,
int noSamples,
out int timeIntervalNanoseconds,
short oversample,
out int maxSamples,
ushort segmentIndex);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetValues")]
public static extern short GetValues(
short handle,
uint startIndex,
ref uint noOfSamples,
uint downSampleRatio,
DownSamplingMode downSampleDownSamplingMode,
ushort segmentIndex,
out short overflow);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetPulseWidthQualifier")]
public static extern short SetPulseWidthQualifier(
short handle,
PwqConditions[] conditions,
short numConditions,
ThresholdDirection direction,
uint lower,
uint upper,
PulseWidthType type);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelProperties")]
public static extern short SetTriggerChannelProperties(
short handle,
TriggerChannelProperties[] channelProperties,
short numChannelProperties,
short auxOutputEnable,
int autoTriggerMilliseconds);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelConditions")]
public static extern short SetTriggerChannelConditions(
short handle,
TriggerConditions[] conditions,
short numConditions);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerDelay")]
public static extern short SetTriggerDelay(short handle, uint delay);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetUnitInfo")]
public static extern short GetUnitInfo(short handle, StringBuilder infoString, short stringLength, out short requiredSize, int info);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetSigGenBuiltIn")]
public static extern short SetSiggenBuiltIn(
short handle,
int offsetVoltage,
uint pkToPk,
SiggenWaveType siggenWaveType,
float startFrequency,
float stopFrequency,
float increment,
float dwellTime,
SiggenSweepType sweepType,
bool whiteNoise,
uint shots,
uint sweeps,
SiggenTrigType triggerType,
SiggenTrigSource triggerSource,
short extInThreshold);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetSigGenArbitrary")]
public static extern short SetSiggenArbitrary(
short handle,
int offsetVoltage,
uint pkToPk,
uint startDeltaPhase,
uint stopDeltaPhase,
uint deltaPhaseIncrement,
uint dwellCount,
short[] arbitraryWaveform,
uint arbitraryWaveformSize,
SiggenSweepType sweepType,
bool whiteNoise,
SiggenIndexMode indexMode,
uint shots,
uint sweeps,
SiggenTrigType triggerType,
SiggenTrigSource triggerSource,
short extInThreshold);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000RunStreaming")]
public static extern short RunStreaming(
short handle,
ref uint sampleInterval,
ReportedTimeUnits sampleIntervalTimeUnits,
uint maxPreTriggerSamples,
uint maxPostPreTriggerSamples,
bool autoStop,
uint downSamplingRation,
uint overviewBufferSize);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetStreamingLatestValues")]
public static extern short GetStreamingLatestValues(
short handle,
ps5000StreamingReady lpPs5000StreamingReady,
IntPtr pVoid);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetNoOfCaptures")]
public static extern short SetNoOfRapidCaptures(
short handle,
ushort nWaveforms);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000MemorySegments")]
public static extern short MemorySegments(
short handle,
ushort nSegments,
out int nMaxSamples);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBufferBulk")]
public static extern short SetDataBuffersRapid(
short handle,
Channel channel,
short[] buffer,
int bufferLth,
ushort waveform);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetValuesBulk")]
public static extern short GetValuesRapid(
short handle,
ref uint noOfSamples,
ushort fromSegmentIndex,
ushort toSegmentIndex,
short[] overflows);
#endregion
}
}

View File

@ -0,0 +1,147 @@
using System;
using System.IO;
using System.Threading;
namespace PicoSopeReader
{
class PicoReader
{
private readonly short _handle;
uint _timebase;
short _oversample;
bool _ready = false;
ushort[] inputRanges = { 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000 };
public PicoReader(short handle)
{
_handle = handle;
}
public void Run()
{
char ch = ' ';
while (ch != 'X')
{
Console.WriteLine("");
Console.WriteLine("+-----------------------------------------------------+");
Console.WriteLine("|Wilkommen zum PicoScopeReader: |");
Console.WriteLine("|Programiert von Philip Schell |");
Console.WriteLine("| |");
Console.WriteLine("|Programm released under LGPLv3 |");
Console.WriteLine("| |");
Console.WriteLine("| S - Start Reading X - exit |");
Console.WriteLine("+-----------------------------------------------------+");
ch = char.ToUpper(Console.ReadKey().KeyChar);
Console.WriteLine("\n");
switch (ch)
{
case 'B':
Tracking();
break;
default:
Console.WriteLine("Invalid operation");
break;
}
}
}
private void Tracking()
{
Console.WriteLine("Chan A einschalten und auf 5V: {0}", Imports.SetChannel(_handle, Imports.Channel.ChannelA, 1, 1, Imports.Range.Range_5V));
Console.WriteLine("Chan B einschalten und auf 1V: {0}", Imports.SetChannel(_handle, Imports.Channel.ChannelB, 1, 1, Imports.Range.Range_1V));
int tmp;
Console.WriteLine("Disable ETS: {0}", Imports.SetEts(_handle, Imports.EtsMode.Off, 0, 0, out tmp));
int timeInterval;
int maxSamples;
uint sampleCount = (int)(1 * 1e6);
_timebase = 5; //timebase = 5 => 24ns => 40mhz
_oversample = 1;
Console.WriteLine("Zeit Setzen: {0}", Imports.GetTimebase(_handle, _timebase, (int)sampleCount, out timeInterval, _oversample, out maxSamples, 0));
short triggerVoltage = mv_to_adc(3000, (short)Imports.Range.Range_5V);
Console.WriteLine("max {0} {1}:", Imports.MaxValue, triggerVoltage);
Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] {
new Imports.TriggerChannelProperties(
triggerVoltage,
triggerVoltage,
1,
Imports.Channel.ChannelA,
Imports.ThresholdMode.Level)};
Console.WriteLine("Trigger Einstellungen auf Chan A setzen: {0}", Imports.SetTriggerChannelProperties(_handle, sourceDetails, (short)sourceDetails.Length, 0, 0));
Imports.TriggerConditions[] cond = new Imports.TriggerConditions[] {
new Imports.TriggerConditions(
Imports.TriggerState.True,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare)};
Console.WriteLine("Trigger Bedingung auf Chan A setzen: {0}", Imports.SetTriggerChannelConditions(_handle, cond, (short)cond.Length));
Imports.ThresholdDirection dir_i = Imports.ThresholdDirection.Falling;
Imports.ThresholdDirection dir_n = Imports.ThresholdDirection.None;
Console.WriteLine("Trigger Richtung auf Chan A setzen: {0}", Imports.SetTriggerChannelDirections(_handle, dir_i, dir_n, dir_n, dir_n, dir_n, dir_n));
Console.WriteLine("Trigger Verzögerung setzen: {0}", Imports.SetTriggerDelay(_handle, 0));
Console.WriteLine("Alloc Buffer A (Chan A)");
short[] Buffer_A = new short[sampleCount];
Console.WriteLine("Alloc Buffer B (Chan B)");
short[] Buffer_B = new short[sampleCount];
Console.WriteLine("Buffer ChanA Setzen: {0}", Imports.SetDataBuffer(_handle, Imports.Channel.ChannelA, Buffer_A, sampleCount));
Console.WriteLine("Buffer ChanB Setzen: {0}", Imports.SetDataBuffer(_handle, Imports.Channel.ChannelB, Buffer_B, sampleCount));
_ready = false;
int timeIndisposed;
Console.WriteLine("Trigger Starten: {0}", Imports.RunBlock(_handle, 0, (int)sampleCount, _timebase, _oversample, out timeIndisposed, 0, BlockCallback, IntPtr.Zero));
Console.WriteLine("======================================================\n" +
"Gestartet, wenn Sie keine Lust mehr haben, drücken sie irgend eine Taste");
while (!_ready && !Console.KeyAvailable)
{
Thread.Sleep(100);
}
if (Console.KeyAvailable)
Console.ReadKey(true);
Imports.Stop(_handle);
if (_ready)
{
short overflow;
Console.WriteLine("Bekomme werte zurück: {0}", Imports.GetValues(_handle, 0, ref sampleCount, 1, Imports.DownSamplingMode.None, 0, out overflow));
Console.WriteLine("Buffergröße {0}", sampleCount);
StreamWriter chan_a = new StreamWriter("Chan_A.txt");
StreamWriter chan_b = new StreamWriter("Chan_B.txt");
for (int i = 0; i < sampleCount; i++)
{
chan_a.WriteLine(adc_to_mv(Buffer_A[i], (short)Imports.Range.Range_5V));
chan_b.WriteLine(adc_to_mv(Buffer_B[i], (short)Imports.Range.Range_1V));
}
chan_a.Close();
chan_b.Close();
Console.WriteLine("Dateien geschrieben!");
}
}
short mv_to_adc(short mv, short ch)
{
return (short)((mv * Imports.MaxValue) / inputRanges[ch]);
}
int adc_to_mv(int raw, int ch)
{
return (raw * inputRanges[ch]) / Imports.MaxValue;
}
void BlockCallback(short handle, short status, IntPtr pVoid)
{
_ready = true;
}
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DB1DED6E-A9EA-4075-8500-21D1686A64C9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PicoSopeReader</RootNamespace>
<AssemblyName>PicoSopeReader</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Imports.cs" />
<Compile Include="PicoReader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

57
PicoSopeReader/Program.cs Normal file
View File

@ -0,0 +1,57 @@
using System;
using System.Threading;
namespace PicoSopeReader
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("PS5000 Reader Programm");
Console.WriteLine("Version 1.0\n");
Console.WriteLine("\n\nGerät öffnen...");
short handle = 0;
short status = 0;
try
{
status = Imports.OpenUnit(out handle);
}
catch (System.DllNotFoundException)
{
Console.WriteLine("Konnte die Treiber DLL Datei nicht finden! ({0})",Imports._DRIVER_FILENAME);
WaitForKeyAndExit();
}
catch (Exception e)
{
Console.WriteLine(e);
WaitForKeyAndExit();
}
finally
{
Console.WriteLine("Handle: {0}", handle);
if (status != 0)
{
Console.WriteLine("Unable to open device");
Console.WriteLine("Error code : {0}", status);
WaitForKeyAndExit();
}
else
{
Console.WriteLine("Device opened successfully\n");
PicoReader prog = new PicoReader(handle);
prog.Run();
Imports.CloseUnit(handle);
}
}
}
private static void WaitForKeyAndExit()
{
while (!Console.KeyAvailable)
Thread.Sleep(100);
if (Console.KeyAvailable)
Console.ReadKey(true);
Environment.Exit(1);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("PicoSopeReader")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PicoSopeReader")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("83a98d9b-1322-451c-9d00-d4f2c8b4e822")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Binary file not shown.

File diff suppressed because it is too large Load Diff

478
dotnet example/Imports.cs Normal file
View File

@ -0,0 +1,478 @@
/**************************************************************************
*
* Filename: Imports.cs
*
* Copyright: Pico Technology Limited 2007
*
* Author: MJL
*
* Description:
* This file contains all the .NET wrapper calls needed to support
* the console example. It also has the enums and structs required
* by the (wrapped) function calls.
*
* History:
* 14Dec06 MJL Created
*
* Revision Info: "file %n date %f revision %v"
* ""
*
***************************************************************************/
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace ps5000example
{
class Imports
{
#region constants
private const string _DRIVER_FILENAME = "ps5000.dll";
public const int MaxValue = 32512;
#endregion
#region Driver enums
public enum Channel : int
{
ChannelA,
ChannelB,
ChannelC,
ChannelD,
External,
Aux,
None,
}
public enum Range : int
{
Range_10MV,
Range_20MV,
Range_50MV,
Range_100MV,
Range_200MV,
Range_500MV,
Range_1V,
Range_2V,
Range_5V,
Range_10V,
Range_20V,
Range_50V,
}
public enum ReportedTimeUnits : int
{
FemtoSeconds,
PicoSeconds,
NanoSeconds,
MicroSeconds,
MilliSeconds,
Seconds,
}
public enum SiggenWaveType : int
{
Sine,
Square,
Triangle,
RampUp,
RampDown,
SinXOverX,
Gaussian,
HalfSine,
DcVoltage,
MAX_WAVE_TYPES
}
public enum SiggenSweepType : int
{
Up,
Down,
UpDown,
DownUp
}
public enum SiggenTrigType : int
{
Rising,
Falling,
GateHigh,
GateLow
}
public enum SiggenTrigSource : int
{
None,
ScopeTrigger,
AuxIn,
ExtIn,
SoftwareTrigger
}
public enum SiggenIndexMode : int
{
Single,
Dual,
Quad,
}
public enum EtsMode : int
{
Off,
Fast,
Slow,
}
public enum ThresholdMode : int
{
Level,
Window
}
public enum ThresholdDirection : int
{
// Values for level threshold mode
//
Above,
Below,
Rising,
Falling,
RisingOrFalling,
// Values for window threshold mode
//
Inside = Above,
Outside = Below,
Enter = Rising,
Exit = Falling,
EnterOrExit = RisingOrFalling,
None = Rising,
}
public enum DownSamplingMode : int
{
None,
Aggregate
}
public enum PulseWidthType : int
{
None,
LessThan,
GreaterThan,
InRange,
OutOfRange
}
public enum TriggerState : int
{
DontCare,
True,
False,
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TriggerChannelProperties
{
public short ThresholdMajor;
public short ThresholdMinor;
public ushort Hysteresis;
public Channel Channel;
public ThresholdMode ThresholdMode;
public TriggerChannelProperties(
short thresholdMajor,
short thresholdMinor,
ushort hysteresis,
Channel channel,
ThresholdMode thresholdMode)
{
this.ThresholdMajor = thresholdMajor;
this.ThresholdMinor = thresholdMinor;
this.Hysteresis = hysteresis;
this.Channel = channel;
this.ThresholdMode = thresholdMode;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TriggerConditions
{
public TriggerState ChannelA;
public TriggerState ChannelB;
public TriggerState ChannelC;
public TriggerState ChannelD;
public TriggerState External;
public TriggerState Aux;
public TriggerState Pwq;
public TriggerConditions(
TriggerState channelA,
TriggerState channelB,
TriggerState channelC,
TriggerState channelD,
TriggerState external,
TriggerState aux,
TriggerState pwq)
{
this.ChannelA = channelA;
this.ChannelB = channelB;
this.ChannelC = channelC;
this.ChannelD = channelD;
this.External = external;
this.Aux = aux;
this.Pwq = pwq;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PwqConditions
{
public TriggerState ChannelA;
public TriggerState ChannelB;
public TriggerState ChannelC;
public TriggerState ChannelD;
public TriggerState External;
public TriggerState Aux;
public PwqConditions(
TriggerState channelA,
TriggerState channelB,
TriggerState channelC,
TriggerState channelD,
TriggerState external,
TriggerState aux)
{
this.ChannelA = channelA;
this.ChannelB = channelB;
this.ChannelC = channelC;
this.ChannelD = channelD;
this.External = external;
this.Aux = aux;
}
}
#endregion
#region Driver Imports
#region Callback delegates
public delegate void ps5000BlockReady(short handle, short status, IntPtr pVoid);
public delegate void ps5000StreamingReady(
short handle,
int noOfSamples,
uint startIndex,
short ov,
uint triggerAt,
short triggered,
short autoStop,
IntPtr pVoid);
public delegate void ps5000DataReady(
short handle,
int noOfSamples,
short overflow,
uint triggerAt,
short triggered,
IntPtr pVoid);
#endregion
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000OpenUnit")]
public static extern short OpenUnit(out short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000CloseUnit")]
public static extern short CloseUnit(short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000RunBlock")]
public static extern short RunBlock(
short handle,
int noOfPreTriggerSamples,
int noOfPostTriggerSamples,
uint timebase,
short oversample,
out int timeIndisposedMs,
ushort segmentIndex,
ps5000BlockReady lpPs5000BlockReady,
IntPtr pVoid);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000Stop")]
public static extern short Stop(short handle);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetChannel")]
public static extern short SetChannel(
short handle,
Channel channel,
short enabled,
short dc,
Range range);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBuffers")]
public static extern short SetDataBuffers(
short handle,
Channel channel,
short[] bufferMax,
short[] bufferMin,
int bufferLth);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBuffer")]
public static extern short SetDataBuffer(
short handle,
Channel channel,
short[] buffer,
long bufferLth);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetEts")]
public static extern short SetEts(
short handle,
EtsMode mode,
short etsCycles,
short etsInterleave,
out int sampleTimePicoseconds);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelDirections")]
public static extern short SetTriggerChannelDirections(
short handle,
ThresholdDirection channelA,
ThresholdDirection channelB,
ThresholdDirection channelC,
ThresholdDirection channelD,
ThresholdDirection ext,
ThresholdDirection aux);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetTimebase")]
public static extern short GetTimebase(
short handle,
uint timebase,
int noSamples,
out int timeIntervalNanoseconds,
short oversample,
out int maxSamples,
ushort segmentIndex);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetValues")]
public static extern short GetValues(
short handle,
uint startIndex,
ref uint noOfSamples,
uint downSampleRatio,
DownSamplingMode downSampleDownSamplingMode,
ushort segmentIndex,
out short overflow);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetPulseWidthQualifier")]
public static extern short SetPulseWidthQualifier(
short handle,
PwqConditions[] conditions,
short numConditions,
ThresholdDirection direction,
uint lower,
uint upper,
PulseWidthType type);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelProperties")]
public static extern short SetTriggerChannelProperties(
short handle,
TriggerChannelProperties[] channelProperties,
short numChannelProperties,
short auxOutputEnable,
int autoTriggerMilliseconds);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerChannelConditions")]
public static extern short SetTriggerChannelConditions(
short handle,
TriggerConditions[] conditions,
short numConditions);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetTriggerDelay")]
public static extern short SetTriggerDelay(short handle, uint delay);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetUnitInfo")]
public static extern short GetUnitInfo(short handle, StringBuilder infoString, short stringLength, out short requiredSize, int info);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetSigGenBuiltIn")]
public static extern short SetSiggenBuiltIn(
short handle,
int offsetVoltage,
uint pkToPk,
SiggenWaveType siggenWaveType,
float startFrequency,
float stopFrequency,
float increment,
float dwellTime,
SiggenSweepType sweepType,
bool whiteNoise,
uint shots,
uint sweeps,
SiggenTrigType triggerType,
SiggenTrigSource triggerSource,
short extInThreshold);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetSigGenArbitrary")]
public static extern short SetSiggenArbitrary(
short handle,
int offsetVoltage,
uint pkToPk,
uint startDeltaPhase,
uint stopDeltaPhase,
uint deltaPhaseIncrement,
uint dwellCount,
short[] arbitraryWaveform,
uint arbitraryWaveformSize,
SiggenSweepType sweepType,
bool whiteNoise,
SiggenIndexMode indexMode,
uint shots,
uint sweeps,
SiggenTrigType triggerType,
SiggenTrigSource triggerSource,
short extInThreshold);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000RunStreaming")]
public static extern short RunStreaming(
short handle,
ref uint sampleInterval,
ReportedTimeUnits sampleIntervalTimeUnits,
uint maxPreTriggerSamples,
uint maxPostPreTriggerSamples,
bool autoStop,
uint downSamplingRation,
uint overviewBufferSize);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetStreamingLatestValues")]
public static extern short GetStreamingLatestValues(
short handle,
ps5000StreamingReady lpPs5000StreamingReady,
IntPtr pVoid);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetNoOfCaptures")]
public static extern short SetNoOfRapidCaptures(
short handle,
ushort nWaveforms);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000MemorySegments")]
public static extern short MemorySegments(
short handle,
ushort nSegments,
out int nMaxSamples);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000SetDataBufferBulk")]
public static extern short SetDataBuffersRapid(
short handle,
Channel channel,
short[] buffer,
int bufferLth,
ushort waveform);
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000GetValuesBulk")]
public static extern short GetValuesRapid(
short handle,
ref uint noOfSamples,
ushort fromSegmentIndex,
ushort toSegmentIndex,
short[] overflows);
#endregion
}
}

View File

@ -0,0 +1,47 @@
using System;
using System.Runtime.InteropServices;
namespace ps5000example
{
public class PinnedArray<T>
{
GCHandle _pinnedHandle;
private bool _disposed;
public PinnedArray(int arraySize) : this(new T[arraySize]) { }
public PinnedArray(T[] array)
{
_pinnedHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
}
~PinnedArray()
{
Dispose();
}
public T[] Target
{
get { return (T[])_pinnedHandle.Target; }
}
public static implicit operator T[](PinnedArray<T> a)
{
if (a == null)
return null;
else
return (T[])a._pinnedHandle.Target;
}
public void Dispose()
{
if (!_disposed)
{
_pinnedHandle.Free();
_disposed = true;
GC.SuppressFinalize(this);
}
}
}
}

View File

@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ps5000example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ps5000example")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6709ad7a-5daa-4134-b34d-ec6a3ca23a4b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC-Manifestoptionen
Wenn Sie die Ebene der Benutzerkontensteuerung für Windows ändern
möchten, ersetzen Sie den Knoten "requestedExecutionLevel" wie folgt:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Wenn Sie aus Gründen der Abwärtskompatibilität Datei- und Registrierungsvirtualisierung
verwenden möchten, löschen Sie den Knoten "requestedExecutionLevel".
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
</asmv1:assembly>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,111 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{105D08D9-97FD-43A7-AD6F-3DAD94F04644}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ps5000example</RootNamespace>
<AssemblyName>ps5000example</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkSubset>Full</TargetFrameworkSubset>
<IsWebBootstrapper>false</IsWebBootstrapper>
<SignAssembly>false</SignAssembly>
<TargetZone>LocalIntranet</TargetZone>
<GenerateManifests>false</GenerateManifests>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConsoleExample.cs" />
<Compile Include="PinnedArray.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Imports.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Properties\app.manifest" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,27 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory>
</InstallUrlHistory>
<SupportUrlHistory>
</SupportUrlHistory>
<UpdateUrlHistory>
</UpdateUrlHistory>
<BootstrapperUrlHistory>
</BootstrapperUrlHistory>
<ErrorReportUrlHistory>
</ErrorReportUrlHistory>
<FallbackCulture>de-DE</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
<ReferencePath>
</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<StartArguments>
</StartArguments>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ps5000example", "ps5000example.csproj", "{105D08D9-97FD-43A7-AD6F-3DAD94F04644}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{105D08D9-97FD-43A7-AD6F-3DAD94F04644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{105D08D9-97FD-43A7-AD6F-3DAD94F04644}.Debug|Any CPU.Build.0 = Debug|Any CPU
{105D08D9-97FD-43A7-AD6F-3DAD94F04644}.Release|Any CPU.ActiveCfg = Release|Any CPU
{105D08D9-97FD-43A7-AD6F-3DAD94F04644}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal