Exemplo n.º 1
0
        private void DataFillGo(StepMotorData temp, bool reset_pos)
        {
            NPozXTextBox.Text = temp.new_x.ToString();
            NPozYTextBox.Text = temp.new_y.ToString();

            if (reset_pos)
            {
                APozXTextBox.Text = temp.x.ToString();
                APozYTextBox.Text = temp.y.ToString();
            }

            NStanComboBox.SelectedIndex = NStanComboBox.Items.IndexOf(temp.state.ToString());
        }
Exemplo n.º 2
0
        private Byte[] USBPrepareOutBuffer(StepMotorData s, USB_DEFINES usb_def)
        {
            Byte[] OUTBuffer = new Byte[65];

            OUTBuffer[0] = 0;
            OUTBuffer[1] = (byte)usb_def;
            for (uint i = 2; i < 65; i++)
                OUTBuffer[i] = 0xFF;

            OUTBuffer[2] = (byte)(s.x & 0xff);
            OUTBuffer[3] = (byte)((s.x >> 8) & 0xff);
            OUTBuffer[4] = s.step_x;
            OUTBuffer[5] = (byte)(s.new_x & 0xff);
            OUTBuffer[6] = (byte)((s.new_x >> 8) & 0xff);
            OUTBuffer[7] = (byte)s.dir_x;
            OUTBuffer[8] = s.end_x1 == true ? (byte)1 : (byte)0;
            OUTBuffer[9] = s.end_x2 == true ? (byte)1 : (byte)0;

            OUTBuffer[10] = (byte)(s.y & 0xff);
            OUTBuffer[11] = (byte)((s.y >> 8) & 0xff);
            OUTBuffer[12] = s.step_y;
            OUTBuffer[13] = (byte)(s.new_y & 0xff);
            OUTBuffer[14] = (byte)((s.new_y >> 8) & 0xff);
            OUTBuffer[15] = (byte)s.dir_y;
            OUTBuffer[16] = s.end_y1 == true ? (byte)1 : (byte)0;
            OUTBuffer[17] = s.end_y2 == true ? (byte)1 : (byte)0;

            OUTBuffer[18] = (byte)s.state;

            OUTBuffer[19] = (byte)(s.feed_x & 0xff);
            OUTBuffer[20] = (byte)((s.feed_x >> 8) & 0xff);

            OUTBuffer[21] = (byte)(s.feed_y & 0xff);
            OUTBuffer[22] = (byte)((s.feed_y >> 8) & 0xff);

            OUTBuffer[23] = (byte)s.current;

            OUTBuffer[24] = (byte)s.controll_state;

            return OUTBuffer;
        }
Exemplo n.º 3
0
        private void DataFill(StepMotorData temp)
        {
            /*
            switch (currentUnits)
            {
                case Units.kroki:
                    temp.x /= 5;
                    temp.new_x /= 5;

                    temp.y /= 5;
                    temp.new_y /= 5;
                    break;

                case Units.mm:
                    temp.x /= 200;
                    temp.new_x /= 200;

                    temp.y /= 200;
                    temp.new_y /= 200;
                    break;
            }
            */
            APozXTextBox.Text = temp.x.ToString();
            DPozXTextBox.Text = temp.new_x.ToString();
            AkierXTextBox.Text = temp.dir_x.ToString();

            APozYTextBox.Text = temp.y.ToString();
            DPozYTextBox.Text = temp.new_y.ToString();
            AkierYTextBox.Text = temp.dir_y.ToString();

            AStanTextBox.Text = temp.state.ToString();

            AFeedXTextBox.Text = temp.feed_x.ToString();
            AFeedYTextBox.Text = temp.feed_y.ToString();

            //APWMTextBox.Text = temp.pwm_set.ToString();
            AKontrolaTextBox.Text = temp.controll_state.ToString();
            ANastawaTextBox.Text = temp.current.ToString();
            //ADCTextBox.Text = temp.adc_read.ToString();
        }
Exemplo n.º 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // program version
            this.Text = "DrillCAD v." + PublishVersion;

            // additional events
            this.canvas2D.MouseWheel += new MouseEventHandler(Canvas2D_MouseWheel);

            // usb state
            usb_state = USB_DEFINES.USB_CNC_NULL;

            // jednostki
            currentUnits = Units.kroki;
            JednostkiComboBox.SelectedIndex = JednostkiComboBox.Items.IndexOf(Units.kroki.ToString());

            // step motor init
            stepMotorDataIn.x = 0;
            stepMotorDataIn.new_x = 0;
            stepMotorDataIn.step_x = 0;
            stepMotorDataIn.dir_x = DIRECTION_OF_MOVEMENT.DIRECTION_STOP;
            stepMotorDataIn.end_x1 = false;
            stepMotorDataIn.end_x2 = false;

            stepMotorDataIn.y = 0;
            stepMotorDataIn.new_y = 0;
            stepMotorDataIn.step_y = 0;
            stepMotorDataIn.dir_y = DIRECTION_OF_MOVEMENT.DIRECTION_STOP;
            stepMotorDataIn.end_y1 = false;
            stepMotorDataIn.end_y2 = false;

            stepMotorDataIn.state = STATE_OF_MOVEMENT.STATE_MOVE;

            stepMotorDataIn.feed_x = STEP_MOTOR_MAX_FEED;
            stepMotorDataIn.feed_y = STEP_MOTOR_MAX_FEED;

            stepMotorDataIn.current = CURRENT.CURRENT_ON;
            stepMotorDataIn.controll_state = CONTROLL_STATES.CON_AUTOMATIC;

            stepMotorDataOut = stepMotorDataIn;

            DataFill(stepMotorDataIn);
            DataFillNew();
        }