Exemple #1
0
    public static void Main(string[] args)
    {
        if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["COMport"]))
            COMPort = Int32.Parse(ConfigurationManager.AppSettings["COMport"]);

        if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["targetHR"]))
            File_targetHR = Int32.Parse(ConfigurationManager.AppSettings["targetHR"]);

        Console.WriteLine ("ESOMA Data Processing Server");
        allHRcalc=new List<int>();
        allOXcalc=new List<int>();
        allEAcalc=new List<double>();
        HRtarget=new double[2];
        StartPulseOX();
        StartServer();
        do{
            if(!indivo_init){
                if(serv.IsClientConnected("INDIVO")){
                    _indivoInit=new IndivoInitialization("rpoole","rpoole-dope75");
                    Console.WriteLine("INITIALIZE INDIVO:" +_indivoInit.ToString());
                    serv.SendToClient("INITIALIZE|"+_indivoInit.ToString()+"|","INDIVO");
                    indivo_init=true;
                }
            }else if(serv.IsClientConnected("UNITY") && !unity_init && sexercisePlan!=""){
                unity_init=true;
                Console.WriteLine(sexercisePlan);
                _indivoPlan = new IndivoExercisePlan(sexercisePlan);
            //	Console.WriteLine("hola");
                SetHRtarget();
                _indivoResults = new IndivoExerciseResult(new ExerciseResult(),_indivoPlan.AccountID);
                _indivoResults.Result.exerciseGroups = new System.Collections.Generic.List<ExerciseResultExerciseGroup>();
                _indivoResults.Result.exerciseGroups.Add(new ExerciseResultExerciseGroup());
                _indivoResults.Result.exerciseGroups[0].exercises = new System.Collections.Generic.List<ExerciseResultExerciseGroupExercise>();
                ControlProgress();
            }
            if(!serv.IsClientConnected("UNITY")){
                unity_init=false;
                cen=-1;
            }

        }while(!exit);
        serv.SendToClient("ENDSESSION|"+_indivoResults.ToString()+"|","INDIVO");
        Console.WriteLine("ENDSESSION|"+_indivoResults.ToString()+"|");
        pulse.ClosePulseOX();
    }
        public Patient(TCPServer serv)
        {
            _serv = serv;
              _serv.DataManager += new DataManager(onDataReceived);

              data.Add("Mass", 60.0);
              data.Add("Height", 160.0);// cm

              EsomaSharedDocuments.IndivoInitialization _indivoInit;

              bool indivo_init=false;

              do{
            if(serv.IsClientConnected("INDIVO")){
              _indivoInit = new IndivoInitialization("rpoole","rpoole-dope75");
              Console.WriteLine("INITIALIZE INDIVO:" +_indivoInit.ToString());
              serv.SendToClient("INITIALIZE|"+_indivoInit.ToString()+"|","INDIVO");
              indivo_init=true;
            } else System.Threading.Thread.Sleep(1000);
              } while((indivo_init == false));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            string serverIp = "localhost";
            int serverPort = 10000;
            bool testMode = false;

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[IP_KEY]))
                serverIp = ConfigurationManager.AppSettings[IP_KEY];

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[PORT_KEY]))
                serverPort = Int32.Parse(ConfigurationManager.AppSettings[PORT_KEY]);

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[TESTMODE_KEY]))
                testMode = bool.Parse(ConfigurationManager.AppSettings[TESTMODE_KEY]);

            if (!testMode)
            {
                using (_client = new TCPClient(serverIp, serverPort))
                {
                    _client.UserName = CONNECT_NAME;
                    _client.DataManager += HandleClientDataManager;
                    _client.Connect();

                    while (_continue)
                    {
                        /*
                        if (_isConnected && _isReceiving && (_lastReceived - DateTime.Now).Seconds > 5)
                        {
                            _isReceiving = false;
                            _lastReceived = DateTime.MinValue;
                        }
                        */
                    }
                }
            }
            else // run testing code
            {
                DataRequestor dr = new DataRequestor();
                IndivoInitialization init = new IndivoInitialization("rpoole", "rpoole-dope75");

                string accountId = dr.Login(init.UserName, init.Password);
                ExercisePlan exPlan = dr.GetExercisePlan(accountId);
                Demographics demo = dr.GetDemographics(accountId);
                IndivoExercisePlan plan = CreateIndivoExercisePlan(accountId, exPlan, demo);
                Console.WriteLine(plan.Plan.exerciseGroups.Count);
                plan = plan.GetTodaysExercisePlan();
                Console.WriteLine(plan.Plan.exerciseGroups.Count);
            }

            return;
        }
Exemple #4
0
        private static void InitializeIndivo(string[] dataArray)
        {
            Console.WriteLine("Initializing");

            if (dataArray.Length > 1)
            {
                string jsonString = dataArray[1];
                Console.WriteLine(jsonString);
                IndivoInitialization init = new IndivoInitialization(jsonString);

                Console.WriteLine("Getting init data from indivo using username: "******" and password: " + init.Password);

                DataRequestor dr = new DataRequestor();
                string accountId = dr.Login(init.UserName, init.Password);
                Demographics demo = dr.GetDemographics(accountId);
                ExercisePlan exPlan = dr.GetExercisePlan(accountId);
                IndivoExercisePlan plan = CreateIndivoExercisePlan(accountId, exPlan, demo);
                //plan = plan.GetTodaysExercisePlan();

                SendExercisePlan(plan);
            }
            else //no data from server
            {
                _continue = false;
            }
        }