This commit is contained in:
parent
448b916ef1
commit
fd4373645c
@ -1,136 +1,51 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Testconsole
|
namespace Testconsole {
|
||||||
{
|
class Program {
|
||||||
/*class Program
|
private Boolean RunningProcess = true;
|
||||||
{
|
private System.Threading.Thread sig_thread;
|
||||||
private class bla
|
|
||||||
{
|
|
||||||
public string Rb_charge_nr;
|
|
||||||
public string Rb_mat_nr;
|
|
||||||
public string Rb_kg_rohs;
|
|
||||||
public string Rb_eox_kg;
|
|
||||||
public string Rb_koh_kg;
|
|
||||||
public string Rb_milchs_kg;
|
|
||||||
public string Rb_essig_kg;
|
|
||||||
}
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
string strLine = "asdads,asdasd,asd,asd,asd,ads,a,sd,a,sd,as,d,asd,a,sd";
|
public static void Main() => new Program();
|
||||||
bla a = new bla();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string[] split = strLine.Split(',');
|
|
||||||
a.Rb_charge_nr = split[0];
|
|
||||||
a.Rb_mat_nr = a.Rb_charge_nr.Substring(3, 3);
|
|
||||||
a.Rb_kg_rohs = split[1];
|
|
||||||
a.Rb_eox_kg = split[2];
|
|
||||||
a.Rb_koh_kg = split[3];
|
|
||||||
a.Rb_milchs_kg = split[4];
|
|
||||||
a.Rb_essig_kg = split[5];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
// This example demonstrates the Console.Beep(Int32, Int32) method
|
|
||||||
|
|
||||||
|
Program() {
|
||||||
|
Console.WriteLine("Start");
|
||||||
|
this.WaitForShutdown();
|
||||||
|
Console.WriteLine("Shutdown");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
class Program
|
private void WaitForShutdown() {
|
||||||
{
|
this.sig_thread = new System.Threading.Thread(delegate () {
|
||||||
public static void Main()
|
Console.WriteLine("Mono: Create thread");
|
||||||
{
|
Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] {
|
||||||
// Declare the first few notes of the song, "Mary Had A Little Lamb".
|
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
|
||||||
Note[] Mary =
|
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT)
|
||||||
{
|
|
||||||
new Note(Tone.B, Duration.QUARTER),
|
|
||||||
new Note(Tone.A, Duration.QUARTER),
|
|
||||||
new Note(Tone.GbelowC, Duration.QUARTER),
|
|
||||||
new Note(Tone.A, Duration.QUARTER),
|
|
||||||
new Note(Tone.B, Duration.QUARTER),
|
|
||||||
new Note(Tone.B, Duration.QUARTER),
|
|
||||||
new Note(Tone.B, Duration.HALF),
|
|
||||||
new Note(Tone.A, Duration.QUARTER),
|
|
||||||
new Note(Tone.A, Duration.QUARTER),
|
|
||||||
new Note(Tone.A, Duration.HALF),
|
|
||||||
new Note(Tone.B, Duration.QUARTER),
|
|
||||||
new Note(Tone.D, Duration.QUARTER),
|
|
||||||
new Note(Tone.D, Duration.HALF)
|
|
||||||
};
|
};
|
||||||
// Play the song
|
Console.WriteLine("Mono: Set Signals");
|
||||||
Play(Mary);
|
while (this.RunningProcess) {
|
||||||
}
|
Console.WriteLine("Mono: Wait for Signal");
|
||||||
|
Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1);
|
||||||
// Play the notes in a song.
|
Console.WriteLine("Mono: Signal Recieved: "+i);
|
||||||
protected static void Play(Note[] tune)
|
this.RunningProcess = false;
|
||||||
{
|
|
||||||
foreach (Note n in tune)
|
|
||||||
{
|
|
||||||
if (n.NoteTone == Tone.REST)
|
|
||||||
Thread.Sleep((int)n.NoteDuration);
|
|
||||||
else
|
|
||||||
Console.Beep((int)n.NoteTone, (int)n.NoteDuration);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
if (Type.GetType("Mono.Runtime") != null) {
|
||||||
|
this.sig_thread.Start();
|
||||||
|
} else {
|
||||||
|
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
|
||||||
|
}
|
||||||
|
Console.WriteLine("Windows: Create Handler");
|
||||||
|
Console.WriteLine("Wait");
|
||||||
|
while (this.RunningProcess) {
|
||||||
|
System.Threading.Thread.Sleep(100);
|
||||||
|
}
|
||||||
|
Console.WriteLine("After Wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the frequencies of notes in an octave, as well as
|
private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) {
|
||||||
// silence (rest).
|
e.Cancel = true;
|
||||||
protected enum Tone
|
Console.WriteLine("Windows get Signal");
|
||||||
{
|
this.RunningProcess = false;
|
||||||
REST = 0,
|
|
||||||
GbelowC = 196,
|
|
||||||
A = 220,
|
|
||||||
Asharp = 233,
|
|
||||||
B = 247,
|
|
||||||
C = 262,
|
|
||||||
Csharp = 277,
|
|
||||||
D = 294,
|
|
||||||
Dsharp = 311,
|
|
||||||
E = 330,
|
|
||||||
F = 349,
|
|
||||||
Fsharp = 370,
|
|
||||||
G = 392,
|
|
||||||
Gsharp = 415,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the duration of a note in units of milliseconds.
|
|
||||||
protected enum Duration
|
|
||||||
{
|
|
||||||
WHOLE = 1600,
|
|
||||||
HALF = WHOLE/2,
|
|
||||||
QUARTER = HALF/2,
|
|
||||||
EIGHTH = QUARTER/2,
|
|
||||||
SIXTEENTH = EIGHTH/2,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define a note as a frequency (tone) and the amount of
|
|
||||||
// time (duration) the note plays.
|
|
||||||
protected struct Note
|
|
||||||
{
|
|
||||||
Tone toneVal;
|
|
||||||
Duration durVal;
|
|
||||||
|
|
||||||
// Define a constructor to create a specific note.
|
|
||||||
public Note(Tone frequency, Duration time)
|
|
||||||
{
|
|
||||||
toneVal = frequency;
|
|
||||||
durVal = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define properties to return the note's tone and duration.
|
|
||||||
public Tone NoteTone { get{ return toneVal; } }
|
|
||||||
public Duration NoteDuration { get{ return durVal; } }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
This example produces the following results:
|
|
||||||
|
|
||||||
This example plays the first few notes of "Mary Had A Little Lamb"
|
|
||||||
through the console speaker.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -9,8 +9,11 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Testconsole</RootNamespace>
|
<RootNamespace>Testconsole</RootNamespace>
|
||||||
<AssemblyName>Testconsole</AssemblyName>
|
<AssemblyName>Testconsole</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -45,9 +48,16 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets" Condition="Exists('..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets'))" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
Loading…
Reference in New Issue
Block a user