g0b1vetx-board/Board/data.c
2584532475@qq.com 0f40dd8b17 网络自适应
2024-09-10 11:51:07 +08:00

220 lines
3.7 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "data.h"
#include <rtthread.h>
#include <stdbool.h>
/******************************************
* 版本信息
******************************************/
volatile const char _makeData[] = __DATE__; //12字节编译日期
volatile const char _makeTime[] = __TIME__; //9字节
//第一个字节环境变量修改时增加序号 第二个字节
volatile const char cBootv[] = "Ver5.0.11"; //
char _versionTemp[64];
int g_cat1_log_enable = 0 ;
const StrIndex_t cDownDataType[] =
{
{"run",DownRun} ,
{"stop",DownStop} ,
{"open",DownOpen} ,
{"close",DownClose} ,
{"reg_ans",DownRegistAns} ,
{"heart_ans",DownHeartAns},
{"update",DownUpdate},
{"reboot",DownReboot},
{"config",DownConfig},
{"read",DownRead} ,
{"fact",DownFact}
};
const StrIndex_t cSiteType[] =
{
{"sluice",SiteSluice} ,
{"flow",SiteFlow} ,
{"press",SiteSee} ,
{"auto",SiteColl} , // 自动化采集站
{"trans",SiteServer} ,
{"level",SiteLevel},
{"skew",SiteSkew} //测斜仪
};
const StrIndex_t cMotorType[] =
{
{"mg1000",MT_MG_1000} ,
{"qh100", MT_QH_V100} ,
{"qh200", MT_QH_V200} ,
{"zs100", MT_ZS_V100} ,
{"jz200", MT_JZ_V200} , // 金志 4-20 ma
{"dy100", MT_DY_V100}, // 大禹锥型阀
{"kg100", MT_KG_V100}, // 开关量模块
{"kr100", MT_KR_V100}, // 闸位计
{"asca3", MT_ASC_A3}, // A3 驱动器
{"ascws", MT_ASC_WS}, // A3 驱动器
};
const StrIndex_t c4851Type[] =
{
{"mg1000", ST_MG_1000},
{"qh100", ST_QH_V100},
{"qh200", ST_QH_V200},
{"zs100", ST_ZS_V100}, // 中盛4-20ma
{"dy100", ST_DY_V100},
{"kg100", ST_KG_V100},
{"at100", ST_AT_V100},
{"kr100", ST_KR_V100},
};
const StrIndex_t cU485Type[] =
{
{"modbus", 0}
};
// 485 2 通道
const StrIndex_t c4852Type[] =
{
{"rds600", ST_RDS_600},
{"tds300", ST_TDS_300},
{"ht100", ST_HT_V100},
{"zkjszk", ST_ZK_JSZK},
{"djx100", ST_DJX_100},
{"rds300", ST_RDS_300},
{"mi600", ST_MI_600}, // 测斜仪
{"ht200", ST_HT_V200} // 华天压力计
};
SluiceData_t SluiceData[SLUICE_COUTN];
WaterData_t WaterData[WATER_COUTN];
InclinometerData_t IncData[6]; // 测斜仪数据
SysData_t SysData;
SOFTRTC_t g_SoftRtc =
{
23, 10, 1, 0, 0, 0
};
uint32_t g_ifconfig = 0;
uint32_t g_ifupdate = 0;
int cMotorGetType (char * str)
{
for (int i = 0; i < sizeof (cMotorType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, cMotorType[i].str, rt_strlen (str)) == 0)
{
return cMotorType[i].index;
}
}
return -1;
}
int c4851GetType (char * str)
{
for (int i = 0; i < sizeof (c4851Type) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, c4851Type[i].str, rt_strlen (str)) == 0)
{
return c4851Type[i].index;
}
}
return -1;
}
int c4852GetType (char * str)
{
for (int i = 0; i < sizeof (c4852Type) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, c4852Type[i].str, rt_strlen (str)) == 0)
{
return c4852Type[i].index;
}
}
return -1;
}
int cU485GetType (char *str)
{
for (int i = 0; i < sizeof (cU485Type) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, cU485Type[i].str, rt_strlen (str)) == 0)
{
return cU485Type[i].index;
}
}
return -1;
}
int cDownType2Index (char * str)
{
for (int i = 0; i < sizeof (cDownDataType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, cDownDataType[i].str, rt_strlen (str)) == 0)
{
return cDownDataType[i].index;
}
}
return -1;
}
int cSiteType2Index (char * str)
{
for (int i = 0; i < sizeof (cSiteType) / sizeof (StrIndex_t); i++)
{
if (rt_memcmp (str, cSiteType[i].str, rt_strlen (str)) == 0)
{
return cSiteType[i].index;
}
}
return -1;
}
/**********************************************
获取boot版本信息
**********************************************/
void *GetVersion(void)
{
int i = rt_sprintf(_versionTemp,"%s-%s %s",cBootv, _makeData, _makeTime);
_versionTemp[i] = 0;
return (void*)_versionTemp;
}