[NF] Now sould dedect Strg+c on Linux

This commit is contained in:
BlubbFish 2018-05-15 20:52:54 +00:00
parent 69030796f5
commit 852a096f1d
31 changed files with 49 additions and 17 deletions

View File

@ -11,6 +11,7 @@ namespace ZwayBot {
private readonly ZwayController zw; private readonly ZwayController zw;
private readonly Dictionary<String, AModul> moduls = new Dictionary<String, AModul>(); private readonly Dictionary<String, AModul> moduls = new Dictionary<String, AModul>();
private Boolean RunningProcess = true; private Boolean RunningProcess = true;
private System.Threading.Thread sig_thread;
private readonly ProgramLogger logger = new ProgramLogger(); private readonly ProgramLogger logger = new ProgramLogger();
public Program(String[] args) { public Program(String[] args) {
@ -42,6 +43,16 @@ namespace ZwayBot {
} }
private void WaitForShutdown() { private void WaitForShutdown() {
this.sig_thread = new System.Threading.Thread(delegate() {
Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] {
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT)
};
while (true) {
Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1);
this.RunningProcess = false;
}
});
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown); Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
while (this.RunningProcess) { while (this.RunningProcess) {
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
@ -59,6 +70,7 @@ namespace ZwayBot {
Console.WriteLine("Modul entladen: " + item.Key); Console.WriteLine("Modul entladen: " + item.Key);
} }
this.zw.Dispose(); this.zw.Dispose();
this.sig_thread.Abort();
} }
private void ModulEvents() { private void ModulEvents() {

View File

@ -31,8 +31,8 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2")] [assembly: AssemblyVersion("1.4.3")]
[assembly: AssemblyFileVersion("1.4.2")] [assembly: AssemblyFileVersion("1.4.3")]
[assembly: NeutralResourcesLanguage("de-DE")] [assembly: NeutralResourcesLanguage("de-DE")]
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com. // “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.

View File

@ -12,6 +12,8 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -51,6 +53,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="dpkg\preinst" /> <None Include="dpkg\preinst" />
<None Include="dpkg\postinst" />
<Compile Include="Events.cs" /> <Compile Include="Events.cs" />
<Compile Include="Interfaces\IForceLoad.cs" /> <Compile Include="Interfaces\IForceLoad.cs" />
<Compile Include="Moduls\AModul.cs" /> <Compile Include="Moduls\AModul.cs" />
@ -150,6 +153,7 @@
<None Include="dpkg\make-deb.sh" /> <None Include="dpkg\make-deb.sh" />
<None Include="dpkg\prerm" /> <None Include="dpkg\prerm" />
<None Include="dpkg\zwaybot.service" /> <None Include="dpkg\zwaybot.service" />
<None Include="packages.config" />
<None Include="Resources\Icon.ico" /> <None Include="Resources\Icon.ico" />
<Content Include="Resources\icon.svg" /> <Content Include="Resources\icon.svg" />
</ItemGroup> </ItemGroup>
@ -160,4 +164,11 @@
</EmbeddedResource> </EmbeddedResource>
</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>
</Project> </Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=public config=public
[cold] [cold]

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=private config=private
[settings] [settings]

View File

@ -1,4 +1,4 @@
[names] [names]
2-0-37=Kühlschrank Schalter 2-0-37=Kühlschrank Schalter
2-0-49-4=Kühlschrank Leistung 2-0-49-4=Kühlschrank Leistung
2-0-50-0=Kühlschrank Verbrauch [kWh] 2-0-50-0=Kühlschrank Verbrauch [kWh]

View File

@ -1,4 +1,4 @@
[hot] [hot]
from=7-0-67-1:Level from=7-0-67-1:Level
to=8-0-67-1:Level;9-0-67-1:Level to=8-0-67-1:Level;9-0-67-1:Level

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=private config=private
[settings] [settings]

View File

@ -1,4 +1,4 @@
[zway] [zway]
server=localhost server=localhost
user=admin user=admin
pass=pass pass=pass

View File

@ -1,3 +1,3 @@
[temp] [temp]
cron=30 * * * * cron=30 * * * *
devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1 devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1

Binary file not shown.

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=public config=public
[cold] [cold]

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=private config=private
[settings] [settings]

View File

@ -1,4 +1,4 @@
[names] [names]
2-0-37=Kühlschrank Schalter 2-0-37=Kühlschrank Schalter
2-0-49-4=Kühlschrank Leistung 2-0-49-4=Kühlschrank Leistung
2-0-50-0=Kühlschrank Verbrauch [kWh] 2-0-50-0=Kühlschrank Verbrauch [kWh]

View File

@ -1,4 +1,4 @@
[hot] [hot]
from=7-0-67-1:Level from=7-0-67-1:Level
to=8-0-67-1:Level;9-0-67-1:Level to=8-0-67-1:Level;9-0-67-1:Level

View File

@ -1,4 +1,4 @@
[modul] [modul]
config=private config=private
[settings] [settings]

View File

@ -1,4 +1,4 @@
[zway] [zway]
server=localhost server=localhost
user=admin user=admin
pass=pass pass=pass

View File

@ -1,3 +1,3 @@
[temp] [temp]
cron=30 * * * * cron=30 * * * *
devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1 devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1

View File

@ -18,6 +18,7 @@ mkdir -p $SYSTEMD
cp control $DEBIAN cp control $DEBIAN
cp preinst $DEBIAN cp preinst $DEBIAN
cp postinst $DEBIAN
cp prerm $DEBIAN cp prerm $DEBIAN
sed -i s/Version:\ x\.x-x/"Version: $VMAJOR.$VMINOR-$VBUILD"/ $DEBIAN/control sed -i s/Version:\ x\.x-x/"Version: $VMAJOR.$VMINOR-$VBUILD"/ $DEBIAN/control
sed -i s/Architecture:\ any/"Architecture: $ARCHT"/ $DEBIAN/control sed -i s/Architecture:\ any/"Architecture: $ARCHT"/ $DEBIAN/control

3
Zway-Bot/dpkg/postinst Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
service zwaybot start

View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
service zwaybot stop service zwaybot stop
adduser --system zwaybot addgroup zwaybot
adduser --system --no-create-home --disabled-login --ingroup zwaybot zwaybot

4
Zway-Bot/packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Posix" version="5.4.0.201" targetFramework="net471" />
</packages>