|
|
@ -1,6 +1,10 @@ |
|
|
#include "SC828_DATA_table.h" |
|
|
#include "SC828_DATA_table.h" |
|
|
#include "Variable.h" |
|
|
#include "Variable.h" |
|
|
|
|
|
|
|
|
|
|
|
#define DBG_TAG "data.table" |
|
|
|
|
|
#define DBG_LVL DBG_LOG |
|
|
|
|
|
#include <rtdbg.h> |
|
|
|
|
|
|
|
|
// 系统数据状态表(表格)
|
|
|
// 系统数据状态表(表格)
|
|
|
IO_State_DATA data_table[] = { |
|
|
IO_State_DATA data_table[] = { |
|
|
{1001, 0, STR_COMM_COUNTER}, |
|
|
{1001, 0, STR_COMM_COUNTER}, |
|
|
@ -173,7 +177,7 @@ IO_State_DIO do_table[] = { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//AIO状态表
|
|
|
//AIO状态表
|
|
|
IO_State_AIO aio_table[] = { |
|
|
IO_State_AIO ai_table[] = { |
|
|
// --- AIO 输入(4001~4022)---
|
|
|
// --- AIO 输入(4001~4022)---
|
|
|
{4001, 0, STR_AIO_TEMP1}, |
|
|
{4001, 0, STR_AIO_TEMP1}, |
|
|
{4002, 0, STR_AIO_TEMP2}, |
|
|
{4002, 0, STR_AIO_TEMP2}, |
|
|
@ -197,7 +201,9 @@ IO_State_AIO aio_table[] = { |
|
|
{4020, 0, STR_AIO_FABRIC_CYCLE5}, |
|
|
{4020, 0, STR_AIO_FABRIC_CYCLE5}, |
|
|
{4021, 0, STR_AIO_FABRIC_CYCLE6}, |
|
|
{4021, 0, STR_AIO_FABRIC_CYCLE6}, |
|
|
{4022, 0, STR_AIO_PH}, |
|
|
{4022, 0, STR_AIO_PH}, |
|
|
|
|
|
}; |
|
|
// --- AO 输出(5001~5014)---
|
|
|
// --- AO 输出(5001~5014)---
|
|
|
|
|
|
IO_State_AIO ao_table[] = { |
|
|
{5001, 0, STR_AIO_HEAT_RATIO}, |
|
|
{5001, 0, STR_AIO_HEAT_RATIO}, |
|
|
{5002, 0, STR_AIO_COOL_RATIO}, |
|
|
{5002, 0, STR_AIO_COOL_RATIO}, |
|
|
{5003, 0, STR_AIO_MAIN_PUMP_SPEED}, |
|
|
{5003, 0, STR_AIO_MAIN_PUMP_SPEED}, |
|
|
@ -218,7 +224,8 @@ IO_STEP_DATA step_table[99]; |
|
|
|
|
|
|
|
|
const unsigned char DI_TABLE_SIZE = sizeof(di_table) / sizeof(di_table[0]); |
|
|
const unsigned char DI_TABLE_SIZE = sizeof(di_table) / sizeof(di_table[0]); |
|
|
const unsigned char DO_TABLE_SIZE = sizeof(do_table) / sizeof(do_table[0]); |
|
|
const unsigned char DO_TABLE_SIZE = sizeof(do_table) / sizeof(do_table[0]); |
|
|
const unsigned char AIO_TABLE_SIZE = sizeof(aio_table) / sizeof(aio_table[0]); |
|
|
const unsigned char AI_TABLE_SIZE = sizeof(ai_table) / sizeof(ai_table[0]); |
|
|
|
|
|
const unsigned char AO_TABLE_SIZE = sizeof(ao_table) / sizeof(ao_table[0]); |
|
|
const unsigned char DATA_TABLE_SIZE = sizeof(data_table) / sizeof(data_table[0]); |
|
|
const unsigned char DATA_TABLE_SIZE = sizeof(data_table) / sizeof(data_table[0]); |
|
|
|
|
|
|
|
|
void DATA_Table_Init(){ |
|
|
void DATA_Table_Init(){ |
|
|
@ -231,10 +238,15 @@ void DATA_Table_Init(){ |
|
|
do_table[i].current_state = 0; |
|
|
do_table[i].current_state = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(int i=0;i<AIO_TABLE_SIZE;i++) |
|
|
for(int i=0;i<AI_TABLE_SIZE;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
ai_table[i].current_Value = 0; |
|
|
|
|
|
} |
|
|
|
|
|
for(int i=0;i<AO_TABLE_SIZE;i++) |
|
|
{ |
|
|
{ |
|
|
aio_table[i].current_Value = 0; |
|
|
ao_table[i].current_Value = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(int i=0;i<DATA_TABLE_SIZE;i++) |
|
|
for(int i=0;i<DATA_TABLE_SIZE;i++) |
|
|
{ |
|
|
{ |
|
|
data_table[i].current_data = 0; |
|
|
data_table[i].current_data = 0; |
|
|
@ -354,3 +366,67 @@ void DATA_INSTRUCTION_STOP(){ |
|
|
rt_snprintf(SIDS2, 3,"000"); |
|
|
rt_snprintf(SIDS2, 3,"000"); |
|
|
rt_snprintf(SIDS3, 3,"000"); |
|
|
rt_snprintf(SIDS3, 3,"000"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据 pin 查找 current_Value |
|
|
|
|
|
* @param pin: 要查询的 PLC 地址(如 4001) |
|
|
|
|
|
* @return: 找到则返回 current_Value;未找到返回 INT16_MIN |
|
|
|
|
|
*/ |
|
|
|
|
|
rt_int16_t get_ai_value(int pin) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < AI_TABLE_SIZE; i++) { |
|
|
|
|
|
if (ai_table[i].pin == pin) { |
|
|
|
|
|
return ai_table[i].current_Value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return 0; // 表示未找到
|
|
|
|
|
|
} |
|
|
|
|
|
void get_ao_value(int pin,int16_t dat) |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < AO_TABLE_SIZE; i++) { |
|
|
|
|
|
if (ao_table[i].pin == pin) { |
|
|
|
|
|
ao_table[i].current_Value = dat; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void table_thread_entry(void *parameter) |
|
|
|
|
|
{ |
|
|
|
|
|
while (1) |
|
|
|
|
|
{ |
|
|
|
|
|
rt_thread_delay(1000); |
|
|
|
|
|
|
|
|
|
|
|
MTT = get_ai_value(4001)/10.0f; |
|
|
|
|
|
MUT = get_ai_value(4002)/10.0f; |
|
|
|
|
|
STTA = get_ai_value(4003)/10.0f; |
|
|
|
|
|
STTB = get_ai_value(4004)/10.0f; |
|
|
|
|
|
STTC = get_ai_value(4005)/10.0f; |
|
|
|
|
|
MTL = get_ai_value(4007); |
|
|
|
|
|
STLA = get_ai_value(4008); |
|
|
|
|
|
STLB = get_ai_value(4009); |
|
|
|
|
|
STLC = get_ai_value(4010); |
|
|
|
|
|
MTH = get_ai_value(4022); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
extern struct rt_memheap sram_DTCMRAM; |
|
|
|
|
|
static struct rt_thread dat_table_thread; |
|
|
|
|
|
static void *dat_comm_stack __attribute__((aligned(4)))= RT_NULL ; |
|
|
|
|
|
int data_table_th(void) |
|
|
|
|
|
{ |
|
|
|
|
|
rt_err_t dat_err; |
|
|
|
|
|
|
|
|
|
|
|
dat_comm_stack = rt_memheap_alloc(&sram_DTCMRAM, 1024); |
|
|
|
|
|
dat_err = rt_thread_init(&dat_table_thread, "dat_tab", table_thread_entry, RT_NULL,dat_comm_stack, 1024, 10, 10); |
|
|
|
|
|
|
|
|
|
|
|
if(dat_err != RT_EOK) |
|
|
|
|
|
{ |
|
|
|
|
|
LOG_E("Failed to create data table thread!"); |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
rt_thread_startup(&dat_table_thread); |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
INIT_APP_EXPORT(data_table_th); |
|
|
|