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)); } }
private void button1_Click(object sender, EventArgs e) { try { if (m_connected == false) { MessageBox.Show("Motor is not connected"); return; } saveSettings(); if (textBox4.Text == "") { MessageBox.Show("Script is empty"); return; } if (m_initialized == false) { Initialize(); } if (m_motor.IsRunning() == true) { MessageBox.Show("Already running"); return; } try { File.Delete("c:\\log.txt"); } catch (Exception err) { } try { DishBuilder d = new DishBuilder("Potato"); //string script = "name:potato;loop:2;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10;loopend;loop:2;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10;loopend"; //string script = "name:potato;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10"; //string script = "name:potato;loop:2;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10;move:40;wait:2;move:20;wait:1;move:40;wait:2;move:10;loopend"; string script = textBox4.Text; d.SetScript(script); m_dish.Add(d); int miniute = int.Parse(txtMin.Text); int seconds = int.Parse(txtSec.Text); TimeSpan time1 = new TimeSpan(0, miniute, seconds); if (m_clockMode == CLOCK_MODE.OVERAL_CLOCK) { string str = time1.Minutes.ToString("00") + ":" + time1.Seconds.ToString("00"); lblTime.Text = str; m_motor.RunScript(d, time1, true); } else { TimeSpan time = d.getTotalTime(); string str = time.Minutes.ToString("00") + ":" + time.Seconds.ToString("00"); lblTime.Text = str; m_motor.RunScript(d, true); } } catch (Exception err) { MessageBox.Show(err.Message); } } catch (Exception err) { MessageBox.Show(err.Message); } }