//----------------------------------------------------------------------------------
// <copyright file="SensorProgramSettings.cpp" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
//   Implementation of SensorProgramSettings class, a serializable entity that holds
//   the settings for SensorProgram.
// </summary>
//
// <owner>Mike Cookson</owner>
//----------------------------------------------------------------------------------

#include "SensorProgramSettings.h"
#include "LqrSMACLoadSaveBoostXml.h"

using namespace std;
using namespace LiquidRobotics::SMACFramework;
using namespace LiquidRobotics::EventLib;

namespace LiquidRobotics {
namespace EventLib {

SensorProgramSettings::SensorProgramSettings()
: serverName("serverName")
, serverKind("")
, commandCompleteEvent("CommandComplete", "SendCommandCompleteEvent", "LiquidR-SMC")
, gpsEvent("GPSSample", "GPSSample", "LiquidR-SMC")
, shutdownEvent("Shutdown", "EventBase", "LiquidR-SMC")
{
}

SensorProgramSettings::SensorProgramSettings(const SensorProgramSettings& rhs)
: serverName(rhs.serverName)
, serverKind(rhs.serverKind)
, softwareVersion(rhs.softwareVersion)
, loggerSettings(rhs.loggerSettings)
, commandCompleteEvent(rhs.commandCompleteEvent)
, gpsEvent(rhs.gpsEvent)
, shutdownEvent(rhs.shutdownEvent)
, eventTransceiverSettings(rhs.eventTransceiverSettings)
, payloadManagerClientSettings(rhs.payloadManagerClientSettings)
{
}

const string& SensorProgramSettings::GetServerName() const
{
	return serverName;
}

void SensorProgramSettings::SetServerName(const string& newValue)
{
	serverName = newValue;
}

const string& SensorProgramSettings::GetServerKind() const
{
	return serverKind;
}

void SensorProgramSettings::SetServerKind(const string& newValue)
{
	serverKind = newValue;
}

const SensorProgramSettings::Version& SensorProgramSettings::GetSoftwareVersion() const
{
	return softwareVersion;
}

void SensorProgramSettings::SetSoftwareVersion(const Version& newValue)
{
	softwareVersion = newValue;
}

const StdOutLoggerSettings& SensorProgramSettings::GetLoggerSettings() const
{
	return loggerSettings;
}

void SensorProgramSettings::SetLoggerSettings(const StdOutLoggerSettings& newValue)
{
	loggerSettings = newValue;
}

const EventSettings& SensorProgramSettings::GetCommandCompleteEvent() const
{
	return commandCompleteEvent;
}


void SensorProgramSettings::SetCommandCompleteEvent(const EventSettings& newValue)
{
	commandCompleteEvent = newValue;
}

const EventSettings& SensorProgramSettings::GetGPSEvent() const
{
	return gpsEvent;
}

void SensorProgramSettings::SetGPSEvent(const EventSettings& newValue)
{
	gpsEvent = newValue;
}

const EventSettings& SensorProgramSettings::GetShutdownEvent() const
{
	return shutdownEvent;
}

void SensorProgramSettings::SetShutdownEvent(const EventSettings& newValue)
{
	shutdownEvent = newValue;
}

//const BenthosModemControllerSettings& GetControllerSettings() const;
//void SetControllerSettings(const BenthosModemControllerSettings& newValue);

//const SerialPortSettings& GetSerialPortSettings() const;
//void SetSerialPortSettings(const SerialPortSettings& newValue);

const EventTransceiverSettings& SensorProgramSettings::GetEventTransceiverSettings() const
{
	return eventTransceiverSettings;
}
void SensorProgramSettings::SetEventTransceiverSettings(const EventTransceiverSettings& newValue)
{
	eventTransceiverSettings = newValue;
}

const PayloadManagerClientSettings& SensorProgramSettings::GetPayloadManagerClientSettings() const
{
	return payloadManagerClientSettings;
}

void SensorProgramSettings::SetPayloadManagerClientSettings(const PayloadManagerClientSettings& newValue)
{
	payloadManagerClientSettings = newValue;
}

void SensorProgramSettings::Load(const string& fileName, bool withMD5)
{
	if (withMD5)
		LoadBoostXmlMD5(fileName, *this, true);
	else
		LoadBoostXml(fileName, *this);
}

void SensorProgramSettings::Save(const string& fileName, bool withMD5) const
{
	if (withMD5)
		SaveBoostXmlMD5(fileName, *this, true);
	else
		SaveBoostXml(fileName, *this);
}

}
}
