[NF] Debugmode eingebaut

This commit is contained in:
BlubbFish 2017-09-24 15:41:09 +00:00
parent e3bafaf014
commit 7f0de5503f
5 changed files with 31 additions and 8 deletions

View File

@ -61,6 +61,8 @@ namespace Dashboard.Connector {
send.StartInfo.Arguments = args + "-m \""+data.Replace("\"","\\\"")+"\" -t \""+topic+"\" -d";
send.StartInfo.CreateNoWindow = true;
send.StartInfo.UseShellExecute = false;
send.StartInfo.RedirectStandardOutput = true;
send.StartInfo.RedirectStandardError = true;
send.Start();
send.WaitForExit();
MessageSending?.Invoke(this, new MqttEventArgs(data, topic));

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartArguments>-debug</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>-debug</StartArguments>
</PropertyGroup>
</Project>

View File

@ -10,7 +10,7 @@ namespace Dashboard {
public partial class Dashboard : Form {
private Dictionary<String, ASensor> sensors = new Dictionary<String, ASensor>();
public Dashboard() {
public Dashboard(Boolean debug) {
InitializeComponent();
ADataBackend.SetInstance(InIReader.GetInstance("settings.ini").GetSection("mqtt"));
@ -19,9 +19,11 @@ namespace Dashboard {
this.FormClosed += this.Dashboard_FormClosed;
this.SizeChanged += this.Dashboard_SizeChanged;
ADataBackend.Instance.MessageIncomming += this.Instance_MessageIncomming;
ADataBackend.Instance.MessageSending += this.Instance_MessageSending;
if (debug) {
ADataBackend.Instance.MessageIncomming += this.Instance_MessageIncomming;
ADataBackend.Instance.MessageSending += this.Instance_MessageSending;
}
}
private void Dashboard_SizeChanged(Object sender, EventArgs e) {
@ -58,11 +60,11 @@ namespace Dashboard {
}
private void Instance_MessageIncomming(Object sender, MqttEventArgs e) {
System.Diagnostics.Debug.WriteLine("Received = " + e.Message + " on topic " + e.Topic+" at "+DateTime.Now.ToUniversalTime());
Console.WriteLine("Received = " + e.Message + " on topic " + e.Topic+" at "+DateTime.Now.ToUniversalTime());
}
private void Instance_MessageSending(Object sender, MqttEventArgs e) {
System.Diagnostics.Debug.WriteLine("Sended = " + e.Message + " on topic " + e.Topic + " at " + DateTime.Now.ToUniversalTime());
Console.WriteLine("Sended = " + e.Message + " on topic " + e.Topic + " at " + DateTime.Now.ToUniversalTime());
}
}
}

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using BlubbFish.Utils;
namespace Dashboard {
static class Program {
@ -7,10 +9,18 @@ namespace Dashboard {
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main() {
static void Main(String[] args) {
Dictionary<String, CmdArgs.VaildArguments> pargs = new Dictionary<String, CmdArgs.VaildArguments> {
{ "-debug", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }
};
CmdArgs.Instance.SetArguments(pargs, args);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Dashboard());
Boolean debug = false;
if(CmdArgs.Instance.HasArgumentType("-debug")) {
debug = true;
}
Application.Run(new Dashboard(debug));
}
}
}