-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This library is intended to work with variety of JyeTech scopes. It has simple interface and can be easily added to other projects. More information below.
This library needs .NET framework v4.0 and above. So it can run under all version of Windows starting from Windows XP.
- DSO068 - fully supported
- DSO112A - partially supported (scope has bugs in serial interface)
- Other JyeScope scopes that support serial interface (DSO094, DSO082 etc.) should work in DSO068 mode but this is untested.
First you need to create SerialPortAdapter object.
SerialPortAdapter Adapter = new SerialPortAdapter(SerialPort serialPort)
Where SerialPort
is System.IO.Ports.SerialPort
port of JyeScope device.
After creating port you can create scope object. All scopes that are supported inherites from abstract JyeScope class that implement IScope interface. You can manually initialize scope as shown below:
IScope scope = new DSO.DSO068(SerialPortAdapter Adapter)
or
IScope scope = new DSO.DSO112(SerialPortAdapter Adapter)
where SerialPortAdapter
is object that use IStreamResource
interface
You can also use static Initialization class to automatically get proper scope object:
IScope scope = DSO.Initialization.GetScope(SerialPortAdapter Adapter)
JyeScope class implements IScope interface:
public interface IScope
{
event EventHandler NewDataInBuffer;
bool Destroy();
bool Connect();
bool Disconnect();
bool StartCapture();
bool StopCapture();
string ScopeName { get; }
IParameter<float> CurrentVoltageLimit { get; }
IParameter<int> DataSamplesPerDiv { get; }
List<IParameter<Config.Timebase>> AvailableTimebaseSettings { get; }
List<IParameter<Config.Coupling>> AvailableCoupleSettings { get; }
List<IParameter<Config.Slope>> AvailableTriggerSlopeSettings { get; }
List<IParameter<Config.VerticalSensitivity>> AvailableSenitivitySettings { get; }
List<IParameter<Config.TriggerMode>> AvailableTriggerModeSettings { get; }
List<IParameter<Config.RecordLength>> AvailableRecordLength { get; }
IParameter<Config.Timebase> TimeBase { get; set; }
IParameter<Config.Coupling> Couple { get; set; }
IParameter<Config.Slope> TriggerSlope { get; set; }
IParameter<Config.VerticalSensitivity> Sensitivity { get; set; }
IParameter<Config.TriggerMode> TriggerMode { get; set; }
IParameter<Config.RecordLength> RecordLength { get; set; }
int TriggerPosition { get; set; }
float TriggerLevel { get; set; }
}
where IParameter is:
public interface IParameter<T>
{
string ParameterName { get; }
string ParameterValue { get; }
string ParameterUnit { get; }
bool IsReadOnly { get; }
T GetParameter { get; }
}
All Booleans values returns true if command is executed succesfully.
This is event fired when there are new data readed in buffer.
Sender object is float[]
array. Values are in same units as CurrentVoltageLimit
.
Register to the event:
scope.NewDataInBuffer += Scope_NewDataInBuffer;
Read data from event sender:
private void Scope_NewDataInBuffer(object sender, EventArgs e)
{
float[] values = (float[])sender;
}
Scope exits from USB mode. This command frees also all resources used by scope (serial port etc.) and disposes Scope object.
scope.Destroy();
Command to connect with scope. Returns true if connection is succesfull. After invoking this command, all scope parameters and fields are filled with proper values supported by scope. Also current measurements are getting read and at this point you can receive measurements and control scope via PC.
scope.Connect();
Scope exits from USB mode and also read from serial port is halted.
scope.Disconnect();
Scope enters USB mode. To use this command scope need to be connected. This command is mainly used for start capture data from scope after invoking StopCapture command.
scope.StartCapture();
Scope exits from USB mode but read from serial port is not halted (scope is not disconnected). Useful for manually change parameters in scope. To resume capture use StartCapture command.
scope.StopCapture();
Return scope name.
string name = scope.ScopeName();
Return voltage limit for actual scope settings.
float voltageLimit = CurrentVoltageLimit.GetParameter();
Return current value of data samples per division.
int samplesPerDiv = DataSamplesPerDiv.GetParameter();
List of IParameter objects that corresponds to all available settings of that parameter supported by scope. You can select exact object from that list and set it to appropriate parameter of scope. Below is example showing select desired timebase from list and assign it to correct scope field. Every other parameter that you can choose from list work in same manner.
Scope.Timebase = AvailableTimebaseSettings[1];
Trigger position in percentage of buffer. For exapmple if you set trigger position to 50 it would mean that signal is triggered exactly in the middle of buffer
Scope.TriggerPosition = 50;
Actual trigger level of scope. Units are same as in CurretVoltageLimit
Scope.TriggerLevel = 3.17; //Volts
Throwns by Initialization
class
throw new ScopeNotRecognizedException($"Scope not recognized. Returned scope type: {(int)Ready.ScopeType}.");
Exception is being thrown when scope is not recognized but it somehow responds to standard jyeScope commands. At that point you can manually create JyeScope object (DSO068 or DSO112, but DSO068 is more generic so it's better to choose it first) and check if you can control scope.
Throwns by Initialization
class
throw new ScopeNotSupportedException($"Scope recognized but not supported. Returned scope type: {(int)Ready.ScopeType}.");
Exception is being thrown when scope is recognized but not yet implemented (this is the case of DSO082, DSO094). You can try to treat them as DSO068 scope.
Throwns by Initialization
class
throw new ScopeNotDetectedException("Scope not detected.");
Exception is thrown when object is not correctly responds while trying to establish connection or there is no response at all.
Exception is thrown when setting parameter (for example Timebase) to scope failed.
Exception is thrown when there is no acknowledgement from scope that it received command. (This exception is internal and shouldn't being thrown outside. If this situation happen this must be considered as a bug in library).
Exception is being thrown when DataFrame cannot be created from current buffer. (This exception is internal and shouldn't being thrown outside. If this situation happen this must be considered as a bug in library).