예제 #1
0
        public static void Move(string port, int motorPause, ControlList controlList)
        {
            SerialPort    sPort = new SerialPort(port);
            StringBuilder sb    = new StringBuilder();

            try
            {
                sPort.Open();
                sb.Clear();
                foreach (IMovement m in controlList)
                {
                    // parses the IMovement into a Position if possible
                    // and writes it to the serial port
                    if (m is Position position)
                    {
                        sb.Append(motorPause);
                        sb.Append(';');
                        sb.Append(position.BasicAngle);
                        sb.Append(';');
                        sb.Append(position.SoulderAngle);
                        sb.Append(';');
                        sb.Append(position.EllbowAngle);
                        sb.Append(';');
                        sb.Append(position.HandAngle_ver);
                        sb.Append(';');
                        sb.Append(position.HandAngle_rot);
                        sb.Append(';');
                        sb.Append(position.Gripper);

                        sPort.Write(sb.ToString());
                        sPort.ReadExisting();   // wait for message
                    }
                    else
                    {
                        if (m is Pause)
                        {
                            Task.Delay(((Pause)m).Pause_ms);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sPort.Close();
            }
        }
예제 #2
0
        public MainInterfacefrm()
        {
            #region initialize
            InitializeComponent();
            // read config from file
            try
            {
                config = FileOperator.ReadConfig(configPath);
            }
            catch (Exception)
            {
                MessageBox.Show("Konfiguration konnte nicht gelesen werden.\nStandardkonfiguration wurde erstellt");
                config = new Configuration()
                {
                    EnginePause = 20
                };

                // add standard positions
            }
            controlList = new ControlList();

            #region initializeControls
            cboPorts.Items.AddRange(SerialPort.GetPortNames());
            numericEnginePause.Value = config.EnginePause;
            cboSavedPositions.Items.Add("slider input");
            cboSavedPositions.SelectedIndex = 0;
            foreach (SavedPosition p in config.StandardPositions)
            {
                cboSavedPositions.Items.Add(p.Name);
            }
            #endregion
            #endregion

            #region appearance
            MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance;
            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;

            materialSkinManager.ColorScheme = new ColorScheme(
                Primary.Orange400, Primary.Orange800,
                Primary.Orange500, Accent.DeepOrange700,
                TextShade.WHITE);
            #endregion
        }
예제 #3
0
 public static bool WriteMovement(string path, ControlList list)
 {
     return(true);
 }