Repository: xioTechnologies/Serial-Oscilloscope
Branch: master
Commit: 217e494a0c59
Files: 24
Total size: 150.5 KB
Directory structure:
gitextract_wgem7s09/
├── .gitattributes
├── .gitignore
├── ArduinoPrintADC/
│ └── ArduinoPrintADC.ino
├── README.md
└── Serial Oscilloscope/
├── Serial Oscilloscope/
│ ├── CsvFileWriter.cs
│ ├── FormGetValue.Designer.cs
│ ├── FormGetValue.cs
│ ├── FormGetValue.resx
│ ├── FormTerminal.Designer.cs
│ ├── FormTerminal.cs
│ ├── FormTerminal.resx
│ ├── Oscilloscope/
│ │ ├── Oscilloscope.cs
│ │ └── Oscilloscope_settings.ini
│ ├── Program.cs
│ ├── Properties/
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── SampleCounter.cs
│ ├── Serial Oscilloscope.csproj
│ ├── TextBoxBuffer.cs
│ └── VisualStudio_CleanUp.bat
└── Serial Oscilloscope.sln
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
================================================
FILE: .gitignore
================================================
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover
## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
# Visual Studio profiler
*.psess
*.vsp
# ReSharper is a .NET coding add-in
_ReSharper*
# Installshield output folder
[Ee]xpress
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish
# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
############
## Windows
############
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
# Mac crap
.DS_Store
##################
# Binary archive
##################
bin-archive/
================================================
FILE: ArduinoPrintADC/ArduinoPrintADC.ino
================================================
/*
ArduinoPrintADC.ino
Author: Seb Madgwick
Sends up to all 6 analogue inputs values in ASCII as comma separated values
over serial. Each line is terminated with a carriage return character ('\r').
The number of channels is sent by sending a character value of '1' to '6' to
the Arduino.
Tested with "arduino-1.0.3" and "Arduino Uno".
*/
#include <stdlib.h> // div, div_t
void setup() {
// Enable pull-ups to avoid floating inputs
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A6, HIGH);
digitalWrite(A7, HIGH);
// Init serial
Serial.begin(115200);
}
void loop() {
static int numChans = 1;
// Received character sets number of active channels
while(Serial.available() > 0) {
char c = Serial.read();
if(c >= '1' && c <= '6') {
numChans = c - '0';
}
}
// Print ADC results for active channels
PrintInt(analogRead(A0));
if(numChans > 1) {
Serial.write(',');
PrintInt(analogRead(A1));
}
if(numChans > 2) {
Serial.write(',');
PrintInt(analogRead(A2));
}
if(numChans > 3) {
Serial.write(',');
PrintInt(analogRead(A3));
}
if(numChans > 4) {
Serial.write(',');
PrintInt(analogRead(A6));
}
if(numChans > 5) {
Serial.write(',');
PrintInt(analogRead(A7));
}
Serial.write('\r'); // print new line
}
// Fast int to ASCII conversion
void PrintInt(int i) {
static const char asciiDigits[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
div_t n;
int print = 0;
if(i < 0) {
Serial.write('-');
i = -i;
}
if(i >= 10000) {
n = div(i, 10000);
Serial.write(asciiDigits[n.quot]);
i = n.rem;
print = 1;
}
if(i >= 1000 || print) {
n = div(i, 1000);
Serial.write(asciiDigits[n.quot]);
i = n.rem;
print = 1;
}
if(i >= 100 || print) {
n = div(i, 100);
Serial.write(asciiDigits[n.quot]);
i = n.rem;
print = 1;
}
if(i >= 10 || print) {
n = div(i, 10);
Serial.write(asciiDigits[n.quot]);
i = n.rem;
}
Serial.write(asciiDigits[i]);
}
================================================
FILE: README.md
================================================
Serial-Oscilloscope
===================
Serial Oscilloscope is a Windows application that plots comma-separated variables within any incoming serial steam as channels on a real-time oscilloscope. The application also functions as a basic serial terminal, received bytes are printed to the terminal and typed characters are transmitted. The project uses Michael Bernstein's [oscilloscope library](http://www.oscilloscope-lib.com/) to plot up to 9 channels on 3 different oscilloscope with view and trigger menus.
Serial Oscilloscope is compatible with any serial stream containing comma-separated values terminated by a new-line character ("\r"). For example, "11,22,33\r" will be interpreted as values 11, 22 and 33 for channels 1, 2 and 3 respectively. The serial stream can also include non numerical characters which will be ignored. For example, "a=0.5,blue,x=3.14,t1t2t3,8\r\n" will be interpreted as values 0.5, 3.14, 123 and 8 for channels 1, 2, 3 and 4 respectively.
The source files also include an Arduino sketch to send analogue input values over serial. Up to 6 ADC channels can be enabled by sending the characters "1" to "6" to the Arduino. Enabling more channels will reduce the sample rate.
In the [YouTube video](http://www.youtube.com/watch?v=jgMG0UQ2_pc) I show the Arduino and Serial Oscilloscope being used to plot data from an [IR distance sensor]( https://www.sparkfun.com/products/242), a [triple-axis accelerometer]( https://www.sparkfun.com/products/9269) and a [microphone]( https://www.sparkfun.com/products/9964).
Precompiled binary files can be [downloaded](http://www.x-io.co.uk/serial-oscilloscope/) from the x-io website.
Version history
---------------
* **v1.0** Initial release
* **v1.1** Supports non-standard baud rates. Disable terminal feature added.
* **v1.2** Fixed memory leak and bug that prevent plotting of negative numbers.
* **v1.3** No longer ignores "." for plotting decimal values.
* **v1.4** Clear terminal menu item added
* **v1.5** Log to file tool. Remove non-numerical characters from port names.
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/CsvFileWriter.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
namespace Serial_Oscilloscope
{
class CsvFileWriter
{
/// <summary>
/// File path of CSV file.
/// </summary>
public string FilePath { get; private set; }
/// <summary>
/// Internal flag used to disable writes during file close.
/// </summary>
private bool writesEnabled;
/// <summary>
/// Stream Writer to write to file.
/// </summary>
private StreamWriter streamWriter;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="filePath"></param>
public CsvFileWriter(string filePath)
{
FilePath = filePath;
writesEnabled = true;
streamWriter = null;
}
/// <summary>
/// Close CSV file.
/// </summary>
public void CloseFile()
{
List<string> fileNames = new List<string>();
writesEnabled = false;
streamWriter.Close();
}
/// <summary>
/// Write array of values as line of CSVs in file.
/// </summary>
/// <param name="values"></param>
public void WriteCSVline(float[] values)
{
if (writesEnabled)
{
// Open file
if (streamWriter == null)
{
streamWriter = new System.IO.StreamWriter(FilePath, false);
}
// Write line
string csvLine = "";
for(int i = 0; i <values.Length; i++){
csvLine += values[i].ToString(CultureInfo.InvariantCulture);
if (i < values.Length - 1)
{
csvLine += ",";
}
}
streamWriter.WriteLine(csvLine);
}
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormGetValue.Designer.cs
================================================
namespace Serial_Oscilloscope
{
partial class FormGetValue
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxValue = new System.Windows.Forms.TextBox();
this.labelValue = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxValue
//
this.textBoxValue.Location = new System.Drawing.Point(55, 12);
this.textBoxValue.Name = "textBoxValue";
this.textBoxValue.Size = new System.Drawing.Size(100, 20);
this.textBoxValue.TabIndex = 1;
this.textBoxValue.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxValue_KeyPress);
//
// labelValue
//
this.labelValue.AutoSize = true;
this.labelValue.Location = new System.Drawing.Point(12, 15);
this.labelValue.Name = "labelValue";
this.labelValue.Size = new System.Drawing.Size(37, 13);
this.labelValue.TabIndex = 0;
this.labelValue.Text = "Value:";
//
// buttonOK
//
this.buttonOK.Location = new System.Drawing.Point(161, 10);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 2;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// FormGetValue
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(246, 48);
this.Controls.Add(this.labelValue);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.textBoxValue);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormGetValue";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Enter Value";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormGetValue_FormClosed);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBoxValue;
private System.Windows.Forms.Label labelValue;
private System.Windows.Forms.Button buttonOK;
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormGetValue.cs
================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Serial_Oscilloscope
{
/// <summary>
/// Dialog form to get text value from user.
/// </summary>
public partial class FormGetValue : Form
{
/// <summary>
/// Value entered by user.
/// </summary>
public string value { get; private set; }
/// <summary>
/// Constructor.
/// </summary>
public FormGetValue()
{
InitializeComponent();
}
/// <summary>
/// textBoxValue KeyPress event to close form when Enter key pressed.
/// </summary>
private void textBoxValue_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
Close();
}
}
/// <summary>
/// buttonOK Click event to close form.
/// </summary>
private void buttonOK_Click(object sender, EventArgs e)
{
Close();
}
/// <summary>
/// FormGetValue FormClosed event to store value entered by user.
/// </summary>
private void FormGetValue_FormClosed(object sender, FormClosedEventArgs e)
{
value = textBoxValue.Text;
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormGetValue.resx
================================================
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormTerminal.Designer.cs
================================================
namespace Serial_Oscilloscope
{
partial class FormTerminal
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItemSerialPort = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemBaudRate = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem9600 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem19200 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem38400 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem57600 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem115200 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem230400 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem460800 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem921600 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemOther = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemTerminal = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemEnabled = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemClear = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemOsciloscope = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemChannels123 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemChannels456 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemChannels789 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemHelp = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemAbout0 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemSourceCode = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSamplesReceived = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelSampleRate = new System.Windows.Forms.ToolStripStatusLabel();
this.textBox = new System.Windows.Forms.TextBox();
this.toolStripMenuItemLogToFile = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStartLogging = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStopLogging = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemSerialPort,
this.toolStripMenuItemBaudRate,
this.toolStripMenuItemTerminal,
this.toolStripMenuItemOsciloscope,
this.toolStripMenuItemLogToFile,
this.toolStripMenuItemHelp});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(584, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
//
// toolStripMenuItemSerialPort
//
this.toolStripMenuItemSerialPort.Name = "toolStripMenuItemSerialPort";
this.toolStripMenuItemSerialPort.Size = new System.Drawing.Size(72, 20);
this.toolStripMenuItemSerialPort.Text = "Serial Port";
this.toolStripMenuItemSerialPort.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStripMenuItemSerialPort_DropDownItemClicked);
//
// toolStripMenuItemBaudRate
//
this.toolStripMenuItemBaudRate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem9600,
this.toolStripMenuItem19200,
this.toolStripMenuItem38400,
this.toolStripMenuItem57600,
this.toolStripMenuItem115200,
this.toolStripMenuItem230400,
this.toolStripMenuItem460800,
this.toolStripMenuItem921600,
this.toolStripMenuItemOther});
this.toolStripMenuItemBaudRate.Name = "toolStripMenuItemBaudRate";
this.toolStripMenuItemBaudRate.Size = new System.Drawing.Size(72, 20);
this.toolStripMenuItemBaudRate.Text = "Baud Rate";
this.toolStripMenuItemBaudRate.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStripMenuItemBaudRate_DropDownItemClicked);
//
// toolStripMenuItem9600
//
this.toolStripMenuItem9600.Name = "toolStripMenuItem9600";
this.toolStripMenuItem9600.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem9600.Text = "9600";
//
// toolStripMenuItem19200
//
this.toolStripMenuItem19200.Name = "toolStripMenuItem19200";
this.toolStripMenuItem19200.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem19200.Text = "19200";
//
// toolStripMenuItem38400
//
this.toolStripMenuItem38400.Name = "toolStripMenuItem38400";
this.toolStripMenuItem38400.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem38400.Text = "38400";
//
// toolStripMenuItem57600
//
this.toolStripMenuItem57600.Name = "toolStripMenuItem57600";
this.toolStripMenuItem57600.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem57600.Text = "57600";
//
// toolStripMenuItem115200
//
this.toolStripMenuItem115200.Name = "toolStripMenuItem115200";
this.toolStripMenuItem115200.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem115200.Text = "115200";
//
// toolStripMenuItem230400
//
this.toolStripMenuItem230400.Name = "toolStripMenuItem230400";
this.toolStripMenuItem230400.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem230400.Text = "230400";
//
// toolStripMenuItem460800
//
this.toolStripMenuItem460800.Name = "toolStripMenuItem460800";
this.toolStripMenuItem460800.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem460800.Text = "460800";
//
// toolStripMenuItem921600
//
this.toolStripMenuItem921600.Name = "toolStripMenuItem921600";
this.toolStripMenuItem921600.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItem921600.Text = "921600";
//
// toolStripMenuItemOther
//
this.toolStripMenuItemOther.Name = "toolStripMenuItemOther";
this.toolStripMenuItemOther.Size = new System.Drawing.Size(110, 22);
this.toolStripMenuItemOther.Text = "Other";
//
// toolStripMenuItemTerminal
//
this.toolStripMenuItemTerminal.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemEnabled,
this.toolStripMenuItemClear});
this.toolStripMenuItemTerminal.Name = "toolStripMenuItemTerminal";
this.toolStripMenuItemTerminal.Size = new System.Drawing.Size(66, 20);
this.toolStripMenuItemTerminal.Text = "Terminal";
//
// toolStripMenuItemEnabled
//
this.toolStripMenuItemEnabled.Checked = true;
this.toolStripMenuItemEnabled.CheckOnClick = true;
this.toolStripMenuItemEnabled.CheckState = System.Windows.Forms.CheckState.Checked;
this.toolStripMenuItemEnabled.Name = "toolStripMenuItemEnabled";
this.toolStripMenuItemEnabled.Size = new System.Drawing.Size(116, 22);
this.toolStripMenuItemEnabled.Text = "Enabled";
this.toolStripMenuItemEnabled.CheckStateChanged += new System.EventHandler(this.toolStripMenuItemEnabled_CheckStateChanged);
//
// toolStripMenuItemClear
//
this.toolStripMenuItemClear.Name = "toolStripMenuItemClear";
this.toolStripMenuItemClear.Size = new System.Drawing.Size(116, 22);
this.toolStripMenuItemClear.Text = "Clear";
this.toolStripMenuItemClear.Click += new System.EventHandler(this.toolStripMenuItemClear_Click);
//
// toolStripMenuItemOsciloscope
//
this.toolStripMenuItemOsciloscope.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemChannels123,
this.toolStripMenuItemChannels456,
this.toolStripMenuItemChannels789});
this.toolStripMenuItemOsciloscope.Name = "toolStripMenuItemOsciloscope";
this.toolStripMenuItemOsciloscope.Size = new System.Drawing.Size(83, 20);
this.toolStripMenuItemOsciloscope.Text = "Osciloscope";
//
// toolStripMenuItemChannels123
//
this.toolStripMenuItemChannels123.CheckOnClick = true;
this.toolStripMenuItemChannels123.Name = "toolStripMenuItemChannels123";
this.toolStripMenuItemChannels123.Size = new System.Drawing.Size(176, 22);
this.toolStripMenuItemChannels123.Text = "Channels 1, 2 and 3";
this.toolStripMenuItemChannels123.CheckStateChanged += new System.EventHandler(this.toolStripMenuItemChannels123_CheckStateChanged);
//
// toolStripMenuItemChannels456
//
this.toolStripMenuItemChannels456.CheckOnClick = true;
this.toolStripMenuItemChannels456.Name = "toolStripMenuItemChannels456";
this.toolStripMenuItemChannels456.Size = new System.Drawing.Size(176, 22);
this.toolStripMenuItemChannels456.Text = "Channels 3, 4 and 5";
this.toolStripMenuItemChannels456.Click += new System.EventHandler(this.toolStripMenuItemChannels456_CheckStateChanged);
//
// toolStripMenuItemChannels789
//
this.toolStripMenuItemChannels789.CheckOnClick = true;
this.toolStripMenuItemChannels789.Name = "toolStripMenuItemChannels789";
this.toolStripMenuItemChannels789.Size = new System.Drawing.Size(176, 22);
this.toolStripMenuItemChannels789.Text = "Channels 7, 8 and 9";
this.toolStripMenuItemChannels789.CheckStateChanged += new System.EventHandler(this.toolStripMenuItemChannels789_CheckStateChanged);
//
// toolStripMenuItemHelp
//
this.toolStripMenuItemHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemAbout0,
this.toolStripMenuItemSourceCode});
this.toolStripMenuItemHelp.Name = "toolStripMenuItemHelp";
this.toolStripMenuItemHelp.Size = new System.Drawing.Size(44, 20);
this.toolStripMenuItemHelp.Text = "Help";
//
// toolStripMenuItemAbout0
//
this.toolStripMenuItemAbout0.Name = "toolStripMenuItemAbout0";
this.toolStripMenuItemAbout0.Size = new System.Drawing.Size(141, 22);
this.toolStripMenuItemAbout0.Text = "About";
this.toolStripMenuItemAbout0.Click += new System.EventHandler(this.toolStripMenuItemAbout_Click);
//
// toolStripMenuItemSourceCode
//
this.toolStripMenuItemSourceCode.Name = "toolStripMenuItemSourceCode";
this.toolStripMenuItemSourceCode.Size = new System.Drawing.Size(141, 22);
this.toolStripMenuItemSourceCode.Text = "Source Code";
this.toolStripMenuItemSourceCode.Click += new System.EventHandler(this.toolStripMenuItemSourceCode_Click);
//
// statusStrip
//
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSamplesReceived,
this.toolStripStatusLabelSampleRate});
this.statusStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
this.statusStrip.Location = new System.Drawing.Point(0, 342);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(584, 20);
this.statusStrip.TabIndex = 1;
this.statusStrip.Text = "statusStrip1";
//
// toolStripStatusLabelSamplesReceived
//
this.toolStripStatusLabelSamplesReceived.Name = "toolStripStatusLabelSamplesReceived";
this.toolStripStatusLabelSamplesReceived.Size = new System.Drawing.Size(203, 15);
this.toolStripStatusLabelSamplesReceived.Text = "toolStripStatusLabelSamplesReceived";
//
// toolStripStatusLabelSampleRate
//
this.toolStripStatusLabelSampleRate.Name = "toolStripStatusLabelSampleRate";
this.toolStripStatusLabelSampleRate.Size = new System.Drawing.Size(174, 15);
this.toolStripStatusLabelSampleRate.Text = "toolStripStatusLabelSampleRate";
//
// textBox
//
this.textBox.BackColor = System.Drawing.Color.Black;
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox.Font = new System.Drawing.Font("Courier New", 8.25F);
this.textBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.textBox.Location = new System.Drawing.Point(0, 24);
this.textBox.Multiline = true;
this.textBox.Name = "textBox";
this.textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox.Size = new System.Drawing.Size(584, 318);
this.textBox.TabIndex = 1;
this.textBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox_KeyPress);
//
// toolStripMenuItemLogToFile
//
this.toolStripMenuItemLogToFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemStartLogging,
this.toolStripMenuItemStopLogging});
this.toolStripMenuItemLogToFile.Name = "toolStripMenuItemLogToFile";
this.toolStripMenuItemLogToFile.Size = new System.Drawing.Size(77, 20);
this.toolStripMenuItemLogToFile.Text = "Log To File";
//
// toolStripMenuItemStartLogging
//
this.toolStripMenuItemStartLogging.Name = "toolStripMenuItemStartLogging";
this.toolStripMenuItemStartLogging.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItemStartLogging.Text = "Start Logging";
this.toolStripMenuItemStartLogging.Click += new System.EventHandler(this.toolStripMenuItemStartLogging_Click);
//
// toolStripMenuItemStopLogging
//
this.toolStripMenuItemStopLogging.Enabled = false;
this.toolStripMenuItemStopLogging.Name = "toolStripMenuItemStopLogging";
this.toolStripMenuItemStopLogging.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItemStopLogging.Text = "Stop Logging";
this.toolStripMenuItemStopLogging.Click += new System.EventHandler(this.toolStripMenuItemStopLogging_Click);
//
// FormTerminal
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 362);
this.Controls.Add(this.textBox);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormTerminal";
this.Text = "FormTerminal";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormTerminal_FormClosed);
this.Load += new System.EventHandler(this.FormTerminal_Load);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.StatusStrip statusStrip;
private System.Windows.Forms.TextBox textBox;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSerialPort;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOsciloscope;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemHelp;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSamplesReceived;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSampleRate;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBaudRate;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9600;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem19200;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem38400;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem57600;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem115200;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem230400;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem460800;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem921600;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChannels123;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChannels456;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChannels789;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAbout0;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSourceCode;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOther;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTerminal;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEnabled;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemClear;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemLogToFile;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartLogging;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStopLogging;
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormTerminal.cs
================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO.Ports;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Serial_Oscilloscope
{
public partial class FormTerminal : Form
{
#region Variables and objects
/// <summary>
/// Timer to update terminal textbox at fixed interval.
/// </summary>
private System.Windows.Forms.Timer formUpdateTimer = new System.Windows.Forms.Timer();
/// <summary>
/// SerialPort object.
/// </summary>
private SerialPort serialPort = new SerialPort();
/// <summary>
/// Sample counter to calculate performance statics.
/// </summary>
private SampleCounter sampleCounter = new SampleCounter();
/// <summary>
/// TextBoxBuffer containing text printed to terminal.
/// </summary>
private TextBoxBuffer textBoxBuffer = new TextBoxBuffer(4096);
/// <summary>
/// ASCII buffer for decoding CSVs in serial stream.
/// </summary>
private string asciiBuf = "";
/// <summary>
/// Oscilloscope channel values decoded from serial stream.
/// </summary>
private float[] channels = new float[9] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
/// <summary>
/// Oscilloscope for channels 1, 2 and 3.
/// </summary>
private Oscilloscope oscilloscope123 = Oscilloscope.CreateScope("Oscilloscope/Oscilloscope_settings.ini", "");
/// <summary>
/// Oscilloscope for channels 4, 5 and 6.
/// </summary>
private Oscilloscope oscilloscope456 = Oscilloscope.CreateScope("Oscilloscope/Oscilloscope_settings.ini", "");
/// <summary>
/// Oscilloscope for channels 7, 8 and 9.
/// </summary>
private Oscilloscope oscilloscope789 = Oscilloscope.CreateScope("Oscilloscope/Oscilloscope_settings.ini", "");
/// <summary>
/// CSV file writer.
/// </summary>
private CsvFileWriter csvFileWriter = null;
#endregion
/// <summary>
/// Constructor.
/// </summary>
public FormTerminal()
{
InitializeComponent();
}
#region Form load and close
/// <summary>
/// From load event.
/// </summary>
private void FormTerminal_Load(object sender, EventArgs e)
{
// Set form caption
this.Text = Assembly.GetExecutingAssembly().GetName().Name + " (Port Closed)";
// Set oscilloscope captions
oscilloscope123.Caption = "Channels 1, 2 and 3";
oscilloscope456.Caption = "Channels 4, 5 and 6";
oscilloscope789.Caption = "Channels 7, 8 and 9";
// Refresh serial port list
RefreshSerialPortList();
// Select default baud rate
toolStripMenuItem115200.Checked = true;
// Setup form update timer
formUpdateTimer.Interval = 50;
formUpdateTimer.Tick += new EventHandler(formUpdateTimer_Tick);
formUpdateTimer.Start();
}
/// <summary>
/// Form close event.
/// </summary>
private void FormTerminal_FormClosed(object sender, FormClosedEventArgs e)
{
CloseSerialPort();
toolStripMenuItemStopLogging.PerformClick();
}
#endregion
#region Terminal textbox
/// <summary>
/// formUpdateTimer Tick event to update terminal textbox.
/// </summary>
void formUpdateTimer_Tick(object sender, EventArgs e)
{
// Print textBoxBuffer to terminal
if (textBox.Enabled && !textBoxBuffer.IsEmpty())
{
textBox.AppendText(textBoxBuffer.Get());
if (textBox.Text.Length > textBox.MaxLength) // discard first half of textBox when number of characters exceeds length
{
textBox.Text = textBox.Text.Substring(textBox.Text.Length / 2, textBox.Text.Length - textBox.Text.Length / 2);
}
}
else
{
textBoxBuffer.Clear();
}
// Update sample counter values
toolStripStatusLabelSamplesReceived.Text = "Samples Recieved: " + sampleCounter.SamplesReceived.ToString();
toolStripStatusLabelSampleRate.Text = "Sample Rate: " + sampleCounter.SampleRate.ToString();
}
/// <summary>
/// textBox KeyPress to send character to serial port.
/// </summary>
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
SendSerialPort(e.KeyChar);
e.Handled = true; // don't print character
}
#endregion
#region Menu strip
/// <summary>
/// toolStripMenuItemSerialPort DropDownItemClicke event to select or close serial port.
/// </summary>
private void toolStripMenuItemSerialPort_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
// Close serial port and refresh list is refresh item clicked
if (e.ClickedItem.Text == "Refresh List")
{
CloseSerialPort();
RefreshSerialPortList();
return;
}
// Close serial port if checked port name clicked
if (((ToolStripMenuItem)e.ClickedItem).Checked)
{
CloseSerialPort();
((ToolStripMenuItem)e.ClickedItem).Checked = false;
return;
}
// Check only selected item
foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemSerialPort).DropDownItems)
{
toolStripMenuItem.Checked = false;
}
((ToolStripMenuItem)e.ClickedItem).Checked = true;
// Open serial port
if (!OpenSerialPort())
{
((ToolStripMenuItem)e.ClickedItem).Checked = false; // uncheck serial port if open fails
}
}
/// <summary>
/// toolStripMenuItemSerialPort DropDownItemClicke event to select baud rate.
/// </summary>
private void toolStripMenuItemBaudRate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if ((ToolStripMenuItem)e.ClickedItem == toolStripMenuItemOther)
{
FormGetValue formGetValue = new FormGetValue();
formGetValue.ShowDialog();
((ToolStripMenuItem)e.ClickedItem).Text = "Other (" + formGetValue.value + ")";
((ToolStripMenuItem)e.ClickedItem).Checked = false;
}
// Do nothing if baud already selected
if (((ToolStripMenuItem)e.ClickedItem).Checked)
{
return;
}
// Check only selected item
foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemBaudRate).DropDownItems)
{
toolStripMenuItem.Checked = false;
}
((ToolStripMenuItem)e.ClickedItem).Checked = true;
// Open serial port
if (!OpenSerialPort())
{
RefreshSerialPortList(); // refresh port list if open fails, this also ensures port object is closed
}
}
/// <summary>
/// toolStripMenuItemEnabled CheckStateChanged event to toggle enabled state of the terminal text box.
/// </summary>
private void toolStripMenuItemEnabled_CheckStateChanged(object sender, EventArgs e)
{
if (toolStripMenuItemEnabled.Checked)
{
textBox.Enabled = true;
}
else
{
textBox.Enabled = false;
}
}
/// <summary>
/// toolStripMenuItemClear Click event to clear terminal text box.
/// </summary>
private void toolStripMenuItemClear_Click(object sender, EventArgs e)
{
textBox.Text = "";
}
/// <summary>
/// toolStripMenuItemChannels123 CheckStateChanged event to toggle show state of oscilloscope form.
/// </summary>
private void toolStripMenuItemChannels123_CheckStateChanged(object sender, EventArgs e)
{
if (toolStripMenuItemChannels123.Checked)
{
oscilloscope123.ShowScope();
}
else
{
oscilloscope123.HideScope();
}
}
/// <summary>
/// toolStripMenuItemChannels456 CheckStateChanged event to toggle show state of oscilloscope form.
/// </summary>
private void toolStripMenuItemChannels456_CheckStateChanged(object sender, EventArgs e)
{
if (toolStripMenuItemChannels456.Checked)
{
oscilloscope456.ShowScope();
}
else
{
oscilloscope456.HideScope();
}
}
/// <summary>
/// toolStripMenuItemChannels789 CheckStateChanged event to toggle show state of oscilloscope form.
/// </summary>
private void toolStripMenuItemChannels789_CheckStateChanged(object sender, EventArgs e)
{
if (toolStripMenuItemChannels789.Checked)
{
oscilloscope789.ShowScope();
}
else
{
oscilloscope789.HideScope();
}
}
/// <summary>
/// toolStripMenuItemStartLogging Click event to select file location and start logging
/// </summary>
private void toolStripMenuItemStartLogging_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "Select File Location";
saveFileDialog.Filter = "CSV files (*.csv)|*.csv";
saveFileDialog.OverwritePrompt = false;
saveFileDialog.FileName = "LoggedData";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
csvFileWriter = new CsvFileWriter(saveFileDialog.FileName.ToString());
toolStripMenuItemStartLogging.Enabled = false;
toolStripMenuItemStopLogging.Enabled = true;
}
}
/// <summary>
/// toolStripMenuItemStopLogging Click event to stop logging and close file
/// </summary>
private void toolStripMenuItemStopLogging_Click(object sender, EventArgs e)
{
if (csvFileWriter != null)
{
csvFileWriter.CloseFile();
csvFileWriter = null;
}
toolStripMenuItemStartLogging.Enabled = true;
toolStripMenuItemStopLogging.Enabled = false;
}
/// <summary>
/// toolStripMenuItemAbout Click event to display version details.
/// </summary>
private void toolStripMenuItemAbout_Click(object sender, EventArgs e)
{
MessageBox.Show(Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString(), "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// toolStripMenuItemSourceCode Click event to open web browser.
/// </summary>
private void toolStripMenuItemSourceCode_Click(object sender, EventArgs e)
{
try
{
System.Diagnostics.Process.Start("https://github.com/xioTechnologies/Serial-Oscilloscope");
}
catch { }
}
#endregion
#region Serial port
/// <summary>
/// Updates toolStripMenuItemSerialPort DropDownItems to include all available serial port.
/// </summary>
private void RefreshSerialPortList()
{
ToolStripItemCollection toolStripItemCollection = toolStripMenuItemSerialPort.DropDownItems;
toolStripItemCollection.Clear();
toolStripItemCollection.Add("Refresh List");
foreach (string portName in System.IO.Ports.SerialPort.GetPortNames())
{
toolStripItemCollection.Add("COM" + Regex.Replace(portName.Substring("COM".Length, portName.Length - "COM".Length), "[^.0-9]", "\0"));
}
}
/// <summary>
/// Opens serial port. Displays error in MessageBox if unsuccessful.
/// </summary>
/// <returns>
/// true if successful.
/// </returns>
private bool OpenSerialPort()
{
string portName = null;
int baudRate = 0;
// Get selected port name
foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemSerialPort).DropDownItems)
{
if (toolStripMenuItem.Checked)
{
portName = toolStripMenuItem.Text;
break;
}
}
if (portName == null)
{
return false;
}
// Get selected baud rate
foreach (ToolStripMenuItem toolStripMenuItem in ((ToolStripMenuItem)toolStripMenuItemBaudRate).DropDownItems)
{
if (toolStripMenuItem.Checked)
{
try
{
baudRate = Convert.ToInt32((new Regex("[^0-9]")).Replace(toolStripMenuItem.Text, "")); // convert text to int ignoring all non-numerical characters
}
catch
{
baudRate = 0;
}
break;
}
}
// Open serial port
CloseSerialPort();
try
{
serialPort = new SerialPort(portName, baudRate, Parity.None, 8, StopBits.One);
serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
serialPort.Open();
this.Text = Assembly.GetExecutingAssembly().GetName().Name + " (" + portName + ", " + baudRate.ToString() + ")";
sampleCounter.Reset();
return true;
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return false;
}
}
/// <summary>
/// Closes serial port.
/// </summary>
private void CloseSerialPort()
{
try
{
serialPort.Close();
}
catch { }
this.Text = Assembly.GetExecutingAssembly().GetName().Name + " (Port Closed)";
}
/// <summary>
/// Sends character to serial port.
/// </summary>
/// <param name="c">
/// Character to send to serial port.
/// </param>
private void SendSerialPort(char c)
{
try
{
serialPort.Write(new char[] { c }, 0, 1);
}
catch { }
}
/// <summary>
/// serialPort DataReceived event to print characters to terminal and process bytes through serialDecoder.
/// </summary>
private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
// Get bytes from serial port
int bytesToRead = serialPort.BytesToRead;
byte[] readBuffer = new byte[bytesToRead];
serialPort.Read(readBuffer, 0, bytesToRead);
// Process each byte
foreach (byte b in readBuffer)
{
// Parse character to textBoxBuffer
if ((b < 0x20 || b > 0x7F) && b != '\r') // replace non-printable characters with '.'
{
textBoxBuffer.Put(".");
}
else if (b == '\r') // replace carriage return with '↵' and valid new line
{
textBoxBuffer.Put("↵" + Environment.NewLine);
}
else
{
textBoxBuffer.Put(((char)b).ToString());
}
// Extract CSVs and parse to Oscilloscope
if (asciiBuf.Length > 128)
{
asciiBuf = ""; // prevent memory leak
}
if ((char)b == '\r')
{
// Split string to comma separated variables (ignore non numerical characters)
string[] csvs = (new Regex(@"[^0-9\-,.]")).Replace(asciiBuf, "").Split(',');
// Extract each CSV as oscilloscope channel
int channelIndex = 0;
foreach (string csv in csvs)
{
if (csv != "" && channelIndex < 9)
{
channels[channelIndex++] = float.Parse(csv, CultureInfo.InvariantCulture);
}
}
// Update oscilloscopes if channel values changed
if (channelIndex > 0)
{
oscilloscope123.AddScopeData(channels[0], channels[1], channels[2]);
oscilloscope456.AddScopeData(channels[3], channels[4], channels[5]);
oscilloscope789.AddScopeData(channels[6], channels[7], channels[8]);
sampleCounter.Increment();
}
// Write to file if enabled
if (csvFileWriter != null)
{
csvFileWriter.WriteCSVline(channels);
}
// Reset buffer
asciiBuf = "";
}
else
{
asciiBuf += (char)b;
}
}
}
catch { }
}
#endregion
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/FormTerminal.resx
================================================
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>79</value>
</metadata>
</root>
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Oscilloscope/Oscilloscope.cs
================================================
using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
/*
* C# Wrapper around the Oscilloscope DLL
*
* (C)2006 Dustin Spicuzza
*
* This library interface is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; only
* version 2.1 of the License.
*
* Some comments/function declarations taken from the original
* "oscilloscope-lib" documentation.
*
* Oscilloscope Properties added by: Frank Greenlee, April, 2010
* MessageBoxes replaced with Exceptions by: Sebastian Madgwick, February, 2011
* "Osc_DLL.dll" replaced with Osc_DLL_path by: Sebastian Madgwick, May, 2011
*
*/
/************************************************************************
*
* Quick Reference: Publicly Available Methods and Properties
*
*************************************************************************
*************************************************************************
*
* Public Methods
*
*************************************************************************
Method: CreateScope()
Creates an instance of the Oscilloscope. The Initialization file
is not used in this version of the method.
Lifetime: static
Parameters: void
Return: reference of type Oscilloscope to the instance if successful
null if not successful
*************************************************************************
Method: CreateScope ( string, string )
Creates an instance of the Oscilloscope. The Initialization file
is used (if found) in this version of the method.
Lifetime: static
Parameters: string: Filenmae of intialization file
string: Filename suffix
Return: reference of type Oscilloscope to the instance if successful
null if not successful
*************************************************************************
Method: ShowScope ()
Displays the Oscilloscope. After the instance is created it will not
become visible until this method is called.
Lifetime: instance
Parameters: void
Return: void
*************************************************************************
Method: HideScope ()
Makes the Oscilloscope invisible non-destructively.
Lifetime: instance
Parameters: void
Return: void
*************************************************************************
Method: ClearScope ()
Clears the Oscilloscope's buffers.
Lifetime: instance
Parameters: void
Return: void
*************************************************************************
Method: AddScopeData ( double, double, double )
Adds one new data point to each of the three traces.
Lifetime: instance
Parameters: double: 3X New data points, one for each trace.
Return: void
*************************************************************************
Method: AddExternalScopeData ( double )
Sends a new data point to the external trigger input, which is used
for triggering when the Oscilloscope's Trigger Source is set to
EXTERNAL_TRIG.
Lifetime: instance
Parameters: double: External Trigger Data Point
Return: void
*************************************************************************
Method: UpdateScope ()
Quickly updates the Oscilloscope traces, for use when there is a gap
in the dta stream.
Lifetime: instance
Parameters: void
Return: void
*************************************************************************
Method: Dispose ()
Releases the Oscilloscope resources back to the system and removes
the Oscilloscope from the display. Also sets the _disposed flag to
true. Any future calls or property accesses will be ignored and
will set a SCOPE_DISPOSED_ERROR into LastError.
Lifetime: instance
Parameters: void
Return: void
*************************************************************************
*
* Public Properties -- all of these are class instance members.
*
*************************************************************************
Property: LastError
An application can check this to see if there has been an
error, even when error message displays are turned off.
If it is non-zero (!=NO_ERROR), there has been an error
and the value refers to one of the listed error constants.
When setting LastError the value is ignored and LastError
is set to its defaul value, NO_ERROR. The application
should do this after finding a non-zero error value, as it is
not done automatically; the error code value will persist
until it is manually reset.
Value: int, equal to one of the error constants
Access: Read/Write (any write resets LastError to NO_ERROR
Default: 0 (NO_ERROR)
**************************************************************************
Property: ErrorMessagesOn
If set to "true", a throw new Exception will appear when there is an error.
When debugging is completed it may be desirable to set ErrorMessagesOn
to "false." The LastError variable will work regardless of this
setting and may be checked even when there is no instance of the
Oscilloscope class.
Value: bool
Access: Read/Write
Default: true
**************************************************************************
Property: ControlPanelVisible
Displays or hides the control panel at the bottom of the
oscilloscope display.
Value: bool
Access: Read/Write
Default: true (also can be define in the intialization
file, if it is used)
**************************************************************************
Property: Left
Sets the horizontal position of the oscilloscope on the screen,
specified as the number of pixels from the left edge of the screen
to the left edge of the oscilloscope form.
Value: int, Range: 0-Current Screen Width
Access: Read/Write
Default: Somewhere on the Screen (also can be defined in the
intialization file, if it is used)
**************************************************************************
Property: Top
Sets the vertical position of the oscilloscope on the screen,
specified as the number of pixels from the top edge of the screen
to the top edge of the oscilloscope form.
Value: int, Range: 0-Current Screen Height
Access: Read/Write
Default: Somewhere on the Screen (also can be defined in
the intialization file, if it is used)
**************************************************************************
Property: Width
Sets the Width of the oscilloscope form in pixels.
Value: int, Range: 40-Current Screen Width
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: Height
Sets the Height of the oscilloscope form in pixels.
Value: int, Range: 40-Current Screen Height
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if used)
**************************************************************************
Property: CellSize
Sets the size of a grid cell in pixels; sets both height
and width of grid cells to this single property setting.
Value: int, Range: 10-150
Access: Read/Write
Default: 40 (also can be defined in the initialization file, if it is
used)
**************************************************************************
Property: SamplesPerGridCell
Sets the number of samples per grid cell on the horizontal (time) axis.
The value will be adjusted to closest valid number (see the DLL
documentation).
WARNING: if this setting is too low and the data stream is too fast
a buffer overrun can be caused, which will have no indicator other
than the DLL locking up.
Value: double, Range 0.10000-20,000
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: Caption
Sets the caption at the top of the oscilloscope form.
Value: string, Range 0-250 characters
Access: Write Only
Default: "Oscilloscope" (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: AmplitudeScale1
Sets the Amplitude Scale of Trace 1's grid divisions, in binary steps/grid
cell. The value will be adjusted to closest valid number (see the DLL
documentation).
Value: double, Range: 0.00001-100,000.00000
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: AmplitudeScale2
Sets the Amplitude Scale Trace 2's grid divisions, in binary steps/grid
cell. The value will be adjusted to closest valid number (see the DLL
documentation).
Value: double, Range: 0.00001-100,000.00000
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: AmplitudeScale3
Sets the Amplitude Scale Trace 3's grid divisions, in binary steps/grid
cell. The value will be adjusted to closest valid number (see the DLL
documentation).
Value: double, Range: 0.00001-100,000.00000
Access: Read/Write
Default: (->fill this in) (also can be defined in the
initialization file, if it is used)
**************************************************************************
Property: VerticalOffset1
Sets the Vertical Offset of Trace 1, in units of of Trace 1's
AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file,
if it is used)
**************************************************************************
Property: VerticalOffset2
Sets the Vertical Offset of Trace 2, in units of of Trace 2's
AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file,
if it is used)
**************************************************************************
Property: VerticalOffset3
Sets the Vertical Offset of Trace 3, in units of of Trace 3's
AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file,
if it is used)
**************************************************************************
Property: TriggerLevel1
Sets the Trigger Offset of Trace 1, in units of Trace 1's AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file, if
it is used)
**************************************************************************
Property: TriggerLevel2
Sets the Trigger Offset of Trace 2, in units of Trace 2's AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file, if
it is used)
**************************************************************************
Property: TriggerLevel3
Sets the Trigger Offset of Trace 3, in units of Trace 3's AmplitudeScale.
Value: double, Range: -1,000,000.00000-+1,000,000.00000
Access: Read/Write
Default: 0.00000 (also can be defined in the initialization file, if
it is used)
**************************************************************************
Property: TriggerSource
Sets the Oscilloscope's Trigger Source. The constants TRACE1_TRIG,
TRACE2_TRIG, TRACE3_TRIG and EXTERNAL_TRIG are provided for conenience.
Value: int, Range 0-3 (TRACE1_TRIG-EXTERNAL_TRIG)
Access: Read/Write
Default: TRACE1_TRIG (also can be defined in the initialization file, if
it is used)
**************************************************************************
Property: TriggerEdge
Sets the Trigger Edge Detection Mode. Any valid negative int sets it
Negative Edge Triggered, any valid positive int sets it Positive Edge
Triggered, and 0 set it to disabled. The constants FALLING_EDGE_TRIG,
RISING_EDGE_TRIG and DISABLED_TRIG are provided for convenience.
Value: int, Range: see above
Access: Read/Write
Default: DISABLED_TRIG (also can be defined in the initialization file,
if it is used)
**************************************************************************
Property: TriggerDelay
Sets the Trigger Delay, in number of samples (see DLL Documentation).
Value: int, RangeL 0-Any valid positive int value
Access: Read/Write
Default: 0 (also can be defined in the initialization file, if it is
used)
**************************************************************************
Property: TraceDisplayWidth
Returns the width of the current trace display area in pixels.
Value: int
Access: Read Only
Default: N/A
**************************************************************************
Property: TraceDisplayHeight
Returns the height of the current trace display area in pixels.
Value: int
Access: Read Only
Default: N/A
**************************************************************************
*
* Miscellaneous Public Resources
*
**************************************************************************
--> Trigger Source Constants (int's):
TRACE1_TRIG = 0;
TRACE2_TRIG = 1;
TRACE3_TRIG = 2;
EXTERNAL_TRIG = 3;
--> Trigger Mode Constants (int's):
FALLING_EDGE_TRIG = -1;
RISING_EDGE_TRIG = 1;
DISABLED_TRIG = 0;
--> Error Constants (int's):
NO_ERROR = 0;
SCOPE_CREATION_ERROR = 1;
SCOPE_HANDLE_ERROR = 2;
SCOPE_DISPOSED_ERROR = 3;
LEFT_RANGE_ERROR = 4;
TOP_RANGE_ERROR = 5;
WIDTH_RANGE_ERROR = 6;
HEIGHT_RANGE_ERROR = 7;
CELLSIZE_RANGE_ERROR = 8;
SAMPLESPERGRIDCELL_RANGE_ERROR = 9;
CAPTIONSIZE_ERROR = 10;
CELLAMPLITUDESCALE_RANGE_ERROR = 11;
VERTICALOFFSET_RANGE_ERROR = 12;
TRIGGERLEVEL_RANGE_ERROR = 13;
TRIGGERSOURCE_RANGE_ERROR = 14;
TRIGGERDELAY_RANGE_ERROR = 15;
SCOPE_TRIGGERSOURCE_ERROR = 16;
SCOPE_TRIGGEREDGE_ERROR = 17;
SCOPE_NOT_VISIBLE = 18;
**************************************************************************/
// Begin Oscilloscope DLL Wrapper Implementation
namespace Serial_Oscilloscope
{
sealed class Oscilloscope : IDisposable
{
const string Osc_DLL_path = "Oscilloscope/Osc_DLL.dll";
#region External declarations
/******************************************
* *
* Import Essential Oscilloscope Functions *
* *
******************************************/
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int AtOpenLib
(int Prm);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeCreate(
int Prm,
[MarshalAs(UnmanagedType.LPStr)] StringBuilder P_IniName,
[MarshalAs(UnmanagedType.LPStr)] StringBuilder P_IniSuffix);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeDestroy
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeShow
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeHide
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeCleanBuffers
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ShowNext
(int ScopeHandle,
double[] PArrDbl);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ExternalNext
(int ScopeHandle,
ref double PDbl);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int QuickUpDate
(int ScopeHandle);
/******************************************
* *
* Import Oscilloscope Attribute Controls *
* *
* ****************************************
*
* Import Set functions:
*/
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetPanelState
(int ScopeHandle, int VizState);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetFormPos
(int ScopeHandle, int FormLeft, int FormTop);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetFormSize
(int ScopeHandle, int FormWidth, int FormHeight);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetCellPixelSize
(int ScopeHandle, int CellPixelSize);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetCellSampleSize
(int ScopeHandle, double CellSampleSize);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetCaption
(int ScopeHandle,
[MarshalAs(UnmanagedType.LPStr)] StringBuilder P_ZeroTermStr);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetAmpScale
(int ScopeHandle, int BeamNum, double AmpScale);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetAmpOffset
(int ScopeHandle, int BeamNum, double AmpOffset);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetTriggerLevel
(int ScopeHandle, int BeamNum, double TriggerLevel);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetTriggerSourse
(int ScopeHandle, int BeamNum);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetActiveTriggerEdge
(int ScopeHandle, int TriggerEdge);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeSetTrigHoldOffSmplsNum
(int ScopeHandle, int HoldOffVsl);
/*
* Import Get functions:
*/
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetFormLeft
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetFormTop
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetFormWidth
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetFormHeight
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetScreenWidth
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetScreenHeight
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetCellPixelSize
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern double ScopeGetCellSampleSize
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetPanelState
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern double ScopeGetAmpScale
(int ScopeHandle, int Beam);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern double ScopeGetAmpOffset
(int ScopeHandle, int Beam);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern double ScopeGetTriggerLevel
(int ScopeHandle, int Beam);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetTriggerSourse
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetActiveTriggerEdge
(int ScopeHandle);
[DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
private static extern int ScopeGetTrigHoldOffSmplsNum
(int ScopeHandle);
#endregion
// Property Control Constants (provided for convenience)
//
// Trigger Source Constants
public const int TRACE1_TRIG = 0, TRACE2_TRIG = 1, TRACE3_TRIG = 2, EXTERNAL_TRIG = 3;
//
// Trigger Type Constants
public const int FALLING_EDGE_TRIG = -1, RISING_EDGE_TRIG = 1, DISABLED_TRIG = 0;
/// <summary>
/// Error Constants
/// </summary>
public const int NO_ERROR = 0;
public const int SCOPE_CREATION_ERROR = 1;
public const int SCOPE_HANDLE_ERROR = 2;
public const int SCOPE_DISPOSED_ERROR = 3;
public const int LEFT_RANGE_ERROR = 4;
public const int TOP_RANGE_ERROR = 5;
public const int WIDTH_RANGE_ERROR = 6;
public const int HEIGHT_RANGE_ERROR = 7;
public const int CELLSIZE_RANGE_ERROR = 8;
public const int SAMPLESPERGRIDCELL_RANGE_ERROR = 9;
public const int CAPTIONSIZE_ERROR = 10;
public const int CELLAMPLITUDESCALE_RANGE_ERROR = 11;
public const int VERTICALOFFSET_RANGE_ERROR = 12;
public const int TRIGGERLEVEL_RANGE_ERROR = 13;
public const int TRIGGERSOURCE_RANGE_ERROR = 14;
public const int TRIGGERDELAY_RANGE_ERROR = 15;
public const int SCOPE_TRIGGERSOURCE_ERROR = 16;
public const int SCOPE_TRIGGEREDGE_ERROR = 17;
public const int SCOPE_NOT_VISIBLE = 18;
#region Static members
static bool initialized = false;
/// <summary>
/// Creates a new Oscilloscope. Returns the object if successful,
/// otherwise returns null. Generally, if it returns null then
/// it cannot find the correct DLL to load
/// </summary>
/// <returns>Oscilloscope instance</returns>
public static Oscilloscope CreateScope()
{
return CreateScope("NO_INI_FILE", "NON");
}
/// <summary>
/// Creates a new Oscilloscope. Returns the object if successful,
/// otherwise returns null. Generally, if it returns null then
/// it cannot find the correct DLL to load
/// </summary>
/// <param name="IniName">Name of INI file with scope settings</param>
/// <param name="IniSuffix">Section name suffix (see manual)</param>
/// <returns>Oscilloscope instance</returns>
public static Oscilloscope CreateScope(string IniName, string IniSuffix)
{
int handle;
_Scope_Visible = false;
try
{
if (!initialized)
{
// initialize
if (AtOpenLib(0) == -1)
{
ShowError(SCOPE_CREATION_ERROR);
return null;
}
// Set to true
initialized = true;
}
}
catch
{
// Return the Error
ShowError(SCOPE_CREATION_ERROR);
return null;
}
// Create the Oscilloscope Instance
handle = ScopeCreate(0, new StringBuilder(IniName), new StringBuilder(IniSuffix));
if (handle != 0)
{
return new Oscilloscope(handle);
}
ShowError(SCOPE_CREATION_ERROR);
return null;
}
#endregion
private int scopeHandle;
private bool _disposed = false;
// Class Constructors
private Oscilloscope()
{
}
private Oscilloscope(int handle)
{
scopeHandle = handle;
}
// Class Destructor
~Oscilloscope()
{
Dispose();
}
/// <summary>
/// Shows the scope.
/// </summary>
public void ShowScope()
{
if (!_disposed)
{
_Scope_Visible = true;
ScopeShow(scopeHandle);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/// <summary>
/// Hides the scope from view
/// </summary>
public void HideScope()
{
if (!_disposed)
{
_Scope_Visible = false;
ScopeHide(scopeHandle);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/// <summary>
/// Clears the buffer of the scope
/// </summary>
public void ClearScope()
{
if (!_disposed)
ScopeCleanBuffers(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/// <summary>
/// Add data to the scope traces.
/// </summary>
/// <param name="beam1">Data for first beam</param>
/// <param name="beam2">Data for second beam</param>
/// <param name="beam3">Data for third beam</param>
public void AddScopeData(double beam1, double beam2, double beam3)
{
if (!_disposed)
{
double[] PArrDbl = new double[3];
PArrDbl[0] = beam1;
PArrDbl[1] = beam2;
PArrDbl[2] = beam3;
ShowNext(scopeHandle, PArrDbl);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/// <summary>
/// Add data to the 'external' trigger function signal. This value is used
/// when TriggerSource == EXTERNAL_TRIG.
/// </summary>
/// <param name="data">The data</param>
public void AddExternalScopeData(double data)
{
if (!_disposed)
ExternalNext(scopeHandle, ref data);
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/// <summary>
/// Quickly refreshes screen of oscilloscope. Calling this function is
/// not usually required. Recommended for using in situations when
/// intensive data stream is going into oscilloscope
/// </summary>
public void UpdateScope()
{
if (!_disposed)
{
QuickUpDate(scopeHandle);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
/*****************************************
* *
* C# wrapper for Oscilloscope Properties *
* *
*****************************************/
private static bool _ErrorMessagesOn = true;
private static int _LastError = NO_ERROR;
private static bool _Scope_Visible = false;
/// <summary>
/// Property: LastError
///
/// An application can check this to see if there has been an
/// error, even when error message displays are turned off.
/// If it is non-zero (!=NO_ERROR), there has been an error
/// and the value refers to one of the listed error constants.
///
/// When setting LastError the value is ignored and LastError
/// is set to its defaul value, NO_ERROR. The application
/// should do this after finding an error value here, as it is
/// not done automatically; the error code value will persist
/// until it is manually reset.
///
/// Value: int, equal to one of the error constants
/// Access: Read/Write (any write resets LastError to NO_ERROR
/// Default: 0 (NO_ERROR)
/// </summary>
public int LastError
{
set { _LastError = NO_ERROR; }
get { return _LastError; }
}
/// <summary>
/// Property: ErrorMessagesOn
///
/// If ErrorMessagesOn is set to "true", a throw new Exception will appear
/// when there is an error. When debugging is completed it may be
/// desirable to set ErrorMessagesOn to "false."
///
/// Value: bool
/// Access: Read/Write
/// Default: true
/// </summary>
public bool ErrorMessagesOn
{
set { _ErrorMessagesOn = value; }
get { return _ErrorMessagesOn; }
}
/// <summary>
/// Property: ControlPanelVisible
///
/// Displays or hides the control panel at the bottom of the
/// oscilloscope display
///
/// Value: bool
/// Access: Read/Write
/// Default: true (also can be define in the intialization
/// file, if used)
/// </summary>
public bool ControlPanelVisible
{
set
{
int Ret = 0;
if (!_disposed)
{
if (value)
Ret = ScopeSetPanelState(scopeHandle, 1);
else
Ret = ScopeSetPanelState(scopeHandle, 0);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
get
{
if (!_disposed)
{
if (ScopeGetPanelState(scopeHandle) == 1)
return false;
else
return true;
}
else
ShowError(SCOPE_DISPOSED_ERROR);
return false;
}
}
/// <summary>
/// Property: Left
///
/// Sets the horizontal position of the oscilloscope on the screen,
/// specified as the number of pixels from the left edge of the screen
/// to the left edge of the oscilloscope form.
///
/// Value: int, Range: 0-Current Screen Width
/// Access: Read/Write
/// Default: Somewhere on the Screen (also can be defined in the
/// intialization file, if used)
/// </summary>
public int Left
{
set
{
int MonitorWidth, MonitorHeight;
GetMonitorDimensions(out MonitorWidth, out MonitorHeight);
if ((value < 0) || (value > MonitorWidth))
ShowError(LEFT_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = 0, Top;
Top = ScopeGetFormTop(scopeHandle);
Ret = ScopeSetFormPos(scopeHandle, value, Top);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetFormLeft(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: Top
///
/// Sets the vertical position of the oscilloscope on the screen,
/// specified as the number of pixels from the top edge of the screen
/// to the top edge of the oscilloscope form.
///
/// Value: int, Range: 0-Current Screen Height
/// Access: Read/Write
/// Default: Somewhere on the Screen (also can be defined in
/// the intialization file, if used)
/// </summary>
public int Top
{
set
{
int MonitorWidth, MonitorHeight;
GetMonitorDimensions(out MonitorWidth, out MonitorHeight);
if ((value < 0) || (value > MonitorHeight))
ShowError(TOP_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = 0, Left;
Left = ScopeGetFormLeft(scopeHandle);
Ret = ScopeSetFormPos(scopeHandle, Left, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetFormTop(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: Width
///
/// Sets the Width of the oscilloscope form in pixels.
///
/// Value: int, Range: 40-Current Screen Width
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public int Width
{
set
{
int MonitorWidth, MonitorHeight;
GetMonitorDimensions(out MonitorWidth, out MonitorHeight);
if ((value < 40) || (value > MonitorWidth))
ShowError(WIDTH_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = 0, Height;
Height = ScopeGetFormHeight(scopeHandle);
Ret = ScopeSetFormSize(scopeHandle, value, Height);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetFormWidth(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: Height
///
/// Sets the Height of the oscilloscope form in pixels.
///
/// Value: int, Range: 40-Current Screen Height
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public int Height
{
set
{
int MonitorWidth, MonitorHeight;
GetMonitorDimensions(out MonitorWidth, out MonitorHeight);
if ((value < 40) || (value > MonitorHeight))
ShowError(HEIGHT_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = 0, Width;
Width = ScopeGetFormWidth(scopeHandle);
Ret = ScopeSetFormSize(scopeHandle, Width, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetFormHeight(scopeHandle);
else
ShowError(SCOPE_HANDLE_ERROR);
return 0;
}
}
/// <summary>
/// Property: CellSize
///
/// Sets the size of a grid cell in pixels; sets both height
/// and width of cells to the single parameter setting.
///
/// Value: int, Range: 10-150
/// Access: Read/Write
/// Default: 40 (also can be defined in the initialization file, if used)
/// </summary>
public int CellSize
{
set
{
if ((value < 10) || (value > 150))
ShowError(CELLSIZE_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetCellPixelSize(scopeHandle, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetCellPixelSize(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: SamplesPerGridCell
///
/// Sets the number of samples per grid cell on the horizontal (time) axis.
/// The value will be adjusted to closest valid number (see the DLL
/// documentation).
///
/// WARNING: if this setting is too low and the data stream is too fast
/// a buffer overrun can be caused, which will have no indicator other
/// than the DLL locking up.
///
/// Value: double, Range 0.10000-20,000
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public double SamplesPerGridCell
{
set
{
if ((value < 0.10000) || (value > 20000.00000))
ShowError(SAMPLESPERGRIDCELL_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetCellSampleSize(scopeHandle, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetCellSampleSize(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: Caption
///
/// Sets the caption at the top of the oscilloscope form.
///
/// Value: string, Range 0-250 characters
/// Access: Write Only
/// Default: "Oscilloscope" (also can be defined in the
/// initialization file, if used)
/// </summary>
public string Caption
{
set
{
if (value.Length > 250)
ShowError(CAPTIONSIZE_ERROR);
else
{
if (!_disposed)
{
int Ret = ScopeSetCaption(scopeHandle, new StringBuilder(value));
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
}
/// <summary>
/// Property: AmplitudeScale1
///
/// Sets the Amplitude Scale of Trace 1's grid divisions, in binary steps/grid cell
/// The value will be adjusted to closest valid number (see the DLL documentation)
///
/// Value: double, Range: 0.00001-100,000.00000
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public double AmplitudeScale1
{
set
{
if ((value < 0.00001) || (value > 100000.00000))
ShowError(CELLAMPLITUDESCALE_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpScale(scopeHandle, 0, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpScale(scopeHandle, 0);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: AmplitudeScale2
///
/// Sets the Amplitude Scale Trace 2's grid divisions, in binary steps/grid cell
/// The value will be adjusted to closest valid number (see the DLL documentation)
///
/// Value: double, Range: 0.00001-100,000.00000
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public double AmplitudeScale2
{
set
{
if ((value < 0.00001) || (value > 100000.00000))
ShowError(CELLAMPLITUDESCALE_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpScale(scopeHandle, 1, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpScale(scopeHandle, 1);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: AmplitudeScale3
///
/// Sets the Amplitude Scale of Trace 3's grid divisions, in binary steps/grid cell
/// The value will be adjusted to closest valid number (see the DLL documentation)
///
/// Value: double, Range: 0.00001-100,000.00000
/// Access: Read/Write
/// Default: (->fill this in) (also can be defined in the
/// initialization file, if used)
/// </summary>
public double AmplitudeScale3
{
set
{
if ((value < 0.00001) || (value > 100000.00000))
ShowError(CELLAMPLITUDESCALE_RANGE_ERROR, 0);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpScale(scopeHandle, 2, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpScale(scopeHandle, 2);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: VerticalOffset1
///
/// Sets the Vertical Offset of Trace 1, in units of of Trace 1's
/// AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double VerticalOffset1
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(VERTICALOFFSET_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpOffset(scopeHandle, 0, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpOffset(scopeHandle, 0);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: VerticalOffset2
///
/// Sets the Vertical Offset of Trace 2, in units of of Trace 2's
/// AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double VerticalOffset2
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(VERTICALOFFSET_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpOffset(scopeHandle, 1, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpOffset(scopeHandle, 1);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: VerticalOffset3
///
/// Sets the Vertical Offset of Trace 3, in units of of Trace 3's
/// AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double VerticalOffset3
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(VERTICALOFFSET_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetAmpOffset(scopeHandle, 2, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetAmpOffset(scopeHandle, 2);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: TriggerLevel1
///
/// Sets the Trigger Offset Trace 1, in units of Trace 1's AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double TriggerLevel1
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(TRIGGERLEVEL_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetTriggerLevel(scopeHandle, 0, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetTriggerLevel(scopeHandle, 0);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: TriggerLevel2
///
/// Sets the Trigger Offset Trace 2, in units of Trace 2's AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double TriggerLevel2
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(TRIGGERLEVEL_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetTriggerLevel(scopeHandle, 1, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetTriggerLevel(scopeHandle, 1);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: TriggerLevel3
///
/// Sets the Trigger Offset Trace 3, in units of Trace 3's AmplitudeScale.
///
/// Value: double, Range: -1,000,000.00000-+1,000,000.00000
/// Access: Read/Write
/// Default: 0.00000 (also can be defined in the initialization file, if used)
/// </summary>
public double TriggerLevel3
{
set
{
if ((value < -1000000.0000) || (value > 1000000.00000))
ShowError(TRIGGERLEVEL_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetTriggerLevel(scopeHandle, 2, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetTriggerLevel(scopeHandle, 2);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0.00000;
}
}
/// <summary>
/// Property: TriggerSource
///
/// Sets the Oscilloscope's Trigger Source. The Constants TRACE1_TRIG,
/// TRACE2_TRIG, TRACE3_TRIG and EXTERNAL_TRIG are provided for conenience.
///
/// Value: int, Range 0-3 (TRACE1_TRIG-EXTERNAL_TRIG)
/// Access: Read/Write
/// Default TRACE1_TRIG (also can be defined in the initialization file, if used)
/// </summary>
public int TriggerSource
{
set
{
if (!_Scope_Visible)
ShowError(SCOPE_NOT_VISIBLE);
else if ((value < TRACE1_TRIG) || (value > EXTERNAL_TRIG))
ShowError(TRIGGERSOURCE_RANGE_ERROR, value);
else
{
if (!_disposed)
{
try
{
int Ret = ScopeSetTriggerSourse(scopeHandle, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
catch
{
ShowError(SCOPE_TRIGGERSOURCE_ERROR);
Dispose();
}
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetTriggerSourse(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: TriggerEdge
///
/// Sets the Trigger Edge Detection Mode. Any valid negative int sets it
/// Negative Edge Triggered, any valid positive int sets it Positive Edge
/// Triggered, and 0 set it to disabled. The constants FALLING_EDGE_TRIG,
/// RISING_EDGE_TRIG and DISABLED_TRIG are provided for convenience.
///
/// Value: int, Range: see above
/// Access; Read/Write
/// Default: DISABLED_TRIG (also can be defined in the initialization file,
/// if used)
/// </summary>
public int TriggerEdge
{
set
{
if (!_Scope_Visible)
ShowError(SCOPE_NOT_VISIBLE);
else if (!_disposed)
{
int Edge;
try
{
if (value < 0)
Edge = -1;
else if (value > 0)
Edge = 1;
else
Edge = 0;
int Ret = ScopeSetActiveTriggerEdge(scopeHandle, Edge);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
catch
{
ShowError(SCOPE_TRIGGEREDGE_ERROR);
Dispose();
}
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
get
{
if (!_disposed)
return ScopeGetActiveTriggerEdge(scopeHandle);
else
ShowError(SCOPE_HANDLE_ERROR);
return 0;
}
}
/// <summary>
/// Property: TriggerDelay
///
/// Controls the Trigger Delay, in number of samples.
/// (see DLL Documentation)
///
/// Value: int, RangeL 0-Any valid positive int value
/// Access: Read/Write
/// Default: 0 (also can be defined in the initialization file, if used)
/// </summary>
public int TriggerDelay
{
set
{
if (value < 0)
ShowError(TRIGGERDELAY_RANGE_ERROR, value);
else
{
if (!_disposed)
{
int Ret = ScopeSetTrigHoldOffSmplsNum(scopeHandle, value);
if (Ret != scopeHandle)
ShowError(SCOPE_HANDLE_ERROR);
}
else
ShowError(SCOPE_DISPOSED_ERROR);
}
}
get
{
if (!_disposed)
return ScopeGetTrigHoldOffSmplsNum(scopeHandle);
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: TraceDisplayWidth
///
/// Returns the width of the current trace display area display in pixels.
///
/// Value: int
/// Access: Read Only
/// Default: N/A
/// </summary>
public int TraceDisplayWidth
{
get
{
if (!_disposed)
return (ScopeGetScreenWidth(scopeHandle));
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Property: TraceDisplayHeight
///
/// Returns the height of the current trace display area in pixels.
///
/// Value: int
/// Access: Read Only
/// Default: N/A
/// </summary>
public int TraceDisplayHeight
{
get
{
if (!_disposed)
return (ScopeGetScreenHeight(scopeHandle));
else
ShowError(SCOPE_DISPOSED_ERROR);
return 0;
}
}
/// <summary>
/// Method to Display Error Messages, overload for errors that have no associated
/// data (fundamental DLL communication errors, except for CAPTIONSIZE_ERROR).
/// </summary>
/// <param name="MessageNum">int: Error Number</param>
private static void ShowError(int ErrorNum)
{
_LastError = ErrorNum;
if (_ErrorMessagesOn)
{
switch (ErrorNum)
{
case SCOPE_CREATION_ERROR:
throw new Exception("Oscilloscope Creation Failed.");
case SCOPE_HANDLE_ERROR:
throw new Exception("Oscilloscope Access Failed.");
case SCOPE_DISPOSED_ERROR:
throw new Exception("Oscilloscope has been Disposed.");
case CAPTIONSIZE_ERROR:
throw new Exception("Caption Too Long.");
case SCOPE_TRIGGERSOURCE_ERROR:
throw new Exception("The Oscilloscope threw a Set Trigger Source Exception and must be Closed.");
case SCOPE_TRIGGEREDGE_ERROR:
throw new Exception("The Oscilloscope threw a Set Trigger Edge Exception and must be Closed.");
case SCOPE_NOT_VISIBLE:
throw new Exception("This Property Cannot be Accessed when the Oscilloscope is in Hide Mode.");
}
}
}
/// <summary>
/// Method to Display Error Messages, overload for range errors in property
/// that are type integer.
/// </summary>
/// <param name="MessageNum">int: Error Number</param>
/// <param name="ErrorValue">int: The Value That Caused the Error</param>
private static void ShowError(int ErrorNum, int ErrorValue)
{
_LastError = ErrorNum;
if (_ErrorMessagesOn)
{
switch (ErrorNum)
{
case LEFT_RANGE_ERROR:
throw new Exception(string.Format("Scope Left Out of Range: {0}.", ErrorValue));
case TOP_RANGE_ERROR:
throw new Exception(string.Format("Scope Top Out Of Range: {0}.", ErrorValue));
case WIDTH_RANGE_ERROR:
throw new Exception(string.Format("Scope Width Out of Range: {0}", ErrorValue));
case HEIGHT_RANGE_ERROR:
throw new Exception(string.Format("Scope Height Out Of Range: {0}.", ErrorValue));
case CELLSIZE_RANGE_ERROR:
throw new Exception(string.Format("Scope CellSize Out of Range: {0}.", ErrorValue));
case TRIGGERSOURCE_RANGE_ERROR:
throw new Exception(string.Format("Scope Trigger Source Out of Range: {0}.", ErrorValue));
case TRIGGERDELAY_RANGE_ERROR:
throw new Exception(string.Format("Scope Trigger Delay Out of Range: {0}.", ErrorValue));
}
}
}
/// <summary>
/// Method to Display Error Messages, overload for range errors in properties
/// that are type double.
/// </summary>
/// <param name="MessageNum">int: Error Number</param>
/// <param name="ErrorValue">double: The Value That Caused the Error</param>
private static void ShowError(int ErrorNum, double ErrorValue)
{
_LastError = ErrorNum;
if (_ErrorMessagesOn)
{
switch (ErrorNum)
{
case SAMPLESPERGRIDCELL_RANGE_ERROR:
throw new Exception(string.Format("Scope SamplesPerGridCell Out of Range: {0}", ErrorValue));
case CELLAMPLITUDESCALE_RANGE_ERROR:
throw new Exception(string.Format("Scope CellAmplitideScale Out of Range: {0}", ErrorValue));
case VERTICALOFFSET_RANGE_ERROR:
throw new Exception(string.Format("Vertical Offset Out of Range: {0}", ErrorValue));
case TRIGGERLEVEL_RANGE_ERROR:
throw new Exception(string.Format("Trigger Level Out of Range: {0}", ErrorValue));
}
}
}
public static void GetMonitorDimensions(out int Width, out int Height)
{
Size Monitor = SystemInformation.PrimaryMonitorSize;
Width = Monitor.Width;
Height = Monitor.Height;
}
#region IDisposable Members
/// <summary>
/// Dispose the object - call this to release the oscilloscope resources.
/// </summary>
public void Dispose()
{
if (!_disposed)
{
ScopeDestroy(scopeHandle);
_disposed = true;
}
}
/// <summary>
/// Flag indicating if the object is already disposed.
/// /// </summary>
public bool IsDisposed
{
get
{
return _disposed;
}
}
#endregion
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Oscilloscope/Oscilloscope_settings.ini
================================================
[Oscilloscope]
OscVrulFontName=Arial
OscVrulFontSize=8
OscVrulFontStyleBold=0
OscVrulFontStyleItalic=0
OscBackColor=00222222
OscGridColor=00404040
OscHorScaleColor=00FFFFFF
OscBeam0Color=000000FF
OscBeam1Color=0000FF00
OscBeam2Color=00FF0000
OscVrulGenFontColor=00FFFFFF
OscZeroLineColor=00FFFFFF
OscOscCaption=Oscilloscope
ShowSecondBeam=1
ShowThirdBeam=1
ShowTestButton=0
BuffersRecordType=1
CreateSecondBeam=1
CreateThirdBeam=1
SpreadViewTiming=1
EventsProcDivider=0
GridRefreshDivider=50
GridCellPixelsSize=15
TriggerEnable=0
TriggerSource=0
FirstTriggerLevel=0.0000000000
SecondTriggerLevel=0.0000000000
ThirdTriggerLevel=0.0000000000
ExtrnTriggerLevel=0.0000000000
TimeSamplesPerCell=20.0000000000
Beam0VertScale=10.0000000000
Beam1VertScale=10.0000000000
Beam2VertScale=10.0000000000
Beam0VertOffset=0.0000000000
Beam1VertOffset=0.0000000000
Beam2VertOffset=0.0000000000
ScopeFormHeight=400
ScopeFormWidth=600
ScopeStayOnTop=0
ShowTriggerControls=1
ShowOscJaggies=0
ShowOscHexVal=0
ShowHexCheckBox=0
ScopeShowAutoSweep=0
ScopeAutoSweep=0
ScopeAutoSweepDivider=4
ScopeShowHints=1
Producer_Vendor_Name=+972 507669424 Michael Bernstein, E_Mail: brnstin@cheerful.com
BfrSmplSize=32000
ScopeInputDumpSize=32000
ScopePolylineOptimize=0
[Miscellaneous]
ReadDelayPerSample=0
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Program.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Serial_Oscilloscope
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormTerminal());
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/AssemblyInfo.cs
================================================
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("Serial Oscilloscope")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("x-io Technologies Limited")]
[assembly: AssemblyProduct("Serial Oscilloscope")]
[assembly: AssemblyCopyright("Copyright © x-io Technologies Limited 2013")]
[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(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("dd5e52ed-ab85-46f6-a820-4d740c7456af")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Resources.Designer.cs
================================================
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Serial_Oscilloscope.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Serial_Oscilloscope.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Resources.resx
================================================
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Settings.Designer.cs
================================================
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Serial_Oscilloscope.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Settings.settings
================================================
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/SampleCounter.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Serial_Oscilloscope
{
/// <summary>
/// Sample counter. Tracks number of packets received and packet rate.
/// </summary>
class SampleCounter
{
/// <summary>
/// Timer to calculate packet rate.
/// </summary>
private System.Windows.Forms.Timer timer;
/// <summary>
/// Number of packets received.
/// </summary>
public int SamplesReceived { get; private set; }
/// <summary>
/// Sample receive rate as packets per second.
/// </summary>
public int SampleRate { get; private set; }
/// <summary>
/// Variable used to calculate packet rate.
/// </summary>
private int prevSamplesReceived;
/// <summary>
/// Constructor.
/// </summary>
public SampleCounter()
{
// Initialise variables
prevSamplesReceived = 0;
SamplesReceived = 0;
// Setup timer
timer = new System.Windows.Forms.Timer();
timer.Interval = 1000;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
/// <summary>
/// Increments packet counter.
/// </summary>
public void Increment()
{
SamplesReceived++;
}
// Zeros packet counter.
public void Reset()
{
prevSamplesReceived = 0;
SamplesReceived = 0;
SampleRate = 0;
}
/// <summary>
/// timer Tick event to calculate packet rate.
/// </summary>
void timer_Tick(object sender, EventArgs e)
{
SampleRate = SamplesReceived - prevSamplesReceived;
prevSamplesReceived = SamplesReceived;
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/Serial Oscilloscope.csproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{37F93890-5296-4350-8F67-28BCC26CD6F2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Serial_Oscilloscope</RootNamespace>
<AssemblyName>Serial Oscilloscope</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<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|x86' ">
<PlatformTarget>x86</PlatformTarget>
<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" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CsvFileWriter.cs" />
<Compile Include="FormGetValue.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormGetValue.designer.cs">
<DependentUpon>FormGetValue.cs</DependentUpon>
</Compile>
<Compile Include="FormTerminal.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormTerminal.Designer.cs">
<DependentUpon>FormTerminal.cs</DependentUpon>
</Compile>
<Compile Include="Oscilloscope\Oscilloscope.cs" />
<Compile Include="SampleCounter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextBoxBuffer.cs" />
<EmbeddedResource Include="FormGetValue.resx">
<DependentUpon>FormGetValue.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormTerminal.resx">
<DependentUpon>FormTerminal.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Content Include="Oscilloscope\Oscilloscope_settings.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Oscilloscope\Osc_DLL.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</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>
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/TextBoxBuffer.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Serial_Oscilloscope
{
/// <summary>
/// TextBox FIFO buffer.
/// </summary>
class TextBoxBuffer
{
/// <summary>
/// Size of buffer in bytes.
/// </summary>
private int size;
/// <summary>
/// Buffer array.
/// </summary>
private char[] buffer;
/// <summary>
/// Buffer in position index.
/// </summary>
private int inPos = 0;
/// <summary>
/// Buffer out position index.
/// </summary>
private int outPos = 0;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="size">
/// Size of buffer.
/// </param>
public TextBoxBuffer(int size)
{
this.size = size;
buffer = new char[this.size];
}
/// <summary>
/// Returns value indicating if buffer is empty.
/// </summary>
/// <returns>
/// Value indicating if buffer is empty.
/// </returns>
public bool IsEmpty()
{
return inPos == outPos;
}
/// <summary>
/// Adds string to buffer.
/// </summary>
/// <param name="str">
/// String to add to buffer.
/// </param>
public void Put(string str)
{
foreach (char c in str)
{
buffer[inPos] = c;
if (++inPos == size - 1)
{
inPos = 0;
}
}
}
/// <summary>
/// Gets buffer contents.
/// </summary>
/// <returns>
/// Buffer contents.
/// </returns>
public string Get()
{
string str = "";
while (inPos != outPos)
{
str += buffer[outPos];
if (++outPos == size - 1)
{
outPos = 0;
}
}
return str;
}
/// <summary>
/// Clears buffer.
/// </summary>
public void Clear()
{
inPos = 0;
outPos = 0;
}
}
}
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope/VisualStudio_CleanUp.bat
================================================
@echo off
REM Remove files generated by compiler in this directory and all subdirectories.
REM Essential release files are kept.
echo Removing "*.csproj.user" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.csproj.user"') do del "%%i" /f /q
echo.
echo Removing "*.exe.config" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.exe.config"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe.config" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe.config"') do del "%%i" /f /q
echo.
echo Removing "*.pdb" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.pdb"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.application" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.application"') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe "') do del "%%i" /f /q
echo.
echo Removing "*.vshost.exe.manifest" files...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*.vshost.exe.manifest "') do del "%%i" /f /q
echo.
echo Removing "obj" directory...
rd "%~p0obj" /s /q
echo.
echo Removing "Debug" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*Debug"') do if "%%~ni"=="Debug" rd "%%i" /s /q
echo.
echo Removing "app.publish" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*app.publish"') do rd "%%i" /s /q
echo.
echo Removing "*_mcr" directories recursively...
for /f "delims==" %%i in ('dir /b /on /s "%~p0*_mcr"') do rd "%%i" /s /q
echo.
echo "%~n0.bat" done.
================================================
FILE: Serial Oscilloscope/Serial Oscilloscope.sln
================================================
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serial Oscilloscope", "Serial Oscilloscope\Serial Oscilloscope.csproj", "{37F93890-5296-4350-8F67-28BCC26CD6F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{37F93890-5296-4350-8F67-28BCC26CD6F2}.Debug|x86.ActiveCfg = Debug|x86
{37F93890-5296-4350-8F67-28BCC26CD6F2}.Debug|x86.Build.0 = Debug|x86
{37F93890-5296-4350-8F67-28BCC26CD6F2}.Release|x86.ActiveCfg = Release|x86
{37F93890-5296-4350-8F67-28BCC26CD6F2}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
gitextract_wgem7s09/
├── .gitattributes
├── .gitignore
├── ArduinoPrintADC/
│ └── ArduinoPrintADC.ino
├── README.md
└── Serial Oscilloscope/
├── Serial Oscilloscope/
│ ├── CsvFileWriter.cs
│ ├── FormGetValue.Designer.cs
│ ├── FormGetValue.cs
│ ├── FormGetValue.resx
│ ├── FormTerminal.Designer.cs
│ ├── FormTerminal.cs
│ ├── FormTerminal.resx
│ ├── Oscilloscope/
│ │ ├── Oscilloscope.cs
│ │ └── Oscilloscope_settings.ini
│ ├── Program.cs
│ ├── Properties/
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── SampleCounter.cs
│ ├── Serial Oscilloscope.csproj
│ ├── TextBoxBuffer.cs
│ └── VisualStudio_CleanUp.bat
└── Serial Oscilloscope.sln
SYMBOL INDEX (105 symbols across 11 files)
FILE: Serial Oscilloscope/Serial Oscilloscope/CsvFileWriter.cs
class CsvFileWriter (line 10) | class CsvFileWriter
method CsvFileWriter (line 31) | public CsvFileWriter(string filePath)
method CloseFile (line 41) | public void CloseFile()
method WriteCSVline (line 52) | public void WriteCSVline(float[] values)
FILE: Serial Oscilloscope/Serial Oscilloscope/FormGetValue.Designer.cs
class FormGetValue (line 3) | partial class FormGetValue
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Serial Oscilloscope/Serial Oscilloscope/FormGetValue.cs
class FormGetValue (line 15) | public partial class FormGetValue : Form
method FormGetValue (line 25) | public FormGetValue()
method textBoxValue_KeyPress (line 33) | private void textBoxValue_KeyPress(object sender, KeyPressEventArgs e)
method buttonOK_Click (line 44) | private void buttonOK_Click(object sender, EventArgs e)
method FormGetValue_FormClosed (line 52) | private void FormGetValue_FormClosed(object sender, FormClosedEventArg...
FILE: Serial Oscilloscope/Serial Oscilloscope/FormTerminal.Designer.cs
class FormTerminal (line 3) | partial class FormTerminal
method Dispose (line 14) | protected override void Dispose(bool disposing)
method InitializeComponent (line 29) | private void InitializeComponent()
FILE: Serial Oscilloscope/Serial Oscilloscope/FormTerminal.cs
class FormTerminal (line 16) | public partial class FormTerminal : Form
method FormTerminal (line 75) | public FormTerminal()
method FormTerminal_Load (line 85) | private void FormTerminal_Load(object sender, EventArgs e)
method FormTerminal_FormClosed (line 110) | private void FormTerminal_FormClosed(object sender, FormClosedEventArg...
method formUpdateTimer_Tick (line 123) | void formUpdateTimer_Tick(object sender, EventArgs e)
method textBox_KeyPress (line 147) | private void textBox_KeyPress(object sender, KeyPressEventArgs e)
method toolStripMenuItemSerialPort_DropDownItemClicked (line 160) | private void toolStripMenuItemSerialPort_DropDownItemClicked(object se...
method toolStripMenuItemBaudRate_DropDownItemClicked (line 195) | private void toolStripMenuItemBaudRate_DropDownItemClicked(object send...
method toolStripMenuItemEnabled_CheckStateChanged (line 228) | private void toolStripMenuItemEnabled_CheckStateChanged(object sender,...
method toolStripMenuItemClear_Click (line 243) | private void toolStripMenuItemClear_Click(object sender, EventArgs e)
method toolStripMenuItemChannels123_CheckStateChanged (line 251) | private void toolStripMenuItemChannels123_CheckStateChanged(object sen...
method toolStripMenuItemChannels456_CheckStateChanged (line 266) | private void toolStripMenuItemChannels456_CheckStateChanged(object sen...
method toolStripMenuItemChannels789_CheckStateChanged (line 281) | private void toolStripMenuItemChannels789_CheckStateChanged(object sen...
method toolStripMenuItemStartLogging_Click (line 296) | private void toolStripMenuItemStartLogging_Click(object sender, EventA...
method toolStripMenuItemStopLogging_Click (line 314) | private void toolStripMenuItemStopLogging_Click(object sender, EventAr...
method toolStripMenuItemAbout_Click (line 328) | private void toolStripMenuItemAbout_Click(object sender, EventArgs e)
method toolStripMenuItemSourceCode_Click (line 336) | private void toolStripMenuItemSourceCode_Click(object sender, EventArg...
method RefreshSerialPortList (line 352) | private void RefreshSerialPortList()
method OpenSerialPort (line 369) | private bool OpenSerialPort()
method CloseSerialPort (line 426) | private void CloseSerialPort()
method SendSerialPort (line 442) | private void SendSerialPort(char c)
method serialPort_DataReceived (line 454) | private void serialPort_DataReceived(object sender, SerialDataReceived...
FILE: Serial Oscilloscope/Serial Oscilloscope/Oscilloscope/Oscilloscope.cs
class Oscilloscope (line 484) | sealed class Oscilloscope : IDisposable
method AtOpenLib (line 495) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeCreate (line 499) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeDestroy (line 505) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeShow (line 509) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeHide (line 513) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeCleanBuffers (line 517) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ShowNext (line 521) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ExternalNext (line 526) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method QuickUpDate (line 531) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetPanelState (line 544) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetFormPos (line 548) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetFormSize (line 552) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetCellPixelSize (line 556) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetCellSampleSize (line 560) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetCaption (line 564) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetAmpScale (line 569) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetAmpOffset (line 573) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetTriggerLevel (line 577) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetTriggerSourse (line 581) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetActiveTriggerEdge (line 585) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeSetTrigHoldOffSmplsNum (line 589) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetFormLeft (line 597) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetFormTop (line 601) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetFormWidth (line 605) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetFormHeight (line 609) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetScreenWidth (line 613) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetScreenHeight (line 617) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetCellPixelSize (line 621) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetCellSampleSize (line 625) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetPanelState (line 629) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetAmpScale (line 633) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetAmpOffset (line 637) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetTriggerLevel (line 641) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetTriggerSourse (line 645) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetActiveTriggerEdge (line 649) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method ScopeGetTrigHoldOffSmplsNum (line 653) | [DllImport(Osc_DLL_path, CallingConvention = CallingConvention.Cdecl)]
method CreateScope (line 699) | public static Oscilloscope CreateScope()
method CreateScope (line 712) | public static Oscilloscope CreateScope(string IniName, string IniSuffix)
method Oscilloscope (line 755) | private Oscilloscope()
method Oscilloscope (line 759) | private Oscilloscope(int handle)
method ShowScope (line 773) | public void ShowScope()
method HideScope (line 787) | public void HideScope()
method ClearScope (line 801) | public void ClearScope()
method AddScopeData (line 815) | public void AddScopeData(double beam1, double beam2, double beam3)
method AddExternalScopeData (line 835) | public void AddExternalScopeData(double data)
method UpdateScope (line 848) | public void UpdateScope()
method ShowError (line 1793) | private static void ShowError(int ErrorNum)
method ShowError (line 1824) | private static void ShowError(int ErrorNum, int ErrorValue)
method ShowError (line 1856) | private static void ShowError(int ErrorNum, double ErrorValue)
method GetMonitorDimensions (line 1875) | public static void GetMonitorDimensions(out int Width, out int Height)
method Dispose (line 1887) | public void Dispose()
FILE: Serial Oscilloscope/Serial Oscilloscope/Program.cs
class Program (line 8) | static class Program
method Main (line 13) | [STAThread]
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Resources.Designer.cs
class Resources (line 22) | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resource...
method Resources (line 32) | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Mic...
FILE: Serial Oscilloscope/Serial Oscilloscope/Properties/Settings.Designer.cs
class Settings (line 15) | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
FILE: Serial Oscilloscope/Serial Oscilloscope/SampleCounter.cs
class SampleCounter (line 11) | class SampleCounter
method SampleCounter (line 36) | public SampleCounter()
method Increment (line 52) | public void Increment()
method Reset (line 58) | public void Reset()
method timer_Tick (line 68) | void timer_Tick(object sender, EventArgs e)
FILE: Serial Oscilloscope/Serial Oscilloscope/TextBoxBuffer.cs
class TextBoxBuffer (line 11) | class TextBoxBuffer
method TextBoxBuffer (line 39) | public TextBoxBuffer(int size)
method IsEmpty (line 51) | public bool IsEmpty()
method Put (line 62) | public void Put(string str)
method Get (line 80) | public string Get()
method Clear (line 97) | public void Clear()
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (161K chars).
[
{
"path": ".gitattributes",
"chars": 483,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n\n# Custom for Visual Studio\n*.cs diff=csharp\n*.sln"
},
{
"path": ".gitignore",
"chars": 2039,
"preview": "#################\n## Eclipse\n#################\n\n*.pydevproject\n.project\n.metadata\nbin/\ntmp/\n*.tmp\n*.bak\n*.swp\n*~.nib\nloc"
},
{
"path": "ArduinoPrintADC/ArduinoPrintADC.ino",
"chars": 2335,
"preview": "/*\n ArduinoPrintADC.ino\n\n Author: Seb Madgwick\n\n Sends up to all 6 analogue inputs values in ASCII as comma sep"
},
{
"path": "README.md",
"chars": 2070,
"preview": "Serial-Oscilloscope\n===================\n\nSerial Oscilloscope is a Windows application that plots comma-separated variabl"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/CsvFileWriter.cs",
"chars": 2016,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\nusing System.Glo"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormGetValue.Designer.cs",
"chars": 3551,
"preview": "namespace Serial_Oscilloscope\n{\n partial class FormGetValue\n {\n /// <summary>\n /// Required designe"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormGetValue.cs",
"chars": 1421,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nu"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormGetValue.resx",
"chars": 5696,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormTerminal.Designer.cs",
"chars": 20303,
"preview": "namespace Serial_Oscilloscope\n{\n partial class FormTerminal\n {\n /// <summary>\n /// Required designe"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormTerminal.cs",
"chars": 18919,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nu"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/FormTerminal.resx",
"chars": 6257,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Oscilloscope/Oscilloscope.cs",
"chars": 65188,
"preview": "using System;\nusing System.Text;\nusing System.Drawing;\nusing System.Windows.Forms;\nusing System.Runtime.InteropServices;"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Oscilloscope/Oscilloscope_settings.ini",
"chars": 1274,
"preview": "[Oscilloscope]\nOscVrulFontName=Arial\nOscVrulFontSize=8\nOscVrulFontStyleBold=0\nOscVrulFontStyleItalic=0\nOscBackColor=0022"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Program.cs",
"chars": 495,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Windows.Forms;\n\nnamespace Serial_Oscill"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Properties/AssemblyInfo.cs",
"chars": 1461,
"preview": "using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Infor"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Properties/Resources.Designer.cs",
"chars": 2795,
"preview": "//------------------------------------------------------------------------------\n// <auto-generated>\n// This code w"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Properties/Resources.resx",
"chars": 5494,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <!-- \n Microsoft ResX Schema \n \n Version 2.0\n \n The prim"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Properties/Settings.Designer.cs",
"chars": 1074,
"preview": "//------------------------------------------------------------------------------\n// <auto-generated>\n// This code w"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Properties/Settings.settings",
"chars": 240,
"preview": "<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\""
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/SampleCounter.cs",
"chars": 1907,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Serial_Oscilloscope\n{\n"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/Serial Oscilloscope.csproj",
"chars": 4360,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microso"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/TextBoxBuffer.cs",
"chars": 2301,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace Serial_Oscilloscope\n{\n"
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope/VisualStudio_CleanUp.bat",
"chars": 1552,
"preview": "@echo off\n\nREM Remove files generated by compiler in this directory and all subdirectories.\nREM Essential release files "
},
{
"path": "Serial Oscilloscope/Serial Oscilloscope.sln",
"chars": 877,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C"
}
]
About this extraction
This page contains the full source code of the xioTechnologies/Serial-Oscilloscope GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (150.5 KB), approximately 34.2k tokens, and a symbol index with 105 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.