1.0.7 - Use previous area state when area is arming for web service API

- Add interactive command line option and use path separator for mono compatibility
This commit is contained in:
Ryan Wagoner 2016-11-25 23:06:46 -05:00
parent b4f4e5f795
commit 0d83ded2a4
5 changed files with 37 additions and 16 deletions

View file

@ -8,6 +8,8 @@ namespace HAILogger
{ {
static class Helper static class Helper
{ {
private static string lastmode = "OFF";
public static AreaContract ConvertArea(ushort id, clsArea area) public static AreaContract ConvertArea(ushort id, clsArea area)
{ {
AreaContract ret = new AreaContract(); AreaContract ret = new AreaContract();
@ -19,18 +21,15 @@ namespace HAILogger
ret.fire = area.AreaFireAlarmText; ret.fire = area.AreaFireAlarmText;
ret.water = area.AreaWaterAlarmText; ret.water = area.AreaWaterAlarmText;
string mode = area.ModeText(); if (area.ExitTimer > 0)
{
if (mode.Contains("DAY")) ret.mode = lastmode;
ret.mode = "DAY"; }
else if (mode.Contains("NIGHT"))
ret.mode = "NIGHT";
else if (mode.Contains("AWAY"))
ret.mode = "AWAY";
else if (mode.Contains("VACATION"))
ret.mode = "VACATION";
else else
ret.mode = "OFF"; {
ret.mode = area.ModeText();
lastmode = ret.mode;
}
return ret; return ret;
} }

View file

@ -10,17 +10,27 @@ namespace HAILogger
static void Main(string[] args) static void Main(string[] args)
{ {
bool interactive = false;
for (int i = 0; i < args.Length; i++) for (int i = 0; i < args.Length; i++)
{ {
switch (args[i]) switch (args[i])
{ {
case "/?":
case "-h":
case "-help":
ShowHelp();
return;
case "-c": case "-c":
Global.dir_config = args[++i]; Global.dir_config = args[++i];
break; break;
case "-i":
interactive = true;
break;
} }
} }
if (Environment.UserInteractive) if (Environment.UserInteractive || interactive)
{ {
Console.TreatControlCAsInput = false; Console.TreatControlCAsInput = false;
Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler);
@ -50,5 +60,13 @@ namespace HAILogger
server.Shutdown(); server.Shutdown();
args.Cancel = true; args.Cancel = true;
} }
static void ShowHelp()
{
Console.WriteLine(
AppDomain.CurrentDomain.FriendlyName + " [-c config_file] [-i]\n" +
"\t-c Specifies the name of the config file. Default is HAILogger.ini.\n" +
"\t-i Run in interactive mode.");
}
} }
} }

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.0")] [assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.6.0")] [assembly: AssemblyFileVersion("1.0.7.0")]

View file

@ -10,7 +10,7 @@ namespace HAILogger
{ {
public static void LoadSettings() public static void LoadSettings()
{ {
NameValueCollection settings = LoadCollection(Global.dir_config + "\\HAILogger.ini"); NameValueCollection settings = LoadCollection(Global.dir_config + Path.DirectorySeparatorChar + "HAILogger.ini");
// HAI Controller // HAI Controller
Global.hai_address = settings["hai_address"]; Global.hai_address = settings["hai_address"];

View file

@ -2,7 +2,7 @@
Provides logging and web service API for HAI/Leviton OmniPro II controllers Provides logging and web service API for HAI/Leviton OmniPro II controllers
##Download ##Download
You can download the [binary here](http://www.excalibur-partners.com/downloads/HAILogger_1_0_6.zip) You can download the [binary here](http://www.excalibur-partners.com/downloads/HAILogger_1_0_7.zip)
##Requirements ##Requirements
- .NET Framework 4.0 - .NET Framework 4.0
@ -58,6 +58,10 @@ To test the API you can use your browser to view a page or PowerShell (see below
- Invoke-WebRequest -Uri "http://localhost:8000/SetUnit" -Method POST -ContentType "application/json" -Body (convertto-json -InputObject @{"id"=1;"value"=100}) -UseBasicParsing - Invoke-WebRequest -Uri "http://localhost:8000/SetUnit" -Method POST -ContentType "application/json" -Body (convertto-json -InputObject @{"id"=1;"value"=100}) -UseBasicParsing
##Change Log ##Change Log
Version 1.0.7 - 2016-11-25
- Use previous area state when area is arming for web service API
- Add interactive command line option and use path separator for Mono compatibility
Version 1.0.6 - 2016-11-20 Version 1.0.6 - 2016-11-20
- Added thermostat status and auxiliary temp to web service API - Added thermostat status and auxiliary temp to web service API