Commit 18465bf9 authored by sandrosage11's avatar sandrosage11
Browse files

Init

parents

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30517.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gui1", "Gui1\Gui1.csproj", "{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9BBDAF9A-9378-4660-AE5A-84FD0B3E80BC}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
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 PICkitS;
using System.Threading;
/// <summary>
/// Noch nicht wichtig, diese Art von Arbeitsteilung wird in einem seperaten Projekt gezeigt
/// </summary>
namespace Gui1
{
class BackgroundWorkerSample
{
private double workerResult;
public BackgroundWorkerSample()
{
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.DoWork += new DoWorkEventHandler(this.DoWork);
bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.WorkCompleted);
bgWorker.RunWorkerAsync("Beginne Berechnung von PI!");
bgWorker.WorkerReportsProgress = true;
while (bgWorker.IsBusy)
Thread.Sleep(50);
Console.WriteLine("Ergebnis = " + workerResult);
Console.ReadLine();
}
private void DoWork(object sender, DoWorkEventArgs e)
{
uint p_byte_count = USART.Retrieve_Data_Byte_Count();
byte[] p_data_array = new byte[p_byte_count];
USART.Retrieve_Data(p_byte_count, ref p_data_array);
Console.WriteLine(Encoding.UTF8.GetString(p_data_array, 0, p_data_array.Length));
Console.WriteLine(e.Argument);
Console.WriteLine("Hallo!\n");
e.Result = CalculatePi((BackgroundWorker)sender);
}
private void WorkCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Console.WriteLine("Beendet!");
workerResult = (double)e.Result;
}
private double CalculatePi(BackgroundWorker worker)
{
//asynchrone zyklische Abfrage muss hier noch hin
double radius = 100;
double kreistreffer = 0;
long perc = (long)(((radius * 2) * Math.Pow(radius, 2)) + Math.Pow(radius, 2) / 100) / 100;
long iter = 0;
int percCompleted = 0;
for (double y = radius * (-1); y <= radius; y++)
{
double end = Math.Pow(radius, 2);
for (double x = radius * (-1); x <= end; x++)
{
iter++;
if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(radius, 2))
kreistreffer++;
}
}
return kreistreffer / Math.Pow(radius, 2);
}
}
}
This diff is collapsed.

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 PICkitS;
using System.Threading;
//&&& Hier kann man keine Variable erstellen/deklarieren
namespace Gui1
{
//&&& Hier kann man keine Variable erstellen/deklarieren
public partial class Form1 : Form
{
TextBox[] txtBox; //Erstellen der Textboxes
Label[] lbl; //Erstellen der Labels
TextBox[] rtxtBox; //und jetzt alles nochmal fuer READ
Label[] rlbl;
int bytenum_int = 0; //Zaehlcounter fuer WRITE
int rbytenum_int = 0; //Zaehlcounter fuer READ
int space = 20; //Abstand der Textboxes und Labels zueinander bei WRITE
int rspace = 20; //Abstand der Textboxes und Labels zueinander bei WRITE
//jeweils einzeln, da dynamisch veraendert wird
//&&& Hier kann man eine Variable erstellen/deklarieren, fraglich ob das hier was bringt, denn z.b: IF-Abfragen kann man hier auch nicht stellen
double ToDouble(string In)
{
In = In.Replace(",", ".");
return double.Parse(In, System.Globalization.CultureInfo.InvariantCulture);
}
byte converttobyte(string a) //koennte global bzw. wo anders angelegt werden!?
{
int b = Convert.ToInt16(a, 16);
byte d = Convert.ToByte(b);
return (d);
}
string converttostring(byte a) //Rueckkehrfunktion: byte in string
{
int b = Convert.ToInt16(a);
string d = Convert.ToString(b);
return (d);
}
string printError(string error)
{
return "###Error: " + error + " ###";
}
public Form1()
{
InitializeComponent();
//Errors in red
this.ErrorBar.ForeColor = Color.Red;
/*Slave Adress of the Device */
byte DEV_ADDR_READ = 0xD7;
byte DEV_ADDR_WRITE = 0xD6;
/*Number of Bytes that should be read*/
byte NUM_BYTES = 0x02;
/*Registers that I want to read*/
byte TEMP_ADDR_LOW = 0x15;
byte TEMP_ADDR_HIGH = 0xFF;
/*Array where the data gets saved*/
byte[] Data_Array = new byte[NUM_BYTES];
Data_Array[0] = 0xD7;
string Script_View = "";
//Prüft, ob Gerät initialisiert werden kann
//Statusleiste ändert sich wenn erfolgreich
if (Device.Initialize_PICkitSerial(0))
{
this.Textbox.Text = "Device: Connection successful\r\n";
}
else
{
this.ErrorBar.Text = "Device: Connection failed";
return;
}
this.WriteButton.Visible = false; //sollen erst im spaeteren Verlauf, wenn Funktion ausgewaehlt wird, sichtbar werden
this.ReadButton.Visible = false;
Thread sleepingThread = new Thread(Form1.SleepIndefinitely);
sleepingThread.Start();
//&&& Hier wird der zweite Thread mal erstellt und gestartet, Funktion SleepIndefinitely wird dabei aufgerufen...
}
private void SPI_VCC_OffRB_CheckedChanged(object sender, EventArgs e) //unneeded
{
}
private void SPI_BitrateTB_TextChanged(object sender, EventArgs e) //unneeded
{
}
private void groupBox3_Enter(object sender, EventArgs e)
{
}
private void Communication_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void SPI_VCC_OnRB_CheckedChanged(object sender, EventArgs e)
{
}
private void statusStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void UART_SendBTN_Click(object sender, EventArgs e)
{
if(UART_functionTB.Text == "")
{
this.ErrorBar.Text = printError("Send: Missing command");
return;
}
else
{
UART_OutputTB.Text += "Command:" + UART_functionTB.Text + "was sent\r\n";
string message = UART_functionTB.Text; //Eingabe wird in einer string-Variable gespeichtert, Zusatz: \r\n erforderlich fuer Datenuebermittlung
string Script_View = "";
byte[] Data_Arr = Encoding.ASCII.GetBytes(message); //Umwandlung des Strings in Bytes
UART_OutputTB.Text += Convert.ToString(Data_Arr.Length) + "\r\n";
if (USART.Send_Data(Convert.ToByte(Data_Arr.Length), ref Data_Arr, ref Script_View)) //fuer die Uebermittlung ist auch Laenge (in Byte) des Bytearrays notwendig; hier mit .Length
{
UART_OutputTB.Text += "Send succesful\r\n";
}
Thread.Sleep(2000);
}
Device.Terminate_Comm_Threads();
}
bool a = true;
private void ReceiveStart_Click(object sender, EventArgs e)
{
a = true;
while(a)
{
if(USART.Retrieve_Data_Byte_Count() != 0)
{
uint p_byte_count = USART.Retrieve_Data_Byte_Count(); //fragen, wie viel Bytes zum abholen bereit sind
byte[] p_data_array = new byte[p_byte_count]; //Bytearray fuer Anzahl der abzuholenden Bytes erstellen; Laenge nun bekannt
if (USART.Retrieve_Data(p_byte_count, ref p_data_array))
{
UART_OutputTB.Text += Convert.ToString(p_byte_count) + " Successful!\r\n";
}
UART_OutputTB.Text += Encoding.UTF8.GetString(p_data_array, 0, p_data_array.Length);
}
else
{
UART_OutputTB.Text += "There is no Data to be retrieved!\r\n";
}
Device.Terminate_Comm_Threads();
}
}
private void StopReceive_Click(object sender, EventArgs e)
{
a = false;
UART_OutputTB.Text += "Stop Retrieving Data!\r\n";
}
}
}
\ No newline at end of file
<?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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>160, 22</value>
</metadata>
<metadata name="statusStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>300, 22</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9F0D2EAD-934A-43C0-9AB8-A598CFC7C4A6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Gui1</RootNamespace>
<AssemblyName>Gui1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PICkitS">
<HintPath>..\..\..\..\Downloads\PICkitS (4)\PICkitS.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BackgroundWorkerSamle.cs" />
<Compile Include="I2C.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SPI.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UART.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.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>
<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>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gui1
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
//this is the original version for gui implementation
\ No newline at end of file
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("Gui1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("Gui1")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2020")]
[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("9f0d2ead-934a-43c0-9ab8-a598cfc7c4a6")]
// 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,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]