using System;
using Microsoft.SPOT;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using CPF;

using System.Text;
using System.Threading;
using HWModules;
using SWModules;
using Microsoft.SPOT.Hardware;
using SensorModules;


namespace CPFUnitTests
{
    [TestClass]
    public class OCR504UnitTest
    {
        private HWModules.MotherBoard mb;
        private void InitUT()
        {
            mb = HWModules.MotherBoard.Instance;
            mb.Enable12V();
            mb.Enable5V();
        }


        [TestMethod]
        public void TestOCR504()
        {
            InitUT();

            Radiometer1 radiometer1 = Radiometer1.Instance;

            MessageQueue messageQ = MessageQueue.Instance;

            radiometer1.init();

            Thread.Sleep(1000);

            radiometer1.sendPollSample();

            for (int i = 0; i < 5; i++)
            {
                messageQ.processQ();
                Thread.Sleep(500);
            }

            for (int i = 0; i < 5; i++)
            {
                Debug.Print("Sending pollSample");
                radiometer1.sendPollSample();

                for (int j = 0; j < 10; j++)
                {
                    if (messageQ.Count > 0)
                        messageQ.processQ();
                    else
                        Thread.Sleep(500);
                }
            }

            radiometer1.sendStartCommandMode();

            mb.DisableChannelPower(8);
            // mb.Disable12V();
            //mb.Disable5V();

        }
    }
}
