From 28c4eceb530258e1b22d3f793dfec6ac84f20c11 Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Fri, 9 Dec 2022 18:02:36 +0100 Subject: [PATCH] removed unused bindings, made constants constant --- ADIS_Csharp/RaspiControl/AppState.cs | 8 +------ ADIS_Csharp/RaspiControl/Joystick.cs | 5 +---- ADIS_Csharp/RaspiControl/JoystickButton.cs | 10 +-------- ADIS_Csharp/RaspiControl/MqttConstants.cs | 22 +++++++------------ .../RaspiControl/NavigationConstants.cs | 20 ++++++----------- ADIS_Csharp/RaspiControl/Program.cs | 9 +++----- 6 files changed, 21 insertions(+), 53 deletions(-) diff --git a/ADIS_Csharp/RaspiControl/AppState.cs b/ADIS_Csharp/RaspiControl/AppState.cs index 81b45b2..b7c92b5 100644 --- a/ADIS_Csharp/RaspiControl/AppState.cs +++ b/ADIS_Csharp/RaspiControl/AppState.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RaspiControl { +namespace RaspiControl { public enum APP_STATE { STARTUP = 0, INIT = 1, diff --git a/ADIS_Csharp/RaspiControl/Joystick.cs b/ADIS_Csharp/RaspiControl/Joystick.cs index 6c38798..8f84b83 100644 --- a/ADIS_Csharp/RaspiControl/Joystick.cs +++ b/ADIS_Csharp/RaspiControl/Joystick.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using Unosquare.RaspberryIO; +using Unosquare.RaspberryIO; using Unosquare.RaspberryIO.Abstractions; using Unosquare.WiringPi; diff --git a/ADIS_Csharp/RaspiControl/JoystickButton.cs b/ADIS_Csharp/RaspiControl/JoystickButton.cs index 18e717e..d631c39 100644 --- a/ADIS_Csharp/RaspiControl/JoystickButton.cs +++ b/ADIS_Csharp/RaspiControl/JoystickButton.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RaspiControl { - +namespace RaspiControl { public enum JoystickButton { None = 0, Left = 1, @@ -14,5 +7,4 @@ namespace RaspiControl { Down = 8, Center = 16 } - } diff --git a/ADIS_Csharp/RaspiControl/MqttConstants.cs b/ADIS_Csharp/RaspiControl/MqttConstants.cs index 103bd1a..646858d 100644 --- a/ADIS_Csharp/RaspiControl/MqttConstants.cs +++ b/ADIS_Csharp/RaspiControl/MqttConstants.cs @@ -1,21 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RaspiControl { - internal static class MqttConstants { +namespace RaspiControl { + public static class MqttConstants { #region Publish - public static string MOBILE_NAV_TURN_TOPIC = "/mobile/cmd/nav/turn/"; - public static string MOBILE_NAV_MOVE_TOPIC = "/mobile/cmd/nav/move/"; - public static string MOBILE_NAV_STOP_TOPIC = "/mobile/cmd/nav/stop/"; - public static string SPLITFLAP_DISPLAY = "/splitFlap/cmd/display/"; - public static string SPLITFLAP_INIT = "/splitFlap/cmd/init/"; + public const string MOBILE_NAV_TURN_TOPIC = "/mobile/cmd/nav/turn/"; + public const string MOBILE_NAV_MOVE_TOPIC = "/mobile/cmd/nav/move/"; + public const string MOBILE_NAV_STOP_TOPIC = "/mobile/cmd/nav/stop/"; + public const string SPLITFLAP_DISPLAY_TOPIC = "/splitFlap/cmd/display/"; + public const string SPLITFLAP_INIT_TOPIC = "/splitFlap/cmd/init/"; #endregion #region subscribe - public static string DEVICE_STATUS_APP_TOPIC = "/device/status/+/app"; + public const string DEVICE_STATUS_APP_TOPIC = "/device/status/+/app"; #endregion } } diff --git a/ADIS_Csharp/RaspiControl/NavigationConstants.cs b/ADIS_Csharp/RaspiControl/NavigationConstants.cs index 90ad6d4..0a1d671 100644 --- a/ADIS_Csharp/RaspiControl/NavigationConstants.cs +++ b/ADIS_Csharp/RaspiControl/NavigationConstants.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RaspiControl { - internal static class NavigationConstants { - public static int TURN_ANGLE_LEFT = -10; - public static int TURN_ANGLE_RIGHT = 10; - public static int SPEED_FORWARD = 100; - public static int SPEED_BACKWARD = -100; - public static bool STOP = true; +namespace RaspiControl { + public static class NavigationConstants { + public const int TURN_ANGLE_LEFT = -10; + public const int TURN_ANGLE_RIGHT = 10; + public const int SPEED_FORWARD = 100; + public const int SPEED_BACKWARD = -100; + public const bool STOP = true; } } diff --git a/ADIS_Csharp/RaspiControl/Program.cs b/ADIS_Csharp/RaspiControl/Program.cs index 7ed6b1b..5c36bfe 100644 --- a/ADIS_Csharp/RaspiControl/Program.cs +++ b/ADIS_Csharp/RaspiControl/Program.cs @@ -1,10 +1,7 @@ -using System; -using System.Text; +using System.Text; using M2Mqtt; using M2Mqtt.Messages; using System.Text.Json; -using System.Linq; -using System.Runtime.CompilerServices; namespace RaspiControl { class Programm { @@ -49,7 +46,7 @@ namespace RaspiControl { private static void PublishSplitFlapDisplay(string message) { string payload = JsonSerializer.Serialize>(new Dictionary() { { "message", message } }); - client.Publish(MqttConstants.SPLITFLAP_DISPLAY, Encoding.UTF8.GetBytes(payload),MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE,false); + client.Publish(MqttConstants.SPLITFLAP_DISPLAY_TOPIC, Encoding.UTF8.GetBytes(payload),MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE,false); } private static void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string deviceId = ""; @@ -67,7 +64,7 @@ namespace RaspiControl { switch (appState) { case APP_STATE.STARTUP: Console.WriteLine("Startup"); - client.Publish(MqttConstants.SPLITFLAP_INIT, new byte[] { }, MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); + client.Publish(MqttConstants.SPLITFLAP_INIT_TOPIC, new byte[] { }, MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); break; case APP_STATE.INIT: Console.WriteLine("Init");