using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RPCSupport.Devices;
using System.Globalization;

namespace RPCSupport.Logging
{
    public class Logging : ClientDevice
    {

        public bool enabledEcg;
        public bool enabledBioz;
        public bool enabledRtoR;
        public bool enabledPace;
        public bool enabledTemp1;
        public bool enabledTemp2;
        public bool enabledPressure;
        public bool enabledAccel;
        public struct parametersEcg_Struct
        {
        }
        public struct parametersBioz_Struct
        {
        }
        public struct parametersRtoR_Struct
        {
        }
        public struct parametersPace_Struct
        {
        }
        public struct parametersTemp1_Struct
        {
            public int sampleRate;  // seconds
        } 
        public parametersTemp1_Struct parametersTemp1;

        public struct parametersTemp2_Struct
        {
            public int sampleRate;  // seconds
        }
        public struct parametersPressure_Struct
        {
            public int sampleRate;  // seconds
        }
        public struct parametersAccel_Struct
        {
            public int sampleRate;  // seconds
        }


        const string CLASSNAME = "Logging";
        public Logging(RPCClient client)
            : base(client)
        {

        }
        public void ReadMission()
        {
            int val;
            string cmd;
            string reply;

            reply = Call(CLASSNAME, "ReadMission");

            // parse through reply string here
            //
            //

        }
        public void WriteMission()
        {
            int val;
            string cmd;
            string reply;

            reply = Call(CLASSNAME, "StartMissionDefine");
            enabledTemp1 = true;
            //if (enabledTemp1)
            //{
            parametersTemp1.sampleRate = 1;
            cmd = String.Format("\"/BMP280/InitStart {0}\"", 1);
            reply = Call(CLASSNAME, "AppendMissionCmd", cmd);
            cmd = String.Format("\"/MAX31725/InitStart {0}\"", 2);
            reply = Call(CLASSNAME, "AppendMissionCmd", cmd);
            cmd = String.Format("\"/BMP280/InitStart {0}\"", 3);
            reply = Call(CLASSNAME, "AppendMissionCmd", cmd);
            //}
            reply = Call(CLASSNAME, "EndMissionDefine");
            reply = Call(CLASSNAME, "WriteMission");

            //reply = Call(CLASSNAME, "ReadReg", addr.ToString("X2"));
            //int.TryParse(reply, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val);
        }


        public void EraseMission()
        {
            int val;
            string cmd;
            string reply;

            reply = Call(CLASSNAME, "EraseMission");
        }

        public void TestMission()
        {
            int val;
            string cmd;
            string reply;

            reply = Call(CLASSNAME, "TestStartMission");
        }

        public void TestWriteLog()
        {
            throw new NotImplementedException();
        }

        public void TestReadLog()
        {
            throw new NotImplementedException();
        }

        public void TestBulkErase()
        {
            throw new NotImplementedException();
        }

        public void TestLogSectorsErase()
        {
            throw new NotImplementedException();
        }
    }
}
