private void SpeedDetection_Load(object sender, EventArgs e) { pc = new PortControl(0); pc.AnalogPortConfigurationIn(); pc.AnalogPortConfigurationOut(); pc.DigitalConfigurationOut(); }
public IEnumerator Out(int data) { yield return(new WaitForEndOfFrame()); PortControl.Output(decAdd, data); Invoke("Close", 0.2f); }
IEnumerator test() { for (int i = 0; i < 50; i++) { for (float interval = 0.4f; interval <= 2.0f; interval += 0.4f) { var start = DateTime.Now; PortControl.Output(decAdd, 255); yield return(new WaitForSeconds(0.2f)); var end = DateTime.Now; PortControl.Output(decAdd, 0); yield return(new WaitForSeconds(interval - 0.2f)); //PortcontrolTestWriter.I.Write(start, end); } } for (int i = 0; i < 50; i++) { for (float interval = 0.4f; interval <= 2.0f; interval += 0.4f) { var start = DateTime.Now; PortControl.Output(decAdd, 255); yield return(new WaitForSeconds(interval)); var end = DateTime.Now; PortControl.Output(decAdd, 0); yield return(new WaitForSeconds(interval)); //PortcontrolTestWriter.I.Write(start, end); } } label.SetActive(true); }
public AddWindow(PortControl portControl) { InitializeComponent(); control = portControl; DataContext = portControl; TypeCombo.SelectedIndex = 0; }
void Start() { if (!PortControl.IsInpOutDriverOpen()) { Debug.Log("Driver is not opened !!!"); return; } }
private void Replay_Load(object sender, EventArgs e) { pc = new PortControl(0); pc.AnalogPortConfigurationIn(); pc.AnalogPortConfigurationOut(); pc.DigitalConfigurationOut(); timer1.Interval = 100; }
public MainWindow(PortControl control) { portControl = control; DataContext = portControl; InitializeComponent(); Closed += (o, e) => portControl.StopLogChecker(); Closed += (o, e) => portControl.StopSimulation(); }
/// <summary> /// 按钮选中 /// </summary> /// <param name="arg1"></param> /// <param name="arg2"></param> private void deviceInfoItem_SelectedHandler(object arg1, bool arg2) { PortControl portControl = arg1 as PortControl; foreach (PortControl item in canvasMain.Children) { item.IsSelected = item.Name.Equals(portControl.Name); } }
void Start() { if (!PortControl.IsInpOutDriverOpen()) { Debug.Log("Driver is not opened !!!"); return; } else { StartCoroutine(test()); } }
void Update() { if (open) { decData = 255; PortControl.Output(decAdd, decData); } else { decData = 0; PortControl.Output(decAdd, decData); } }
public static List <string> GetActiveActions(PlayerIndex pi = PlayerIndex.One) { PortControl pc = PortControls[pi]; if (pc.InputType == InputType.GamePad) { return(new List <string>(pc.GamePadMap.Keys)); } else { return(new List <string>(pc.KeyboardMap.Keys)); } }
private void Form1_Load(object sender, EventArgs e) { pc = new PortControl(0); pc.AnalogPortConfigurationIn(); pc.DigitalConfigurationOut(); pc.AnalogPortConfigurationOut(); ifStartDebugMode = true; timer1.Interval = 100; timer2.Interval = 100; }
public static Keys GetRecentKey(PlayerIndex pi = PlayerIndex.One) { PortControl PC = PortControls[pi]; if (PC.InputType != InputType.Keyboard) { return(0); } Keys[] k = KeyboardState.GetPressedKeys(); if (k.Length == 0 || LastKeyboardState.IsKeyDown(k[0])) { return(0); } return(k[0]); }
private void btnBaglanti_Baglan_Click(object sender, EventArgs e) { try { if (cbPorts.SelectedItem != null) { rbBaglantiDurumu.Text = "Bekleyiniz..."; pc = new PortControl(cbPorts.SelectedItem.ToString(), 4000, 4000); if (pc.f_Connection(true)) { rbBaglantiDurumu.Checked = true; rbBaglantiDurumu.Text = "Bağlandi"; btnBaglanti.Text = "Bağlantıyı Kes"; btnUpdate.Enabled = true; btnBaglanti.Click -= btnBaglanti_Baglan_Click; btnBaglanti.Click += btnBaglanti_BaglantiyiKes_Click; } else { rbBaglantiDurumu.Checked = false; rbBaglantiDurumu.Text = "Baglantı Yok!"; } } } catch (TimeoutException tex) { tex.LogException("Seri porta bağlanma zaman aşımına uğradı."); rbBaglantiDurumu.Text = "..."; MessageBox.Show("Bağlantı zaman aşımına uğradı. HATA:\n" + tex.Message, "Port Bağlantısı", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (UnauthorizedAccessException uaEx) { uaEx.LogException("Seri porta bağlanma yetkisiz erişim nedeniyle istisnaya neden oldu."); rbBaglantiDurumu.Text = "..."; MessageBox.Show(pc.M_PortName + " Portuna erişim yetkiniz yok! HATA:\n" + uaEx, "Port Bağlantısı", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { ex.LogException("Seri porta bağlanma esnasında genel istisna meydana geldi."); rbBaglantiDurumu.Text = "..."; MessageBox.Show(ex.ToString(), "Port Bağlantısı", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Form1() { InitializeComponent(); this.FormClosing += Form1_FormClosing; portControl = new PortControl(gboxPort); multiCommands(); portControl.refurbishPortNme(cbboxPort); //串口列表更新 portControl.refubishBaudRate(cbboxBaud); //波特率添加 form5.TopMost = true; lstBoxRe = form5.listBox1; lstBoxRe.Width = this.tboxSend.Width; lstBoxRe.KeyPress += LstBoxRe_KeyPress; lstBoxRe.KeyDown += LstBoxRe_KeyDown; lstBoxRe.DoubleClick += LstBoxRe_DoubleClick; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); thisX = Size.Width; thisY = Size.Height; }
public static Buttons GetRecentButton(PlayerIndex pi = PlayerIndex.One) { PortControl pc = PortControls[pi]; if (pc.InputType != InputType.GamePad) { return(0); } System.Array inputs = Enum.GetValues(typeof(Buttons)); foreach (Buttons input in inputs) { if (pc.GamePadState.IsButtonDown(input) && !pc.LastGamePadState.IsButtonDown(input)) { return(input); } } return(0); }
private void btnBaglanti_Baglan_Click(object sender, EventArgs e) { try { if (cbPorts.SelectedItem != null) { rbBaglantiDurumu.Text = "Bekleyiniz..."; pc = new PortControl(cbPorts.SelectedItem.ToString(), 4000, 4000); if (pc.f_Connection(true)) { rbBaglantiDurumu.Checked = true; rbBaglantiDurumu.Text = "Bağlandi"; btnBaglanti.Text = "Bağlantıyı Kes"; btnBaglanti.Click -= btnBaglanti_Baglan_Click; btnBaglanti.Click += btnBaglanti_BaglantiyiKes_Click; } else { rbBaglantiDurumu.Checked = false; rbBaglantiDurumu.Text = "Baglantı Yok!"; } } } catch (TimeoutException tex) { rbBaglantiDurumu.Text = "..."; MessageBox.Show("Bağlantı zaman aşımına uğradı. HATA:\n" + tex.Message); } catch (UnauthorizedAccessException uaEx) { rbBaglantiDurumu.Text = "..."; MessageBox.Show(pc.M_PortName + " Portuna erişim yetkiniz yok! HATA:\n" + uaEx); } catch (Exception ex) { rbBaglantiDurumu.Text = "..."; MessageBox.Show(ex.ToString()); } }
public static string[] DecodeAction(string action, PlayerIndex pi = PlayerIndex.One) { PortControl pc = PortControls[pi]; return(pc.DecodeAction(action)); }
private void f_PortlariBagla() { cbPorts.Items.Clear(); cbPorts.Items.AddRange(PortControl.f_GetPorts()); cbPorts.SelectedIndex = 1; }
public Commander(PortControl pc, System.Windows.Forms.ProgressBar pb) { M_PortControl = pc; this.pb = pb; }
public Commander(PortControl _pc) { M_PortControl = _pc; }
public LeftToday(PortControl control) { InitializeComponent(); DataContext = control; }
private void CreatGrid() { Dictionary <string, string> firstSource = new Dictionary <string, string>(); // 优先端口 firstSource.Add("0", "----"); int row = AppConfigInfos.AppStateInfos.FaceplateRow; int column = AppConfigInfos.AppStateInfos.FaceplateColumn; sv.HorizontalScrollBarVisibility = column <= 4 ? ScrollBarVisibility.Disabled : ScrollBarVisibility.Auto; sv.VerticalScrollBarVisibility = row <= 5 ? ScrollBarVisibility.Disabled : ScrollBarVisibility.Auto; int itemWith = 173; int itemHeight = 81; double spaceHeight = 5; double spaceWidth = 5; canvasMain.Width = column * (itemWith + spaceWidth); canvasMain.Height = row * (itemHeight + spaceHeight); Style syPort = TryFindResource("syPort") as Style; string portMark = TryFindResource("appMainInventedPort").ToString(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { int index = i * column + j + 1; PortControl portControl = new PortControl() { Name = "prot" + index, InventedIndex = index, Width = itemWith, Height = itemHeight, Style = syPort }; portControl.Source = AppConfigInfos.PortDeviceList.PortevList; PortPairInfo portPairInfo = AppConfigInfos.PortPairInfos.Find(p => p.Index.Equals(index.ToString())); if (portPairInfo != null) { portControl.OldPhysicsCode = portPairInfo.PortCode; } firstSource.Add(index.ToString(), portMark + index); PortControlList.Add(portControl); portControl.SelectedHandler += deviceInfoItem_SelectedHandler; portControl.ChangeValueHandler += portControl_ChangeValueHandler; double left = (itemWith + spaceWidth) * j; double top = (itemHeight + spaceHeight) * i; Canvas.SetLeft(portControl, left); Canvas.SetTop(portControl, top); canvasMain.Children.Add(portControl); } } cbFirst.SelectedValuePath = "Key"; cbFirst.DisplayMemberPath = "Value"; cbFirst.ItemsSource = firstSource; if (string.IsNullOrEmpty(AppConfigInfos.PortDeviceList.FirstPort)) { cbFirst.SelectedIndex = 0; } else { cbFirst.SelectedValue = AppConfigInfos.PortDeviceList.FirstPort; } }
private void Form1_Load(object sender, EventArgs e) { pc = new PortControl(0); pc.AnalogPortConfigurationIn(); pc.AnalogPortConfigurationOut(); pc.DigitalConfigurationOut(); pc.ClearALLDigitalPort(); positionForEverySequence = new List <List <float> >(); torqueForEverySequence = new List <List <float> >(); RightOrLeftForEverySequence = new List <List <int> >(); cc = new CoreControl(); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 StreamReader sR = File.OpenText(Application.StartupPath + "\\set-1.txt"); int length = int.Parse(sR.ReadLine()); for (int i = 0; i != length; i++) { string temp = sR.ReadLine(); if (temp == "Train") { trainOrTest_1.Add(true); experimentTime_1.Add(int.Parse(sR.ReadLine())); lbExpSequence_1.Items.Add(trainOrTest_1.Count.ToString("00") + " " + "Train " + experimentTime_1[i] + "s"); } else { trainOrTest_1.Add(false); experimentTime_1.Add(int.Parse(sR.ReadLine())); lbExpSequence_1.Items.Add(trainOrTest_1.Count.ToString("00") + " " + "Test " + experimentTime_1[i] + "s"); } } sR.Close(); StreamReader sR2 = File.OpenText(Application.StartupPath + "\\set-2.txt"); int length2 = int.Parse(sR2.ReadLine()); for (int i = 0; i != length2; i++) { string temp = sR2.ReadLine(); if (temp == "Train") { trainOrTest_2.Add(true); experimentTime_2.Add(int.Parse(sR2.ReadLine())); lbExpSequence_2.Items.Add(trainOrTest_2.Count.ToString("00") + " " + "Train " + experimentTime_2[i] + "s"); } else { trainOrTest_2.Add(false); experimentTime_2.Add(int.Parse(sR2.ReadLine())); lbExpSequence_2.Items.Add(trainOrTest_2.Count.ToString("00") + " " + "Test " + experimentTime_2[i] + "s"); } } sR2.Close(); StreamReader sR3 = File.OpenText(Application.StartupPath + "\\set-2.txt"); int length3 = int.Parse(sR3.ReadLine()); for (int i = 0; i != length3; i++) { string temp = sR3.ReadLine(); if (temp == "Train") { trainOrTest_3.Add(true); experimentTime_3.Add(int.Parse(sR3.ReadLine())); lbExpSequence_3.Items.Add(trainOrTest_3.Count.ToString("00") + " " + "Train " + experimentTime_3[i] + "s"); } else { trainOrTest_3.Add(false); experimentTime_3.Add(int.Parse(sR3.ReadLine())); lbExpSequence_3.Items.Add(trainOrTest_3.Count.ToString("00") + " " + "Test " + experimentTime_3[i] + "s"); } } sR3.Close(); v = new visionStimulation(); v.Show(); timer1.Interval = 10; timer2.Interval = 100; }
private static void Initialize() { portControl = new PortControl(); portControl.LoadPortData(); }
void Close() { PortControl.Output(decAdd, 0); }
public SettedValues(PortControl _pc) { _portControl = _pc; }
public static bool IsGamePadConnected(PlayerIndex pi = PlayerIndex.One) { PortControl pc = PortControls[pi]; return(pc.GamePadState.IsConnected); }
public TurnedAwayWindow(PortControl control) { InitializeComponent(); DataContext = control; }
public InstantValues(PortControl _pc) { _portControl = _pc; }