示例#1
0
        public IHttpActionResult RunDish(JObject data)
        {
            //var context = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
            //context.Clients.All.ShowMessage("eee");

            try
            {
                if (m_connected == false)
                {
                    return(Ok("ok"));
                }
                dynamic json       = data;
                string  dishname   = json.Name;
                string  dishscript = json.Script;

                int minutes = json.TimeToRun.Minutes;
                int seconds = json.TimeToRun.Seconds;


                DishBuilder dish = new DishBuilder(dishname);
                dish.SetScript(dishscript);

                //TimeSpan time = dish.getTotalTime();


                try
                {
                    File.Delete("c:\\log.txt");
                }
                catch (Exception err)
                {
                }

                TimeSpan time = new TimeSpan(0, minutes, seconds);
                string   str  = time.Minutes.ToString("00") + ":" + time.Seconds.ToString("00");

                var context = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();
                context.Clients.All.UpdateClock(str);

                string astr = json.AlphaConstant;
                int    a    = int.Parse(astr);
                m_motor.SetAlphaConstant(a);
                m_motor.RunScript(dish, time, true);
                return(Ok("ok"));
            }
            catch (Exception err)
            {
                return(Content(System.Net.HttpStatusCode.BadRequest, err.Message));
            }
        }
示例#2
0
 private void textBox7_TextChanged(object sender, EventArgs e)
 {
     if (m_initialized == false)
     {
         Initialize();
     }
     if (m_motor != null)
     {
         try
         {
             double a = int.Parse(textBox7.Text);
             m_motor.SetAlphaConstant((int)a);
         }
         catch (Exception err)
         {
         }
     }
 }
示例#3
0
 void Initialize()
 {
     lock (this)
     {
         try
         {
             Control.CheckForIllegalCrossThreadCalls = false;
             PhidgetMotor.MotorCallback p = new PhidgetMotor.MotorCallback(MotorFunctionCallback);
             m_motor = new GojiMotor(p);
             m_motor.SetMotorLength(int.Parse(textBox3.Text));
             m_motor.SetAlphaConstant(60);
             m_initialized = true;
         }
         catch (Exception err)
         {
             MessageBox.Show(err.Message);
         }
     }
 }