diff --git a/CSV_Converter.sln b/CSV_Converter.sln
new file mode 100644
index 0000000..3370ad5
--- /dev/null
+++ b/CSV_Converter.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27004.2002
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSV_Converter", "CSV_Converter\CSV_Converter.csproj", "{0885067F-5EA8-4AC0-8644-7809BCF11AB2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0885067F-5EA8-4AC0-8644-7809BCF11AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0885067F-5EA8-4AC0-8644-7809BCF11AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0885067F-5EA8-4AC0-8644-7809BCF11AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0885067F-5EA8-4AC0-8644-7809BCF11AB2}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {EA3D6233-FDA7-41E4-9EEA-A26B305EB418}
+ EndGlobalSection
+EndGlobal
diff --git a/CSV_Converter/App.config b/CSV_Converter/App.config
new file mode 100644
index 0000000..bae5d6d
--- /dev/null
+++ b/CSV_Converter/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/CSV_Converter/CSV_Converter.csproj b/CSV_Converter/CSV_Converter.csproj
new file mode 100644
index 0000000..1eaaa48
--- /dev/null
+++ b/CSV_Converter/CSV_Converter.csproj
@@ -0,0 +1,86 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {0885067F-5EA8-4AC0-8644-7809BCF11AB2}
+ WinExe
+ CSV_Converter
+ CSV_Converter
+ v4.6.1
+ 512
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+ True
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CSV_Converter/Form1.Designer.cs b/CSV_Converter/Form1.Designer.cs
new file mode 100644
index 0000000..6df23e2
--- /dev/null
+++ b/CSV_Converter/Form1.Designer.cs
@@ -0,0 +1,116 @@
+namespace CSV_Converter
+{
+ partial class Form1
+ {
+ ///
+ /// Erforderliche Designervariable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Verwendete Ressourcen bereinigen.
+ ///
+ /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Vom Windows Form-Designer generierter Code
+
+ ///
+ /// Erforderliche Methode für die Designerunterstützung.
+ /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
+ ///
+ private void InitializeComponent()
+ {
+ this.txt_load = new System.Windows.Forms.TextBox();
+ this.btn_save = new System.Windows.Forms.Button();
+ this.btn_load = new System.Windows.Forms.Button();
+ this.btn_start = new System.Windows.Forms.Button();
+ this.txt_save = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // txt_load
+ //
+ this.txt_load.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txt_load.Location = new System.Drawing.Point(99, 14);
+ this.txt_load.Name = "txt_load";
+ this.txt_load.Size = new System.Drawing.Size(472, 20);
+ this.txt_load.TabIndex = 1;
+ //
+ // btn_save
+ //
+ this.btn_save.Location = new System.Drawing.Point(12, 41);
+ this.btn_save.Name = "btn_save";
+ this.btn_save.Size = new System.Drawing.Size(81, 23);
+ this.btn_save.TabIndex = 2;
+ this.btn_save.Text = "SR speichern";
+ this.btn_save.UseVisualStyleBackColor = true;
+ this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
+ //
+ // btn_load
+ //
+ this.btn_load.Location = new System.Drawing.Point(12, 12);
+ this.btn_load.Name = "btn_load";
+ this.btn_load.Size = new System.Drawing.Size(81, 23);
+ this.btn_load.TabIndex = 3;
+ this.btn_load.Text = "CSV laden";
+ this.btn_load.UseVisualStyleBackColor = true;
+ this.btn_load.Click += new System.EventHandler(this.btn_load_Click);
+ //
+ // btn_start
+ //
+ this.btn_start.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btn_start.Location = new System.Drawing.Point(577, 41);
+ this.btn_start.Name = "btn_start";
+ this.btn_start.Size = new System.Drawing.Size(75, 23);
+ this.btn_start.TabIndex = 4;
+ this.btn_start.Text = "Start";
+ this.btn_start.UseVisualStyleBackColor = true;
+ this.btn_start.Click += new System.EventHandler(this.btn_start_Click);
+ //
+ // txt_save
+ //
+ this.txt_save.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txt_save.Location = new System.Drawing.Point(99, 43);
+ this.txt_save.Name = "txt_save";
+ this.txt_save.Size = new System.Drawing.Size(472, 20);
+ this.txt_save.TabIndex = 5;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(664, 81);
+ this.Controls.Add(this.txt_save);
+ this.Controls.Add(this.btn_start);
+ this.Controls.Add(this.btn_load);
+ this.Controls.Add(this.btn_save);
+ this.Controls.Add(this.txt_load);
+ this.MaximizeBox = false;
+ this.MaximumSize = new System.Drawing.Size(8000, 120);
+ this.MinimumSize = new System.Drawing.Size(280, 120);
+ this.Name = "Form1";
+ this.Text = "Rigol CSV zu PulseView SR";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox txt_load;
+ private System.Windows.Forms.Button btn_save;
+ private System.Windows.Forms.Button btn_load;
+ private System.Windows.Forms.Button btn_start;
+ private System.Windows.Forms.TextBox txt_save;
+ }
+}
+
diff --git a/CSV_Converter/Form1.cs b/CSV_Converter/Form1.cs
new file mode 100644
index 0000000..c350409
--- /dev/null
+++ b/CSV_Converter/Form1.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+using System.IO.Compression;
+namespace CSV_Converter {
+ public partial class Form1 : Form {
+ public Form1() {
+ InitializeComponent();
+ }
+ private void btn_load_Click(object sender, EventArgs e) {
+ OpenFileDialog fileDialog = new OpenFileDialog();
+ fileDialog.Filter = "CSV & Text|*.txt; *.csv|Alles|*";
+ if(fileDialog.ShowDialog() == DialogResult.OK) {
+ txt_load.Text = fileDialog.FileName;
+ }
+ }
+ private void btn_save_Click(object sender, EventArgs e) {
+ SaveFileDialog fileDialog = new SaveFileDialog();
+ fileDialog.Filter = "SR|*.sr|ZIP|*.zip";
+ if (fileDialog.ShowDialog() == DialogResult.OK) {
+ txt_save.Text = fileDialog.FileName;
+ }
+ }
+ private void btn_start_Click(object sender, EventArgs e) {
+ string filepath_input = txt_load.Text;
+ string filepath_output = txt_save.Text;
+ if (File.Exists(filepath_input)) {
+ if (File.Exists(filepath_output))
+ File.Delete(filepath_output);
+ ZipArchive zipArchive = ZipFile.Open(filepath_output, ZipArchiveMode.Create);
+ int file_lenght = File.ReadAllLines(filepath_input).Length;
+ StreamReader reader = new StreamReader(filepath_input);
+ string[] parts = reader.ReadLine().Split(',');
+ int channels = parts.Length - 3;
+ string[] channel_names = new string[channels];
+ for(int i = 0; i < channels; i++)
+ channel_names[i] = parts[i + 1];
+ parts = reader.ReadLine().Split(',');
+ double frequency;
+ frequency = 1/ Convert.ToDouble(parts[parts.Length - 1].Replace('.', ','));
+ string samplerate = Convert.ToInt32(frequency).ToString() + " Hz";
+ ZipArchiveEntry archiveEntry;
+ StreamWriter streamWriter; // generate some metadata
+ archiveEntry = zipArchive.CreateEntry("version");
+ streamWriter = new StreamWriter(archiveEntry.Open());
+ streamWriter.WriteLine("2");
+ streamWriter.Close();
+ streamWriter.Dispose();
+ archiveEntry = zipArchive.CreateEntry("metadata");
+ streamWriter = new StreamWriter(archiveEntry.Open());
+ streamWriter.WriteLine("[global]");
+ streamWriter.WriteLine("[device 1]");
+ streamWriter.WriteLine("samplerate = " + samplerate);
+ streamWriter.WriteLine("total analog = " + channels);
+ int channel_num = 1;
+ foreach(string channel_name in channel_names)
+ streamWriter.WriteLine("analog" + channel_num++ + " = " + channel_name);
+ streamWriter.WriteLine("unitsize=1");
+ streamWriter.Close();
+ streamWriter.Dispose();
+ int byte_count = 4 * (file_lenght - 2); // generate buffer and other variables
+ byte[][] analog_output = new byte[channels][];
+ for (int i = 0; i < channels; i++)
+ analog_output[i] = new byte[byte_count];
+ int index = 0;
+ float value;
+ byte[] b;
+ while (!reader.EndOfStream) { // convert line by line to float and store values in byte arrays (easy to save)
+ parts = reader.ReadLine().Split(',');
+ for (int i = 0; i < channels; i++) {
+ value = Convert.ToSingle(parts[i + 1].Replace('.', ','));
+ b = BitConverter.GetBytes(value);
+ analog_output[i][index +0] = b[0];
+ analog_output[i][index +1] = b[1];
+ analog_output[i][index +2] = b[2];
+ analog_output[i][index +3] = b[3];
+ }
+ index += 4;
+ }
+ Stream stream_analog; // save compressed streams
+ for (int i = 0; i < channels; i++) {
+ archiveEntry = zipArchive.CreateEntry("analog-1-" + (i + 1) + "-1");
+ stream_analog = archiveEntry.Open();
+ stream_analog.Write(analog_output[i], 0, byte_count);
+ stream_analog.Close();
+ }
+ zipArchive.Dispose();
+ }
+ }
+ }
+}
+// in under 100 lines ;-)
\ No newline at end of file
diff --git a/CSV_Converter/Form1.resx b/CSV_Converter/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/CSV_Converter/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/CSV_Converter/Program.cs b/CSV_Converter/Program.cs
new file mode 100644
index 0000000..b2fc716
--- /dev/null
+++ b/CSV_Converter/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace CSV_Converter
+{
+ static class Program
+ {
+ ///
+ /// Der Haupteinstiegspunkt für die Anwendung.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/CSV_Converter/Properties/AssemblyInfo.cs b/CSV_Converter/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..e138de5
--- /dev/null
+++ b/CSV_Converter/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("CSV_Converter")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CSV_Converter")]
+[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("0885067f-5ea8-4ac0-8644-7809bcf11ab2")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CSV_Converter/Properties/Resources.Designer.cs b/CSV_Converter/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..1099a7f
--- /dev/null
+++ b/CSV_Converter/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace CSV_Converter.Properties {
+ using System;
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
+ // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.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() {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CSV_Converter.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/CSV_Converter/Properties/Resources.resx b/CSV_Converter/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/CSV_Converter/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/CSV_Converter/Properties/Settings.Designer.cs b/CSV_Converter/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..033e812
--- /dev/null
+++ b/CSV_Converter/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace CSV_Converter.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.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;
+ }
+ }
+ }
+}
diff --git a/CSV_Converter/Properties/Settings.settings b/CSV_Converter/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/CSV_Converter/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Form1_v1.cs b/Form1_v1.cs
new file mode 100644
index 0000000..6a54462
--- /dev/null
+++ b/Form1_v1.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+using System.IO.Compression;
+
+namespace CSV_Converter
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void btn_load_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog fileDialog = new OpenFileDialog();
+ fileDialog.Filter = "CSV & Text|*.txt; *.csv|Alles|*";
+ if(fileDialog.ShowDialog() == DialogResult.OK) {
+ txt_load.Text = fileDialog.FileName;
+ }
+ }
+
+ private void btn_save_Click(object sender, EventArgs e)
+ {
+ SaveFileDialog fileDialog = new SaveFileDialog();
+ fileDialog.Filter = "SR|*.sr|ZIP|*.zip";
+ if (fileDialog.ShowDialog() == DialogResult.OK)
+ {
+ txt_save.Text = fileDialog.FileName;
+ }
+ }
+
+ private void btn_start_Click(object sender, EventArgs e)
+ {
+ string filepath_input = txt_load.Text;
+ string filepath_output = txt_save.Text;
+ if (File.Exists(filepath_input))
+ {
+ if (File.Exists(filepath_output))
+ File.Delete(filepath_output);
+ ZipArchive zipArchive = ZipFile.Open(filepath_output, ZipArchiveMode.Create);
+ StreamReader reader = new StreamReader(filepath_input);
+ string[] parts = reader.ReadLine().Split(',');
+ int channels = parts.Length - 3;
+ string[] channel_names = new string[channels];
+ for(int i = 0; i < channels; i++)
+ channel_names[i] = parts[i + 1];
+ parts = reader.ReadLine().Split(',');
+ double frequency;
+ frequency = 1/ Convert.ToDouble(parts[parts.Length - 1].Replace('.', ','));
+ string samplerate = Convert.ToInt32(frequency).ToString() + " Hz";
+ ZipArchiveEntry archiveEntry;
+ StreamWriter streamWriter;
+ archiveEntry = zipArchive.CreateEntry("version");
+ streamWriter = new StreamWriter(archiveEntry.Open());
+ streamWriter.WriteLine("2");
+ streamWriter.Close();
+ streamWriter.Dispose();
+ archiveEntry = zipArchive.CreateEntry("metadata");
+ streamWriter = new StreamWriter(archiveEntry.Open());
+ streamWriter.WriteLine("[global]");
+ streamWriter.WriteLine("sigrok version = 0.6.0-git-af2f9a5");
+ streamWriter.WriteLine("");
+ streamWriter.WriteLine("[device 1]");
+ streamWriter.WriteLine("samplerate = " + samplerate);
+ streamWriter.WriteLine("total analog = " + channels);
+ int channel_num = 1;
+ foreach(string channel_name in channel_names)
+ streamWriter.WriteLine("analog" + channel_num++ + " = " + channel_name);
+ streamWriter.WriteLine("unitsize=1");
+ streamWriter.Close();
+ streamWriter.Dispose();
+ ZipArchiveEntry[] archiveEntry_analog_channels;
+ archiveEntry_analog_channels = new ZipArchiveEntry[channels];
+ Stream[] stream_analog_channels;
+ stream_analog_channels = new Stream[channels];
+ for(int i = 0; i < channels; i++) {
+ archiveEntry_analog_channels[i] = zipArchive.CreateEntry("analog-1-" + (i + 1) + "-1");
+ stream_analog_channels[i] = archiveEntry_analog_channels[i].Open();
+ }
+
+ int index;
+ float[] value;
+ string line;
+ byte[] b;
+ while (!reader.EndOfStream)
+ {
+ line = reader.ReadLine();
+ parts = line.Split(',');
+ index = Convert.ToInt32(parts[0]);
+ value = new float[parts.Length - 1];
+ for (int x = 1; x < parts.Length; x++)
+ value[x - 1] = (float)Convert.ToDouble(parts[x].Replace('.', ','));
+
+ for (int i = 0; i < channels; i++)
+ {
+ b = BitConverter.GetBytes(value[i]);
+ stream_analog_channels[i].WriteByte(b[0]);
+ stream_analog_channels[i].WriteByte(b[1]);
+ stream_analog_channels[i].WriteByte(b[2]);
+ stream_analog_channels[i].WriteByte(b[3]);
+ }
+ }
+
+ for (int i = 0; i < channels; i++) {
+ stream_analog_channels[i].Close();
+ stream_analog_channels[i].Dispose();
+ }
+ zipArchive.Dispose();
+ }
+ //ZipArchive zipArchive = ZipFile.Open("", ZipArchiveMode.Update);
+ //ZipArchiveEntry archiveEntry = zipArchive.CreateEntry("", CompressionLevel.Fastest);
+ //archiveEntry.Open().Write()
+ }
+ }
+}