demo project
Dependencies: AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL
Diff: ArmController.cpp
- Revision:
- 15:4bd10f531cdc
- Parent:
- 14:570c8071f577
- Child:
- 17:0dbcbd8587fd
--- a/ArmController.cpp Fri Jan 15 23:10:30 2016 +0000 +++ b/ArmController.cpp Tue Jan 19 19:50:07 2016 +0000 @@ -157,7 +157,6 @@ NextSendMs = (int)IdleTimer.read_ms() + SEND_STATUS_TO; MainState = MS_Running; - NodeMeasure nextMetric = NM_Temperature; while( true ) { @@ -198,8 +197,6 @@ curseq = NULL; robotArm.MoveArmPositionsEnd(); MainState = MS_Running; - // avoid next poll delay - NextPollMs = now; break; case MS_CancelAll: @@ -210,15 +207,11 @@ if (evt.status != osEventMessage) break; } - // avoid next poll delay - NextPollMs = now; MainState = MS_Running; break; case MS_Resuming: robotArm.MoveArmPositionsResume(); - // avoid next poll delay - NextPollMs = now; MainState = MS_Running; break; @@ -303,9 +296,10 @@ bool sendAlert = MainState != MS_Error; // get measurements and test thresholds - // Reading all values takes too long, - // so we read the load and 1 other value each time int rc = 0; + // call start to clear cached values + robotArm.ArmMeasuresTestStart(); + rc = robotArm.ArmMeasuresTest(NM_Load); if (rc == -1 && sendAlert) { @@ -313,43 +307,27 @@ MainState = MS_Error; } - switch (nextMetric) + rc = robotArm.ArmMeasuresTest(NM_Temperature); + if (rc == -1 && sendAlert) + { + PushTemperatureAlert(robotArm); + MainState = MS_Error; + } + + rc = robotArm.ArmMeasuresTest(NM_Voltage); + if (rc == -1 && sendAlert) { - case NM_Temperature: - rc = robotArm.ArmMeasuresTest(NM_Temperature); - if (rc == -1 && sendAlert) - { - PushTemperatureAlert(robotArm); - MainState = MS_Error; - } - nextMetric = NM_Voltage; - break; - - case NM_Voltage: - rc = robotArm.ArmMeasuresTest(NM_Voltage); - if (rc == -1 && sendAlert) - { - PushVoltageAlert(robotArm); - MainState = MS_Error; - } - nextMetric = NM_Degrees; - break; - - - case NM_Degrees: - rc = robotArm.ArmMeasuresTest(NM_Degrees); - if (rc == -1 && sendAlert) - { - PushPositionAlert(robotArm); - MainState = MS_Error; - } - nextMetric = NM_Temperature; - break; + PushVoltageAlert(robotArm); + MainState = MS_Error; + } - default: - nextMetric = NM_Temperature; - break; + rc = robotArm.ArmMeasuresTest(NM_Degrees); + if (rc == -1 && sendAlert) + { + PushPositionAlert(robotArm); + MainState = MS_Error; } + if (rc == -2 && sendAlert) { int partix = robotArm.GetLastErrorPart();