using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChamChat.Models;

namespace ChamChat
{
    public partial class PLxKPH_Client : Client
    {
        // Run a single step. 
        // The last setting is held when the program ends.
        // See page 60.
        public Boolean Start(Double DurationMin, Double StartT, Double TargetT, Double StartRH, Double TargetRH )
        {

            // Example: RUN PRGM, TEMP10.0 GOTEMP23.0 HUMI85 GOHUMI100 TIME1:00
            string sAddr = _Address.ToString();
            string cmd;
            string read;

            cmd = sAddr + ", RUN PRGM, ";

            cmd += string.Format("TEMP{0:0.0} ", StartT);
            if (StartT != TargetT) // Ramping required
                cmd += string.Format("GOTEMP{0:0.0} ", TargetT);

            if (TargetRH > 0)
            {
                cmd += string.Format("HUMI{0:0} ", StartRH);
                if (StartRH != TargetRH) // Ramping required
                    cmd += string.Format("GOHUMI{0:0} ", TargetRH);
            }
            else cmd += "HUMI OFF "; // No RH set

            double hrs = Math.Floor(DurationMin/60);
            double min = Math.Floor(DurationMin - hrs * 60);
            cmd += String.Format("TIME{0:0}:{1:0}", hrs, min);
           
            return DataTransfer(cmd, out read, _ReturnDataWaitms);
        }
    
    
    }
}
