public Form1(string[] args)
        {
            InitializeComponent();
            loadArgument  = args;
            programConfig = ProgramConfig.Instance;
            if (programConfig.FilePozition != null)
            {
                filePozition.Text = programConfig.FilePozition;
            }

            //comboBox
            comboBox.Items.Clear();
            int portCount = 0;

            foreach (string portName in System.IO.Ports.SerialPort.GetPortNames())
            {
                comboBox.Items.Add(portName);
                portCount++;
            }
            if (portCount > programConfig.PortNum)
            {
                comboBox.SelectedIndex = programConfig.PortNum;
            }

            comboHomeMode.SelectedIndex = 0;
            serialPort = new Serial(serialPortBase);

            //trackBar
            trackBar_A.Maximum = Convert.ToInt32(Serial.qAmin);
            trackBar_A.Maximum = Convert.ToInt32(Serial.qAmax);

            trackBar_B.Maximum = Convert.ToInt32(Serial.qBmin);
            trackBar_B.Maximum = Convert.ToInt32(Serial.qBmax);

            trackBar_C.Maximum = Convert.ToInt32(Serial.qCmin);
            trackBar_C.Maximum = Convert.ToInt32(Serial.qCmax);

            trackBar_D.Maximum = Convert.ToInt32(Serial.qDmin);
            trackBar_D.Maximum = Convert.ToInt32(Serial.qDmax);

            trackBar_E.Maximum = Convert.ToInt32(Serial.qEmin);
            trackBar_E.Maximum = Convert.ToInt32(Serial.qEmax);

            trackBar_F.Maximum = Convert.ToInt32(Serial.qFmin);
            trackBar_F.Maximum = Convert.ToInt32(Serial.qFmax);

            //passing
            Passing.ContextStrategy   = programConfig.Strategy;
            Passing.SentPointFunction = serialPort.Write;

            RX_data   = new Queue <char>();
            send      = new Task(() => { });
            execution = new Task(() => { });
            send.Start();
            execution.Start();

            connectButton.Text      = "отк";
            connectButton.BackColor = System.Drawing.Color.Tomato;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (loadArgument.Length > 0)
            {
                string filename = loadArgument[0]; //openPointFile.SafeFileName;--если нужно расширение
                // читаем файл в строку
                filePozition.Text = filename;
                LoadListButton_Click(sender, e);
                LoadListButton.Enabled = false;

                programConfig = ProgramConfig.Instance;
            }
        }
Exemple #3
0
 private static void Save()
 {
     try
     {
         string Path = $"{Environment.CurrentDirectory}\\programConfig.progc";
         using (StreamWriter sr = new StreamWriter(Path, false))
         {
             ProgramConfig prog = ProgramConfig.Instance;
             sr.WriteLine(JsonConvert.SerializeObject(prog));
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemple #4
0
 private static void Load()
 {
     try
     {
         string        Path = $"{Environment.CurrentDirectory}\\programConfig.progc";
         var           data = File.ReadAllText(Path);//File.ReadAllText($"{Environment.CurrentDirectory}\\{Path}");
         ProgramConfig p    = JsonConvert.DeserializeObject <ProgramConfig>(data);
     }
     catch (FileNotFoundException)
     {
         ProgramConfig p = ProgramConfig.Instance;
         p.Speed   = 9600;
         p.PortNum = 0;
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }