comments fixed
This commit is contained in:
parent
a98fb8d2fd
commit
7f23e3f994
|
@ -1,15 +1,15 @@
|
||||||
#include <rtai_mbx.h>
|
/*#include <rtai_mbx.h>
|
||||||
#include <rtai_sched.h>
|
#include <rtai_sched.h>
|
||||||
#include <rtai_sem.h>
|
#include <rtai_sem.h>
|
||||||
#include <sys/rtai_modbus.h>
|
#include <sys/rtai_modbus.h>*/
|
||||||
|
|
||||||
//#include "include/rtai_mbx.h"
|
#include "include/rtai_mbx.h"
|
||||||
//#include "include/rtai_sched.h"
|
#include "include/rtai_sched.h"
|
||||||
//#include "include/rtai_sem.h"
|
#include "include/rtai_sem.h"
|
||||||
//#include "include/rtai_modbus.h"
|
#include "include/rtai_modbus.h"
|
||||||
//#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <uint128.h>
|
//#include <uint128.h>
|
||||||
|
|
||||||
#define SENSOR_PART_TURNTABLE 1<<0
|
#define SENSOR_PART_TURNTABLE 1<<0
|
||||||
#define SENSOR_PART_DRILL 1<<1
|
#define SENSOR_PART_DRILL 1<<1
|
||||||
|
@ -48,10 +48,11 @@ void end(bool fail) {
|
||||||
|
|
||||||
rt_mbx_delete(&turntable_status_mbx);
|
rt_mbx_delete(&turntable_status_mbx);
|
||||||
rt_mbx_delete(&tester_status_mbx);
|
rt_mbx_delete(&tester_status_mbx);
|
||||||
rt_mbx_delete(&output_status_mbx);
|
|
||||||
rt_mbx_delete(&drill_status_mbx);
|
rt_mbx_delete(&drill_status_mbx);
|
||||||
rt_mbx_delete(&output_data_mbx);
|
rt_mbx_delete(&output_status_mbx);
|
||||||
|
rt_mbx_delete(&turntable_data_mbx);
|
||||||
rt_mbx_delete(&drill_data_mbx);
|
rt_mbx_delete(&drill_data_mbx);
|
||||||
|
rt_mbx_delete(&output_data_mbx);
|
||||||
|
|
||||||
rt_sem_delete(&semaphore);
|
rt_sem_delete(&semaphore);
|
||||||
|
|
||||||
|
@ -64,10 +65,9 @@ void end(bool fail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* readData all bits of the specified type
|
* read all bits of the specified type
|
||||||
* this function is *not* thread safe.
|
* this function is *not* thread safe.
|
||||||
* @param type (DIGITAL_IN, DIGITAL_OUT, ANALOG_IN, ANALOG_OUT)
|
* @param type (DIGITAL_IN, DIGITAL_OUT, ANALOG_IN, ANALOG_OUT)
|
||||||
* @param connection modbus connection id
|
|
||||||
* @param result value to write the result to
|
* @param result value to write the result to
|
||||||
* @return status code(0: success, 1: failure)
|
* @return status code(0: success, 1: failure)
|
||||||
*/
|
*/
|
||||||
|
@ -95,7 +95,6 @@ int readData(int part) {
|
||||||
/**
|
/**
|
||||||
* disable a specified actor of the system.
|
* disable a specified actor of the system.
|
||||||
* this function is thread safe.
|
* this function is thread safe.
|
||||||
* @param connection modbus connection id
|
|
||||||
* @param actor bitmask of the actor to disable
|
* @param actor bitmask of the actor to disable
|
||||||
*/
|
*/
|
||||||
void disable(int actor) {
|
void disable(int actor) {
|
||||||
|
@ -111,7 +110,6 @@ void disable(int actor) {
|
||||||
/**
|
/**
|
||||||
* enable one specified actor of the system.
|
* enable one specified actor of the system.
|
||||||
* this function is thread safe.
|
* this function is thread safe.
|
||||||
* @param connection modbus connection id
|
|
||||||
* @param actor bitmask of the actor to enable
|
* @param actor bitmask of the actor to enable
|
||||||
*/
|
*/
|
||||||
void enable(int actor) {
|
void enable(int actor) {
|
||||||
|
@ -149,13 +147,14 @@ int receiveMailNonBlocking(MBX * mailbox) {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleepStuff(void) {
|
void sleepMs(int ms) {
|
||||||
rt_sleep(1000 * nano2count(1000000));
|
rt_sleep(ms * nano2count(1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void turntable(long data) {
|
static void turntable(long data) {
|
||||||
rt_printk("started turntable task\n");
|
rt_printk("started turntable task\n");
|
||||||
disable(ACTOR_TURNTABLE);
|
disable(ACTOR_TURNTABLE);
|
||||||
|
disable(ACTOR_ENTRANCE);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
receiveMail(&turntable_status_mbx);
|
receiveMail(&turntable_status_mbx);
|
||||||
|
@ -166,9 +165,9 @@ static void turntable(long data) {
|
||||||
int msg2 = receiveMailNonBlocking(&turntable_data_mbx);
|
int msg2 = receiveMailNonBlocking(&turntable_data_mbx);
|
||||||
if(partOnTable || msg1 || msg2) {
|
if(partOnTable || msg1 || msg2) {
|
||||||
enable(ACTOR_TURNTABLE);
|
enable(ACTOR_TURNTABLE);
|
||||||
sleepStuff();
|
sleepMs(1000);
|
||||||
disable(ACTOR_TURNTABLE);
|
disable(ACTOR_TURNTABLE);
|
||||||
sleepStuff();
|
sleepMs(1000);
|
||||||
}
|
}
|
||||||
sendMail(&tester_status_mbx, 1);
|
sendMail(&tester_status_mbx, 1);
|
||||||
sendMail(&drill_status_mbx, 1);
|
sendMail(&drill_status_mbx, 1);
|
||||||
|
@ -187,7 +186,7 @@ static void tester(long data) {
|
||||||
if(partOnTable) {
|
if(partOnTable) {
|
||||||
sendMailNonBlocking(&turntable_data_mbx, 1);
|
sendMailNonBlocking(&turntable_data_mbx, 1);
|
||||||
enable(ACTOR_TESTER);
|
enable(ACTOR_TESTER);
|
||||||
sleepStuff();
|
sleepMs(1000);
|
||||||
int partNormal = readData(SENSOR_PART_TEST);
|
int partNormal = readData(SENSOR_PART_TEST);
|
||||||
if(partNormal) {
|
if(partNormal) {
|
||||||
sendMailNonBlocking(&drill_data_mbx, 1);
|
sendMailNonBlocking(&drill_data_mbx, 1);
|
||||||
|
@ -228,7 +227,7 @@ static void drill(long data) {
|
||||||
do {
|
do {
|
||||||
} while (readData(SENSOR_DRILL_DOWN) == 0);
|
} while (readData(SENSOR_DRILL_DOWN) == 0);
|
||||||
}
|
}
|
||||||
sleepStuff();
|
sleepMs(1000);
|
||||||
disable(ACTOR_DRILL);
|
disable(ACTOR_DRILL);
|
||||||
disable(ACTOR_DRILL_DOWN);
|
disable(ACTOR_DRILL_DOWN);
|
||||||
enable(ACTOR_DRILL_UP);
|
enable(ACTOR_DRILL_UP);
|
||||||
|
@ -256,7 +255,7 @@ static void output(long data) {
|
||||||
|
|
||||||
if(msg) {
|
if(msg) {
|
||||||
enable(ACTOR_EXIT);
|
enable(ACTOR_EXIT);
|
||||||
sleepStuff();
|
sleepMs(1000);
|
||||||
disable(ACTOR_EXIT);
|
disable(ACTOR_EXIT);
|
||||||
}
|
}
|
||||||
sendMail(&turntable_status_mbx, 1);
|
sendMail(&turntable_status_mbx, 1);
|
||||||
|
|
Loading…
Reference in New Issue