Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------
        private void fn_UpdateMotorStatus()
        {
            for (int j = 0; j < motStatusdataTable.Rows.Count; j++)
            {
                //
                if (MOTR.fn_IsSMCMotor((EN_MOTR_ID)j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ENABLED] = MOTR[j].GetServo() ? "ON" : "OFF";
                    motStatusdataTable.Rows[j]["SBACK"] = MOTR[j].GetServo() ? "Green" : "LightGray";

                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.HOME] = MOTR[j].GetHomeEnd() ? "ON" : "OFF";
                    motStatusdataTable.Rows[j]["HBACK"] = MOTR[j].GetHomeEnd() ? "Green" : "LightGray";

                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ALARM] = MOTR[j].GetAlarm() ? "ON" : "OFF";
                    motStatusdataTable.Rows[j]["ABACK"] = MOTR[j].GetAlarm() ? "Red" : "LightGray";

                    continue;
                }

                if (mc_Acs.fn_GetStateEnabled(j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ENABLED] = "ON";
                    motStatusdataTable.Rows[j]["SBACK"] = "Green";
                }
                else
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ENABLED] = "OFF";
                    motStatusdataTable.Rows[j]["SBACK"] = "LightGray";
                }

                if (mc_Acs.fn_GetStateAlarmAll(j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ALARM] = "ON";
                    motStatusdataTable.Rows[j]["ABACK"] = "Red";
                }
                else
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ALARM] = "OFF";
                    motStatusdataTable.Rows[j]["ABACK"] = "LightGray";
                }

                if (mc_Acs.fn_GetStateMove(j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.MOVING] = "ON";
                    motStatusdataTable.Rows[j]["MBACK"] = "Green";
                }
                else
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.MOVING] = "OFF";
                    motStatusdataTable.Rows[j]["MBACK"] = "LightGray";
                }

                //
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.HOME] = MOTR[j].GetHomeEnd() ? "ON" : "OFF";
                motStatusdataTable.Rows[j]["HBACK"] = MOTR[j].GetHomeEnd()? "Green" : "LightGray";

                if (mc_Acs.fn_GetStateHardwareLeftLimit(j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.LIMIT_LEFT] = "ON";
                    motStatusdataTable.Rows[j]["PBACK"] = "Red";
                }
                else
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.LIMIT_LEFT] = "OFF";
                    motStatusdataTable.Rows[j]["PBACK"] = "LightGray";
                }

                if (mc_Acs.fn_GetStateHardwareRightLimit(j))
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.LIMIT_RIGHT] = "ON";
                    motStatusdataTable.Rows[j]["NBACK"] = "Red";
                }
                else
                {
                    motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.LIMIT_RIGHT] = "OFF";
                    motStatusdataTable.Rows[j]["NBACK"] = "LightGray";
                }

                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.POSITION_R] = Math.Round(mc_Acs.fn_GetTargetPosition(j), 3);
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.POSITION_F] = Math.Round(mc_Acs.fn_GetEncoderPosition(j), 3);
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.JERK]       = Math.Round(mc_Acs.fn_GetParameterJerk(j), 3);
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.VELOCITY_F] = Math.Round(mc_Acs.fn_GetParameterVelocity(j), 3);
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.ACC]        = Math.Round(mc_Acs.fn_GetParameterAcceleration(j), 3);
                motStatusdataTable.Rows[j][(int)EN_MOTOR_STATUS.DEC]        = Math.Round(mc_Acs.fn_GetParameterAcceleration(j), 3);
            }
        }