/*
*********************************************************************************************************
*                                       IAR Development Kits
*                                              on the
*
*                                    Nano130
*
* Filename      : def_data.c
* Version       : V1.00
* Programmer(s) : Qian Xianghong
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             INCLUDE FILES
*********************************************************************************************************
*/

#include  "includes.h"

// 硬件版本号（TTS-罐箱-槽车-低功耗4G）【该版本号用于升级时确定硬件版本】
const uint8_t HARDWARE_VER_MINOR = 84;

//// 客户和选项组合配置【该版本号用于上传到服务器，确定具体配置】
//#ifdef _DUWAPING_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 11;
//#endif
//#ifdef _DUWAPING_LOCAL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 12;
//#endif
//#ifdef _DUWAPING_LANSHI_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 13;
//#endif
//#ifdef _LOCAL_DISP_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 15;
//#endif
//#ifdef _LOCAL_ANTI_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 16;
//#endif
//#ifdef _LANSHI_TTS_ANTI_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 17;
//#endif
//#ifdef _LANSHI_TTS_LEAK02_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 18;
//#endif
//#ifdef _DUWAPING_LOCAL_ANTI_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 20;
//#endif
//#ifdef _LOCAL_DISP_1S_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 25;
//#endif
//#ifdef _LOCAL_ANTI_SINGLE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 26;
//#endif
//#ifdef _LANSHI_TTS_ANTI_SINGLE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 27;
//#endif
//#ifdef _ANJIEHUI4_TTS_LEAK02_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 28;
//#endif
//#ifdef _LNG_LORA_4G_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 29;
//#endif
//#ifdef _LNG_LORA_LOCAL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 30;
//#endif
//#ifdef _LANSHI_TTS_ANTI_NORM_OPEN_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 31;
//#endif
//#ifdef _ANJIEHUI4_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 70;
//#endif
//#ifdef _ANJIEHUI4_ANTI_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 71;
//#endif
//#ifdef _ANJIEHUI4_PRAXAIR_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 72;
//#endif
//#ifdef _ANJIEHUI4_LINDE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 73;
//#endif
//#ifdef _ANJIEHUI4_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 74;
//#endif
//#ifdef _ANJIEHUI4_JINHONG_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 75;
//#endif
//#ifdef _ANJIEHUI4_LINDE_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 76;
//#endif
//#ifdef _LOCAL_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 77;
//#endif
//#ifdef _ANJIEHUI4_R0SEMOUNT_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 78;
//#endif
//#ifdef _LANSHI_ROSEMOUNT_485TEMPR_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 96;
//#endif
//#ifdef _PCT_LEVEL_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 98;
//#endif
//#ifdef _ANJIEHUI4_CHAOYANG_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 124;
//#endif
//#ifdef _HUIDA_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 125;
//#endif
//#ifdef _HUAGONG_BOX_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 127;
//#endif
//#ifdef _LANSHI_CAOCHE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 148;
//#endif
//#ifdef _CAOCHE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 149;
//#endif
//#ifdef _BOX_500_2_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 162;
//#endif
//#ifdef _BOX_1000_2_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 163;
//#endif
//#ifdef _BOX_1000_3_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 164;
//#endif
//#ifdef _LANSHI_BOX_1000_3_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 194;
//#endif
//#ifdef _LANSHI_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 195;
//#endif
//#ifdef _FURUI_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 196;
//#endif
//#ifdef _BASF_MAGNETIC_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 197;
//#endif
//#ifdef _PCT_LEVEL_CAOCHE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 198;
//#endif
//#ifdef _CIDC_MAIKE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 199;
//#endif
//#ifdef _PRAXAIR_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 202;	
//#endif
//#ifdef _PRAXAIR_DOL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 203;
//#endif
//#ifdef _PRAXAIR_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 204;
//#endif
//#ifdef _YINGDE_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 205;
//#endif
//#ifdef _MESSER_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 206;
//#endif
//#ifdef _GUANGGANG_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 207;
//#endif
//#ifdef _YINGDE_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 212;	
//#endif
//#ifdef _LINDE_HTTPS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 213;	
//#endif
//#ifdef _MESSER_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 214;
//#endif
//#ifdef _FAYEKONG_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 215;
//#endif
//#ifdef _BAOGANG_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 216;
//#endif
//#ifdef _LANSHI_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 217;
//#endif
//#ifdef _FUSHIKANG_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 218;
//#endif
//#ifdef _ZHONGHAIYOU_BOX_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 219;
//#endif
//#ifdef _FAYEKONG_TTS_CHARGE_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 220;
//#endif
//#ifdef _YINGDE_DOL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 222;
//#endif
//#ifdef _LINDE_HTTPS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 223;
//#endif
//#ifdef _LINDE_HTTPS_DOL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 224;
//#endif
//#ifdef _CHATE_TTS_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 225;
//#endif
//#ifdef _TRAIN_BOX_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 226;
//#endif
//#ifdef _LANSHI_TTS_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 227;
//#endif
//#ifdef _AOYANG_BOX_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 228;
//#endif
//#ifdef _BRASIL_BOX_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 229;
//#endif
//#ifdef _TTS_TEMPR_420MA_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 230;
//#endif
//#ifdef _LANSHI_ZNY_HEYUAN_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 231;
//#endif
//#ifdef _LEVEL_P2_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 232;
//#endif
//#ifdef _LEVEL_P1_ALARM_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 233;
//#endif
//#ifdef _2ND_420MA_OUT_LEVEL_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 238;
//#endif
//#ifdef _ANJIEHUI4_ALL_420MA_VER_
//	const uint8_t HARDWARE_VER_MAJOR = 239;
//#endif
//#ifdef _PAKISTAN_VER_
//  const uint8_t HARDWARE_VER_MAJOR = 240;
//#endif

const uint8_t HARDWARE_VER_MAJOR = 201;
// 软件版本号
const uint8_t SOFTWARE_VER_MAJOR = 1;
const uint8_t SOFTWARE_VER_MINOR = 201;	// TTS-4G低功耗
// 软件日期
const uint8_t SOFTWARE_DATE_YEAR = 25;
const uint8_t SOFTWARE_DATE_MONTH = 3;
const uint8_t SOFTWARE_DATE_DAY = 31;

// 存储格式版本号=1.1
const uint8_t CONFIG_FORMAT_VER_MAJOR = 1;
const uint8_t CONFIG_FORMAT_VER_MINOR = 1;	// 新结构整体式，带双向通信

// 远传协议版本号
const uint8_t REPORT_PROTOCOL_VER_MAJOR = 0;
// 0: 压力单位为bar，1：压力单位为KPa, 107: 支持历史数据发送
const uint8_t REPORT_PROTOCOL_VER_MINOR = 107;

// DTU参数
const uint32_t DTU_BAUDRATE = 115200ul;
const uint8_t DTU_PARITY = PARITY_NONE;

// 蓝牙协议版本号
const uint8_t BLUETOOTH_PROTOCOL_VER_MAJOR = 1;
const uint8_t BLUETOOTH_PROTOCOL_VER_MINOR = 0;

// 蓝牙参数
const uint32_t BLUETOOTH_BAUDRATE = 9600ul;
const uint8_t BLUETOOTH_PARITY = PARITY_NONE;

// 存放全部配置和采集数据的结构体
data_buff_t dcBuff = {0};

// MQTT/HTTPS/HTTP服务器列表
const char SERVER_URLs[][200] =
{
	// 林德服务器
	"/TelemetryWebService.TelemetryWebContract.svc/Postmeasurements",
	// 中海油阿里云服务器
	"iot-as-mqtt.cn-shanghai.aliyuncs.com",
  //巴基斯坦服务器
  "/workflows/1d1d3a530dea461f88c0333ab0a0102a/triggers/manual/paths/\
  invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=\
  dFgP23aabJi6dMl7X2wf8JBfexlMB4xO7Zy6Gkxb2CI",
};

// 各个数据块的长度
const uint8_t	Config_DataLen[] =
{
	sizeof(config_bottle_t),
	sizeof(config_sensor_t),
	sizeof(config_data_t),
	sizeof(config_display_t),
	sizeof(sysinfo_sample_t),
	sizeof(sysinfo_power_t),
	sizeof(sysinfo_display_t),
	sizeof(sysinfo_bluetooth_t),
	sizeof(data_dtu_t),
	sizeof(data_sample_t),
	sizeof(adc_sample_t),
};

// 各个数据区的地址
const void*	Config_DataPtr[] =
{
	&dcBuff.configBottle,
	&dcBuff.configSensor,
	&dcBuff.configData,
	&dcBuff.configDisplay,
	&dcBuff.sampleInfo,
	&dcBuff.powerInfo,
	&dcBuff.displayInfo,
	&dcBuff.bluetoothInfo,
	&dcBuff.dtuData,
	&dcBuff.sampleData,
	&dcBuff.adcData,	
};

// 液体密度：LNG=0.42g/cm3=420kg/m3
//            O2=1.143g/cm3=1143kg/m3
//            N2=0.81g/cm3=810kg/m3
//            AR=1.402g/cm3=1402kg/m3
//           CO2=1.024g/cm3=1024kg/m3
const float LSrc_Density[] = {0.42, 1.143, 0.81, 1.402, 1.024}; // 单位kg/L

// 液体密度： H2=0.071g/cm3=71kg/m3
//           CNG=0.071g/cm3=71kg/m3
//            He=0.125g/cm3=125kg/m3
//            C2H4=0.568g/cm3=568kg/m3
//            LPG=0.539g/cm3=539kg/m3
//           NH3=0.618g/cm3=618kg/m3
//           PENT=0.630g/cm3=630kg/m3
//           POPO=1.038g/cm3=1038kg/m3
const uint16_t LSrc_DensityExt[] = {71, 71, 125, 568, 539, 618, 630, 1038}; // 单位kg/m3

// 多项式为x16+x15+x2+1,LSB顺序
uint16_t do_crc_16(unsigned short crc_reg, uint8_t *message, int16_t len)
{
    int16_t i, j;
    uint16_t current;
       
    for (i = 0; i < len; i++)
    {
        current = message[i];
        for (j = 0; j < 8; j++)
        {
            if ((crc_reg ^ current) & 0x0001)
                crc_reg = (crc_reg >> 1) ^ 0xA001;
            else
                crc_reg >>= 1;
            current >>= 1;
        }
    }
    return crc_reg;
}

// 检查固定的字段
uint32_t Config_CheckValid(rd_buff_t *rdBuff, uint8_t DC)
{
	if(rdBuff->header.mark != CONFIG_MARK_LS)
		return FALSE;
	if(rdBuff->header.product != CONFIG_PRODUCT_CY)
		return FALSE;
	if(rdBuff->header.DC != DC)
		return FALSE;
	if(rdBuff->header.ver.major != CONFIG_FORMAT_VER_MAJOR || rdBuff->header.ver.minor != CONFIG_FORMAT_VER_MINOR)
		return FALSE;
	if(do_crc_16(0, rdBuff->buff, CONFIG_DATA_LEN(DC)) != 0)
		return FALSE;
	return TRUE;
}

// 写入固定的字段
void Config_ForceValid(rd_buff_t *rdBuff, uint8_t DC)
{
	uint8_t pos = CONFIG_DATA_LEN(DC) - 2;
	
	rdBuff->header.mark = CONFIG_MARK_LS;
	rdBuff->header.product = CONFIG_PRODUCT_CY;
	rdBuff->header.DC = DC;
	rdBuff->header.ver.major = CONFIG_FORMAT_VER_MAJOR;
	rdBuff->header.ver.minor = CONFIG_FORMAT_VER_MINOR;
	Int2ByteS(rdBuff->buff, pos, do_crc_16(0, rdBuff->buff, pos));
}

// 设置储罐参数的默认值
void Config_setBottleDefParam(data_buff_t *dataBuff)
{
	uint8_t i;
	
	memset(&dataBuff->configBottle, 0, sizeof(dataBuff->configBottle));

#if defined(_PRAXAIR_SERVER_)	
	dataBuff->configBottle.serverVer = 3;	// 服务器参数版本号: 普莱克斯专用版本
#elif defined(_LINDE_SERVER_)
	dataBuff->configBottle.serverVer = 4;	// 服务器参数版本号: 林德专用版本
#elif defined(_BAOGANG_SERVER_)
	dataBuff->configBottle.serverVer = 5;	// 服务器参数版本号: 宝钢专用版本
#else
	dataBuff->configBottle.serverVer = 0;	// 服务器参数版本号: 安捷汇版本
#endif	
	dataBuff->configBottle.updateFlag = 1;	// 参数更新标志
	
	dataBuff->configBottle.addr = 1;
#if defined(_DUWAPING_VER_) || defined(_DUWAPING_LOCAL_VER_) || defined(_DUWAPING_LANSHI_VER_)
	dataBuff->configBottle.type = BOTTLE_TYPE_STAND;
#else
	dataBuff->configBottle.type = BOTTLE_TYPE_LYING;
#endif
#if defined(_HUAGONG_BOX_VER_)
	dataBuff->configBottle.source = SOURCE_CNG;
#elif defined(_DUWAPING_LOCAL_VER_) || defined(_BOX_VER_)
	dataBuff->configBottle.source = SOURCE_LNG;
#else
	dataBuff->configBottle.source = SOURCE_N2;
#endif

#if defined(_DUWAPING_VER_) || defined(_DUWAPING_LOCAL_VER_) || defined(_DUWAPING_LANSHI_VER_)
	dataBuff->configBottle.len = 1150;
	dataBuff->configBottle.diameter = 500;
#elif defined(_BRASIL_BOX_VER_)
	dataBuff->configBottle.len = 10364;
	dataBuff->configBottle.diameter = 2258;
#elif defined(_BOX_VER_)
	dataBuff->configBottle.len = 10730;
	dataBuff->configBottle.diameter = 2250;
#else
	dataBuff->configBottle.len = 10000;
	dataBuff->configBottle.diameter = 2650;
#endif
	dataBuff->configBottle.lenExtra = 0;
	for(i = 0; i < sizeof(dataBuff->configBottle.density) / sizeof(float); i++)
		dataBuff->configBottle.density[i] = LSrc_Density[i];
	for(i = 0; i < sizeof(dataBuff->configBottle.densityExt) / sizeof(uint16_t); i++)
		dataBuff->configBottle.densityExt[i] = LSrc_DensityExt[i];
	dataBuff->configBottle.chargePct = 100;
	dataBuff->configBottle.measureType = MEASURE_DPRESS;
	
	// 以下参数，如为0则表示无效
#if defined(_TRAIN_BOX_VER_)
	dataBuff->configBottle.fullPct = 7900;	// 满液位百分比
#elif defined(_DISP_MMWC_ONLY_)
	dataBuff->configBottle.fullPct = 0;	// 满液位百分比
#else
	if(dataBuff->configBottle.source == SOURCE_LNG)
		dataBuff->configBottle.fullPct = 9000;	// 满液位百分比
	else
		dataBuff->configBottle.fullPct = 9500;	// 满液位百分比
#endif
	dataBuff->configBottle.priPct = 0;		// 关键液位百分比
	dataBuff->configBottle.orderPct = 0;	// 订货液位百分比
	dataBuff->configBottle.emptyPct = 0;	// 空液位百分比
	dataBuff->configBottle.planMount = 0;	// 每日计划用量
	dataBuff->configBottle.predictMount = 0;	// 每日预测用量
#if defined(_TRAIN_BOX_VER_)
	dataBuff->configBottle.warnVolt = 19;		// 电压报警低点: 19%
#else
	dataBuff->configBottle.warnVolt = 0;		// 电压报警低点: 10mV
#endif
	dataBuff->configBottle.warnVoltH = 0;		// 电压报警高点: 10mV
#if defined(_TRAIN_BOX_VER_)
	dataBuff->configBottle.warnPress = 0;		// 压力报警低点: KPa
	dataBuff->configBottle.warnPressH = 550;		// 压力报警高点
#else	
	dataBuff->configBottle.warnPress = 300;		// 压力报警低点: KPa
	dataBuff->configBottle.warnPressH = 2000;		// 压力报警高点
#endif
	//dataBuff->configBottle.warnPress2 = 400;	//apex	// 压力报警低点: KPa
	//dataBuff->configBottle.warnPressH2 = 3000;		// 压力报警高点
	dataBuff->configBottle.ts = 0;				// 参数时间戳
#if defined(_ANJIEHUI4_JINHONG_VER_)
	dataBuff->configBottle.dispMode = DISP_MODE_L; // 显示升
	dataBuff->configBottle.options = 0x0001;	   // 参数开关
//#elif defined(_YINGDE_TTS_VER_) || defined(_YINGDE_DOL_VER_) || defined(_YINGDE_TTS_CHARGE_VER_)
//	dataBuff->configBottle.dispMode = DISP_MODE_DPRESS; // 不显示升和公斤
//	dataBuff->configBottle.options = 0x0000;	   // 参数开关
#else
	dataBuff->configBottle.dispMode = DISP_MODE_ALL; 	// 显示全部
	dataBuff->configBottle.options = 0x0003;	        // 参数开关
#endif	

#if defined(_PRAXAIR_SERVER_) || defined(_LINDE_SERVER_) || defined(_YINGDE_SERVER_)
	dataBuff->configBottle.hideVacu = 1;
#endif

#ifdef _PRAXAIR_SERVER
	// praxair
	dataBuff->configBottle.floorLevel = 0;
	dataBuff->configBottle.span = 0;
	dataBuff->configBottle.spanPeriod = 3600;
#else
	// others
	dataBuff->configBottle.warnVacuumH = 0;
	dataBuff->configBottle.warnTempr = -300;
	dataBuff->configBottle.warnTemprH = -300;
#endif

	Config_ForceValid((rd_buff_t *) &dataBuff->configBottle, CAN_DC_BOTTLE_CONFIG);
}

// 设置传感器参数的默认值
void Config_setSensorDefParam(data_buff_t *dataBuff)
{
	uint8_t i;
	
	memset(&dataBuff->configSensor, 0, sizeof(dataBuff->configSensor));

	dataBuff->configSensor.sensorWeight.lowRange = 0;
	dataBuff->configSensor.sensorWeight.highRange = 100000ul;	// 100000kg
	dataBuff->configSensor.sensorWeight.zeroValue = 84030ul;	// 经验值
	dataBuff->configSensor.sensorWeight.fullValue = 1613530ul;	// 经验值

#if !defined(_USE_CAPACITY_SENSOR_)
	#if defined(_DOL_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0KPa
		dcBuff.configSensor.sensorDPress.highRange = 150;        // 150KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_TRAIN_BOX_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0KPa
		dcBuff.configSensor.sensorDPress.highRange = 15;        // 15KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 683;	 	// 理论值：0.5v / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3823; 		// 理论值：2.8v / 3.0v
	#elif defined(_BRASIL_BOX_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0KPa
		dcBuff.configSensor.sensorDPress.highRange = 15;        // 15KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_BASF_MAGNETIC_CHARGE_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0mm
		dcBuff.configSensor.sensorDPress.highRange = 2550;      // 2550mm
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_USE_PCT_LEVEL_MA_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0
		dcBuff.configSensor.sensorDPress.highRange = 100;       // 100%
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_USE_PCT_LEVEL_V_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0
		dcBuff.configSensor.sensorDPress.highRange = 100;       // 100%
		dcBuff.configSensor.sensorDPress.zeroValue = 341;	 	// 理论值：0.25v / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3071; 		// 理论值：2.25v / 3.0v
	#elif defined(_CIDC_MAIKE_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0
		dcBuff.configSensor.sensorDPress.highRange = 70;       // 70KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_ANJIEHUI4_R0SEMOUNT_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0
		dcBuff.configSensor.sensorDPress.highRange = 100;       // 100KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_LANSHI_ROSEMOUNT_485TEMPR_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0
		dcBuff.configSensor.sensorDPress.highRangeX10 = 25;     // 2.5KPa
		dcBuff.configSensor.sensorDPress.ishighRangeX10 = 1;
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#elif defined(_ANJIEHUI4_ALL_420MA_VER_)
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0KPa
		dcBuff.configSensor.sensorDPress.highRange = 50;        // 50KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 710;	 	// 理论值：4mA * 130Ω / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3550; 		// 理论值：20mA * 130Ω / 3.0v
	#else
		dcBuff.configSensor.sensorDPress.lowRange = 0;			// 0KPa
		dcBuff.configSensor.sensorDPress.highRange = 50;        // 50KPa
		dcBuff.configSensor.sensorDPress.zeroValue = 683;	 	// 理论值：0.5v / 3.0v
		dcBuff.configSensor.sensorDPress.fullValue = 3823; 		// 理论值：2.8v / 3.0v
	#endif
#elif defined(_USE_PCAP04_CHIP_)	
	dataBuff->configSensor.sensorCap.c1ADC = 1818;				// 电容c1标定ADC值
	dataBuff->configSensor.sensorCap.c2ADC = 6061;        		// 电容c2标定ADC值
	dataBuff->configSensor.sensorCap.baseC = 1720;	 			// 底电容(pF) * 10
	dataBuff->configSensor.sensorCap.refC = 561; 				// 增长电容(pF) * 10
#else	// _555_CHIP_
	dataBuff->configSensor.sensorCap.c1ADC = 682;				// 电容c1标定ADC值
	dataBuff->configSensor.sensorCap.c2ADC = 1635;        		// 电容c2标定ADC值
	dataBuff->configSensor.sensorCap.baseC = 1720;	 			// 底电容(pF) * 10
	dataBuff->configSensor.sensorCap.refC = 561; 				// 增长电容(pF) * 10
#endif
	
#if defined(_TRAIN_BOX_VER_)
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 1600;        // 1.6MPa
	dataBuff->configSensor.sensorPress.zeroValue = 683;	 		// 理论值：0.5v / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3823; 		// 理论值：2.8v / 3.0v
#elif defined(_DOL_VER_)
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 5000;        // 5MPa
	dataBuff->configSensor.sensorPress.zeroValue = 710;			// 理论值：4mA * 130Ω / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3550;		// 理论值：20mA * 130Ω / 3.0v
#elif defined(_BRASIL_BOX_VER_)
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 1600;        // 1.6MPa
	dataBuff->configSensor.sensorPress.zeroValue = 710;			// 理论值：4mA * 130Ω / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3550;		// 理论值：20mA * 130Ω / 3.0v
#elif defined(_CIDC_MAIKE_VER_) || defined(_ANJIEHUI4_R0SEMOUNT_VER_) || defined(_ANJIEHUI4_ALL_420MA_VER_)
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 4000;        // 4MPa
	dataBuff->configSensor.sensorPress.zeroValue = 710;			// 理论值：4mA * 130Ω / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3550;		// 理论值：20mA * 130Ω / 3.0v
#elif defined(_HUAGONG_BOX_VER_)
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 1600;        // 1.6MPa
	dataBuff->configSensor.sensorPress.zeroValue = 683;	 		// 理论值：0.5v / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3823; 		// 理论值：2.8v / 3.0v
#else
	dataBuff->configSensor.sensorPress.lowRange = 0;			// 0MPa
	dataBuff->configSensor.sensorPress.highRange = 4000;        // 4MPa
	dataBuff->configSensor.sensorPress.zeroValue = 683;	 		// 理论值：0.5v / 3.0v
	dataBuff->configSensor.sensorPress.fullValue = 3823; 		// 理论值：2.8v / 3.0v
#endif
	
	for(i = 0; i < sizeof(dataBuff->configSensor.sensorEPress) / sizeof(press_param_t); i++)
	{
		dataBuff->configSensor.sensorEPress[i].lowRange = 0;		// 0MPa
		dataBuff->configSensor.sensorEPress[i].highRange = 4000;    // 4MPa
		dataBuff->configSensor.sensorEPress[i].zeroValue = 710;		// 理论值：4mA * 130Ω / 3.0v
		dataBuff->configSensor.sensorEPress[i].fullValue = 3550;	// 理论值：20mA * 130Ω / 3.0v
	}

#ifndef _USE_PT100_SENSOR_		
	for(i = 0; i < sizeof(dataBuff->configSensor.sensorMTempr) / sizeof(tempr_param_t); i++)
	{
#if defined(_BRASIL_BOX_VER_)
		dataBuff->configSensor.sensorMTempr[i].lowRange = -196;		// -196℃
		dataBuff->configSensor.sensorMTempr[i].highRange = 100;		// 100℃
		dataBuff->configSensor.sensorMTempr[i].zeroValue = 710;		// 理论值：4mA * 130Ω / 3.0v
		dataBuff->configSensor.sensorMTempr[i].fullValue = 3550;	// 理论值：20mA * 130Ω / 3.0v
#else		
		dataBuff->configSensor.sensorMTempr[i].lowRange = -200;		// -200℃
		dataBuff->configSensor.sensorMTempr[i].highRange = 80;		// 80℃
		dataBuff->configSensor.sensorMTempr[i].zeroValue = 710;		// 理论值：4mA * 130Ω / 3.0v
		dataBuff->configSensor.sensorMTempr[i].fullValue = 3550;	// 理论值：20mA * 130Ω / 3.0v
#endif
	}
#else
	for(i = 0; i < sizeof(dataBuff->configSensor.sensorPTempr) / sizeof(pt100_param_t); i++)
	{
		// 导线在18℃下每米电阻为0Ω，温度每下降1℃导线电阻下降1.3‰，假设导线长度为1.7米。
		// （此处默认为忽略导线电阻，实际可根据测量偏差手动调节）
		
		// 在0℃下，导线电阻为0*1.7*（1- 18 * 1.3‰） = 0Ω
		// PT100铂电阻的阻值和温度的关系直接查表，在0℃下为100Ω。
		dataBuff->configSensor.sensorPTempr[i].calibrateT = 0 * 10;	// 校准温度0℃
		dataBuff->configSensor.sensorPTempr[i].calibrateR = (int16_t) ((100 * _PT100_MULTI_ + 0) * 10);	// 0℃下PT100电阻+线电阻（1.7米）
		
	#if _PT100_MULTI_ == 5		
		// 在-200℃下，导线电阻为0*1.7*（1- 218 * 1.3‰） = 0Ω，PT500电阻为92.6Ω，在电桥下测得电压为2.917v
		// (2.5-(0+92.6+4500)/(0+92.6+9500)*5)*15.7+1.25=2.917v
		dataBuff->configSensor.sensorPTempr[i].zeroValue = 3983;		// 理论值：2.917v / 3.0v
		
		// 在80℃下，导线电阻为0*1.7*（1+ 62 * 1.3‰） = 0Ω，PT500电阻为654.5Ω，在电桥下测得电压为0.653v
		// (2.5-(0+654.5+4500)/(0+654.5+9500)*5)*15.7+1.25=0.653v
		dataBuff->configSensor.sensorPTempr[i].fullValue = 891;			// 理论值：0.653v / 3.0v
	#else	// PT1000
		// 在-200℃下，导线电阻为0*1.7*（1-218 * 1.3‰） = 0Ω，PT1000电阻为185.2Ω，在电桥下测得电压为2.917v
		// (2.5-(0+185.2+9000)/(0+185.2+19000)*5)*15.7+1.25=2.917v
		dataBuff->configSensor.sensorPTempr[i].zeroValue = 3983;		// 理论值：2.917v / 3.0v
		
		// 在80℃下，导线电阻为0*1.7*（1+62 * 1.3‰） = 0Ω，PT1000电阻为1309Ω，在电桥下测得电压为0.653v
		// (2.5-(0+1309+9000)/(0+1309+19000)*5)*15.7+1.25=0.653v
		dataBuff->configSensor.sensorPTempr[i].fullValue = 891;			// 理论值：0.653v / 3.0v
	#endif
	}
#endif
	
	dataBuff->configSensor.sensor = 0;	// 杜瓦瓶传感器
	
	Config_ForceValid((rd_buff_t *) &dataBuff->configSensor, CAN_DC_SENSOR_CONFIG);
}

// 设置数据参数的默认值
void Config_setDataDefParam(data_buff_t *dataBuff)
{
	memset(&dataBuff->configData, 0, sizeof(dataBuff->configData));

#if defined(_PRAXAIR_SERVER_) || defined(_LINDE_SERVER_)	
	strcpy(dataBuff->configData.server, "tts.praxair.com.cn");
	dataBuff->configData.port = 7005;
#elif defined(_YINGDE_SERVER_)
	strcpy(dataBuff->configData.server, "tts.yingde.com");
	dataBuff->configData.port = 8088;
	strcpy(dataBuff->configData.gpsServer, "tts.yingde.com");
	dataBuff->configData.gpsPort = 8070;
#elif defined(_BAOGANG_SERVER_)
	strcpy(dataBuff->configData.server, "220.248.39.34");
	dataBuff->configData.port = 7006;
#elif defined(_LANSHI_SERVER_)
	//strcpy(dataBuff->configData.server, "data.cd-ls.cn");
	strcpy(dataBuff->configData.server, "pazx.cd-ls.cn");
	dataBuff->configData.port = 8088;
	strcpy(dataBuff->configData.gpsServer, "track.cd-ls.cn");
	dataBuff->configData.gpsPort = 8070;
#elif defined(_HUIDA_SERVER_)
	strcpy(dataBuff->configData.server, "121.41.59.153");
	dataBuff->configData.port = 8669;
#elif defined(_FUSHIKANG_SERVER_)
	strcpy(dataBuff->configData.server, "183.56.160.149 ");
	dataBuff->configData.port = 7888;
#elif defined(_ZHONGHAIYOU_SERVER_)	// mqtt提交到阿里云	
	dataBuff->configData.port = 1883;
//#elif defined(_LINDE_SERVER_)		// https提交到林德服务器
//	strcpy(dataBuff->configData.server, "Telemetry.Linde.com");
//	dataBuff->configData.port = 443;
#elif defined(_TRAIN_SERVER_)
	strcpy(dataBuff->configData.server, "mtcontainer.crctmc.net");
	dataBuff->configData.port = 9006;
	strcpy(dataBuff->configData.train.mtupServer, "61.233.14.28");
	dataBuff->configData.train.mtupPort = 5004;
	strcpy(dataBuff->configData.upgServer, "mtcontainer.crctmc.net");
	dataBuff->configData.upgPort = 9007;
#elif defined(_AOYANG_SERVER_)
	strcpy(dataBuff->configData.server, "meter.auyen.com");
	dataBuff->configData.port = 1314;
#elif defined(_PAKISTAN_SERVER_)
	strcpy(dataBuff->configData.server, "prod-68.eastus.logic.azure.com");
	dataBuff->configData.port = 443;
#elif defined(_HUAGONG_SERVER_)
	strcpy(dataBuff->configData.server, "47.106.27.50");
	dataBuff->configData.port = 18731;
//#elif defined(_MESSER_SERVER_)
//	strcpy(dataBuff->configData.server, "210.5.152.102");
//	dataBuff->configData.port = 8088;
#elif defined(_FURUI_SERVER_)
	strcpy(dataBuff->configData.server, "jk.furuise.com");
	dataBuff->configData.port = 8031;
#elif defined(_CHAOYANG_SERVER_)
	strcpy(dataBuff->configData.server, "39.99.241.193");
	dataBuff->configData.port = 6969;
#else // _ANJIEHUI_SERVER_
	strcpy(dataBuff->configData.server, "data.ajhiot.com"); // 2021.03.31修改
	dataBuff->configData.port = 8088;
	strcpy(dataBuff->configData.gpsServer, "track.ajhiot.com");
	dataBuff->configData.gpsPort = 8070;
#endif

#ifndef _TRAIN_SERVER_
	#if defined(_PRAXAIR_SERVER_) || defined(_LINDE_SERVER_)	
		strcpy(dataBuff->configData.upgServer, dataBuff->configData.server);
	#else
		strcpy(dataBuff->configData.upgServer, "extra.cd-ls.cn");
	#endif
	dataBuff->configData.upgPort = 7006;
#endif
	
#if defined(_PRAXAIR_TTS_VER_) || defined(_PRAXAIR_DOL_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_PRAXAIR_TTS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 3600;
#elif defined(_ANJIEHUI4_PRAXAIR_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 3600;
#elif defined(_YINGDE_TTS_VER_) || defined(_YINGDE_DOL_VER_) || defined(_YINGDE_TTS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_LINDE_HTTPS_VER_) || defined(_LINDE_HTTPS_DOL_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_LINDE_HTTPS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 3600;
#elif defined(_ANJIEHUI4_LINDE_VER_) || defined(_ANJIEHUI4_LINDE_ALARM_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 3600;
#elif defined(_MESSER_TTS_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 3600; 
#elif defined(_MESSER_TTS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 1800;
#elif defined(_FAYEKONG_TTS_VER_) || defined(_FAYEKONG_TTS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 21600;
#elif defined(_BAOGANG_TTS_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_GUANGGANG_TTS_VER_)
	dataBuff->configData.intervalSample = 900;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_DUWAPING_VER_) || defined(_DUWAPING_LANSHI_VER_)
	dataBuff->configData.intervalSample = 3600;
	dataBuff->configData.intervalTrans = 21600;
#elif defined(_BRASIL_BOX_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 1800;
//#elif defined(_HUAGONG_BOX_VER_)
//	dataBuff->configData.intervalSample = 7200;
//	dataBuff->configData.intervalTrans = 7200;
#elif defined(_BOX_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 300;
#elif defined(_SEND_GPS_DATA_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 300;
#elif defined(_FURUI_TTS_CHARGE_VER_)
	dataBuff->configData.intervalSample = 3600;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_BASF_MAGNETIC_CHARGE_VER_)
	dataBuff->configData.intervalSample = 3600;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_CHATE_TTS_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 21600;
#elif defined(_ANJIEHUI4_VER_) || defined(_ANJIEHUI4_ANTI_VER_) || defined(_ANJIEHUI4_ALARM_VER_) || defined(_ANJIEHUI4_JINHONG_VER_) || defined(_ANJIEHUI4_R0SEMOUNT_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 3600;
#elif defined(_HUIDA_CHARGE_VER_)
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 7200;
#elif defined(_ANJIEHUI4_CHAOYANG_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 300;
//#elif defined(_PAKISTAN_VER_)
//	dataBuff->configData.intervalSample = 1300;
//	dataBuff->configData.intervalTrans = 2700;
#elif defined(_PAKISTAN_VER_)
	dataBuff->configData.intervalSample = 60;
	dataBuff->configData.intervalTrans = 60;
#elif defined(_LNG_LORA_4G_VER_) || defined(_LNG_LORA_LOCAL_VER_)
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 3600;
#else	// _LANSHI_TTS_VER_
	dataBuff->configData.intervalSample = 1800;
	dataBuff->configData.intervalTrans = 7200;
#endif
	dataBuff->configData.intervalSample = 300;
	dataBuff->configData.intervalTrans = 3600;
	dataBuff->configData.intervalGPS = 4;
	dataBuff->configData.intervalGPSTrans = 60;
	dataBuff->configData.timeLag = 8;
	// 铁路罐箱新增配置
	strcpy(dataBuff->configBottle.train.tankId, "TEST1234567"); // 箱号
	dataBuff->configBottle.train.moduleId = 10010004;	// 模块ID
	dataBuff->configBottle.train.appId = 2;				// 应用ID
	
	Config_ForceValid((rd_buff_t *) &dataBuff->configData, CAN_DC_DATA_CONFIG);
}

// 设置显示参数的默认值
void Config_setDisplayDefParam(data_buff_t *dataBuff)
{
	memset(&dataBuff->configDisplay, 0, sizeof(dataBuff->configDisplay));

	dataBuff->configDisplay.lightDelay = 0;
	dataBuff->configDisplay.dispDelay = 30;
	dataBuff->configDisplay.unit = DISP_UNIT_METRIC;
#ifdef _GUANGGANG_TTS_VER_
	dataBuff->configDisplay.L_Unit = UNIT_MMH2O;
#else
	dataBuff->configDisplay.L_Unit = UNIT_PCT;
#endif
	strcpy(dataBuff->configDisplay.pwd1, "2222");		// 储罐参数修改密码
	strcpy(dataBuff->configDisplay.pwd2, "3003");		// 传感器标定密码
	strcpy(dataBuff->configDisplay.APN, "CMIOT");
	dataBuff->configDisplay.bdCommander = 0x03300D;		// 北斗指挥机卡号

	dataBuff->configDisplay.op_HARDWARE_VER_MAJOR = HARDWARE_VER_MAJOR;	// 硬件配置（不同客户和选项的组合）
#ifdef _DISP_MMWC_ONLY_	
	dataBuff->configDisplay.op_DISP_MMWC_ONLY = 1;
#endif
#ifdef _DOL_VER_	
	dataBuff->configDisplay.op_DOL_VER = 1;
#endif
#ifdef _BASF_MAGNETIC_CHARGE_VER_
	dataBuff->configDisplay.op_USE_HEIGHT_LEVEL = 1;
	dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
#endif
#ifdef _LANSHI_ROSEMOUNT_485TEMPR_VER_
	dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
#endif
#ifdef _2ND_420MA_OUT_LEVEL_VER_
	dataBuff->configDisplay.op_2ND_420MA_OUT_LEVEL = 1;
#endif
#ifdef _USE_PCT_LEVEL_MA_
	dataBuff->configDisplay.op_USE_PCT_LEVEL = 1;
	dataBuff->configDisplay.op_DIFF_420MA = 1;
#endif
#ifdef _USE_PCT_LEVEL_V_
	dataBuff->configDisplay.op_USE_PCT_LEVEL = 1;
#endif
#ifdef _BOX_VER_	
  dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_BOX_VER = 1;
#endif
#ifdef _CELL_LOCATION_	
	dataBuff->configDisplay.op_CELL_LOCATION = 1;
#endif
#ifdef _NO_LOCATION_
	dataBuff->configDisplay.op_NO_LOCATION = 1;
#endif
#ifdef _LEVEL_SENSOR_ONLY_	
	dataBuff->configDisplay.op_LEVEL_SENSOR_ONLY = 1;
#endif
#ifdef _USE_PT100_SENSOR_	
	dataBuff->configDisplay.op_USE_PT100_SENSOR = 1;
#endif
	dataBuff->configDisplay.op_PT100_MULTI = _PT100_MULTI_;
#ifdef _PT100_3LINE_	
	dataBuff->configDisplay.op_PT100_3LINE = 1;
#endif
#ifdef _DIFF_RESIST_	
	dataBuff->configDisplay.op_DIFF_RESIST = 1;
#endif
#ifdef _SEND_GPS_DATA_	
	dataBuff->configDisplay.op_SEND_GPS_DATA = 1;
#endif
#ifdef _USE_CAPACITY_SENSOR_	
	dataBuff->configDisplay.op_USE_CAPACITY_SENSOR = 1;
#endif
#if defined(_ZHONGHAIYOU_SERVER_)	// mqtt提交到阿里云	
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_MQTT;
	dataBuff->configDisplay.op_SERVER_INDEX = 1;
//#elif defined(_LINDE_SERVER_)		// https提交到林德服务器
//	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_HTTPS;
//	dataBuff->configDisplay.op_SERVER_INDEX = 0;
#elif defined(_TRAIN_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_TRAIN;
#elif defined(_AOYANG_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_AOYANG;
#elif defined(_PAKISTAN_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_PAKISTAN; 
  dataBuff->configDisplay.op_SERVER_INDEX = 2;
#elif defined(_FURUI_SERVER_) || defined(_HUAGONG_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_FURUI;
#elif defined(_HUIDA_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_HUIDA;
#elif defined(_CHAOYANG_SERVER_)
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_CHAOYANG;
#else
	dataBuff->configDisplay.op_SERVER_PROTOCOL = SERVER_PROTOCOL_TCP;
#endif
#if defined(_FUSHIKANG_SERVER_) // || defined(_TRAIN_SERVER_)
	dataBuff->configDisplay.op_UNIDIR_COMM = 1;
#endif
#ifdef _LOCAL_DISP_ONLY_
	dataBuff->configDisplay.op_LOCAL_DISP = 1;
#endif
#ifdef _LOCAL_DISP_1S_
	dataBuff->configDisplay.op_LOCAL_DISP_1S = 1;
#endif
#ifdef _ANTI_OVER_FILL_
	dataBuff->configDisplay.op_ANTI_OVERFILL = 1;
#endif
#ifdef _USE_PCT_CAP_
	dataBuff->configDisplay.op_USE_PCT_CAP = 1;
#endif
#ifdef _ANTI_SINGLE_CTRL_
	dataBuff->configDisplay.op_ANTI_SINGLE_CTRL = 1;
#endif
#ifdef _ANTI_NORM_OPEN_
	dataBuff->configDisplay.op_ANTI_NORM_OPEN = 1;
	dataBuff->configDisplay.op_LOW_ALARM_OUTPUT = 1;
	dataBuff->configDisplay.op_PRESS_ALARM_OUTPUT = 1;
#endif
#ifdef _ANTI_AUTO_FILL_
	dataBuff->configDisplay.op_ANTI_AUTO_FILL = 1;
#endif
#if defined(_SOUND_ALARM_)
	dataBuff->configDisplay.op_ALARM_OUTPUT = 1;
	dataBuff->configDisplay.op_LOW_ALARM_OUTPUT = 1;
#endif
#if defined(_USE_O2_LEAK_)
	dataBuff->configDisplay.op_USE_O2_LEAK = 1;
#endif
#if defined(_LEAK_SOUND_ALARM_)
	dataBuff->configDisplay.op_LEAK_ALARM_OUTPUT = 1;
#endif
#if defined(_PRESS_SOUND_ALARM_)
	dataBuff->configDisplay.op_PRESS_ALARM_OUTPUT = 1;
#endif
#if defined(_LOW_PRESS_SOUND_ALARM_)
	dataBuff->configDisplay.op_LOW_PRESS_ALARM_OUTPUT = 1;
#endif

#ifdef _TRAIN_SERVER_
	dataBuff->configDisplay.op_TRAIN = 1;
#endif
#ifdef _BRASIL_BOX_VER_
	dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_PRESS_420MA = 1;
	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
	dataBuff->configDisplay.op_USE_SOLAR = 1;
#endif
#ifdef _CIDC_MAIKE_VER_
	dataBuff->configDisplay.op_DIFF_420MA = 1;
//	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
#endif
#ifdef _ANJIEHUI4_R0SEMOUNT_VER_
	dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_PRESS_420MA = 1;
	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
#endif
#if defined(_LNG_LORA_4G_VER_) || defined(_LNG_LORA_LOCAL_VER_)
	dataBuff->configDisplay.op_LNG_LORA = 1;
#endif
#ifdef _ANJIEHUI4_ALL_420MA_VER_
	dataBuff->configDisplay.op_DIFF_420MA = 1;
	dataBuff->configDisplay.op_PRESS_420MA = 1;
	dataBuff->configDisplay.op_USE_R0SEMOUNT = 1;
#endif

	// 铁路罐箱新增配置
	dataBuff->configDisplay.train.intervalTransAlarm = 10;	// 预警上传周期（分钟）
	dataBuff->configDisplay.train.regTimeout = 60;			// 网络注册时间超时(秒)
	dataBuff->configDisplay.train.gpsTimeout = 90;			// 定位时间超时(秒)
	dataBuff->configDisplay.train.sendTimeout = 40;			// 数据发送时间超时(秒)
	dataBuff->configDisplay.train.motionThreshold = 4100;	// 加速度动静阈值mg
	dataBuff->configDisplay.train.leakAlarm = -1;			// 可燃气体浓度预警阀值（预留）
	dataBuff->configDisplay.train.temprAlarm = -133;			// 温度预警阀值（℃）
	dataBuff->configDisplay.train.diffCaliRatio = 10000;	// 差压校准系
	dataBuff->configDisplay.train.pressCaliRatio = 10000;	// 气相压力通道校准系数
	dataBuff->configDisplay.train.temprCaliRatio = 10000;	// 液相温度通道校准系数
	dataBuff->configDisplay.train.leakCaliRatio = 10000;	// 泄漏浓度通道校准系数（预留）
	dataBuff->configDisplay.train.vaccumCaliRatio = 10000;	// 真空度通道校准系数（预留）
	dataBuff->configDisplay.train.pressCompensate = 0;		// 气相压力补偿
	dataBuff->configDisplay.train.diffCompensate = 0;		// 差压补偿
	dataBuff->configDisplay.train.gpsEnabled = 1;			// GPS 开关
	dataBuff->configDisplay.train.loraDisabled = 1;			// lora 开关

	Config_ForceValid((rd_buff_t *) &dataBuff->configDisplay, CAN_DC_DISPLAY_CONFIG);
}

// 填充采集板系统信息
void Config_fillSampleInfo(data_buff_t *dataBuff)
{
	memset(&dataBuff->sampleInfo, 0, sizeof(dataBuff->sampleInfo));
	
	dataBuff->sampleInfo.boardFlag = CONFIG_BOARD_SELF;
	dataBuff->sampleInfo.hardVer.major = dcBuff.configDisplay.op_HARDWARE_VER_MAJOR;
	dataBuff->sampleInfo.hardVer.minor = HARDWARE_VER_MINOR;
	dataBuff->sampleInfo.softVer.major = SOFTWARE_VER_MAJOR;
	dataBuff->sampleInfo.softVer.minor = SOFTWARE_VER_MINOR;
	dataBuff->sampleInfo.softDate.year = SOFTWARE_DATE_YEAR;
	dataBuff->sampleInfo.softDate.month = SOFTWARE_DATE_MONTH;
	dataBuff->sampleInfo.softDate.day = SOFTWARE_DATE_DAY;
}

// 填充电源板系统信息
void Config_fillPowerInfo(data_buff_t *dataBuff)
{
	memset(&dataBuff->powerInfo, 0, sizeof(dataBuff->powerInfo));
	
	dataBuff->powerInfo.boardFlag = CONFIG_BOARD_SELF;
	dataBuff->powerInfo.hardVer.major = dcBuff.configDisplay.op_HARDWARE_VER_MAJOR;
	dataBuff->powerInfo.hardVer.minor = HARDWARE_VER_MINOR;
	dataBuff->powerInfo.softVer.major = SOFTWARE_VER_MAJOR;
	dataBuff->powerInfo.softVer.minor = SOFTWARE_VER_MINOR;
	dataBuff->powerInfo.softDate.year = SOFTWARE_DATE_YEAR;
	dataBuff->powerInfo.softDate.month = SOFTWARE_DATE_MONTH;
	dataBuff->powerInfo.softDate.day = SOFTWARE_DATE_DAY;
	dataBuff->powerInfo.protocolVer.major = REPORT_PROTOCOL_VER_MAJOR;
	dataBuff->powerInfo.protocolVer.minor = REPORT_PROTOCOL_VER_MINOR;
	dataBuff->powerInfo.baudrate = DTU_BAUDRATE;
	dataBuff->powerInfo.parity = DTU_PARITY;
}

// 填充显示板系统信息
void Config_fillDisplayInfo(data_buff_t *dataBuff)
{
	memset(&dataBuff->displayInfo, 0, sizeof(dataBuff->displayInfo));
	
	dataBuff->displayInfo.boardFlag = CONFIG_BOARD_SELF;
	dataBuff->displayInfo.hardVer.major = dcBuff.configDisplay.op_HARDWARE_VER_MAJOR;
	dataBuff->displayInfo.hardVer.minor = HARDWARE_VER_MINOR;
	dataBuff->displayInfo.softVer.major = SOFTWARE_VER_MAJOR;
	dataBuff->displayInfo.softVer.minor = SOFTWARE_VER_MINOR;
	dataBuff->displayInfo.softDate.year = SOFTWARE_DATE_YEAR;
	dataBuff->displayInfo.softDate.month = SOFTWARE_DATE_MONTH;
	dataBuff->displayInfo.softDate.day = SOFTWARE_DATE_DAY;
}

// 填充蓝牙板系统信息
void Config_fillBluetoothInfo(data_buff_t *dataBuff)
{
	memset(&dataBuff->bluetoothInfo, 0, sizeof(dataBuff->bluetoothInfo));
	
	dataBuff->bluetoothInfo.boardFlag = CONFIG_BOARD_SELF;
	dataBuff->bluetoothInfo.hardVer.major = dcBuff.configDisplay.op_HARDWARE_VER_MAJOR;
	dataBuff->bluetoothInfo.hardVer.minor = HARDWARE_VER_MINOR;
	dataBuff->bluetoothInfo.softVer.major = SOFTWARE_VER_MAJOR;
	dataBuff->bluetoothInfo.softVer.minor = SOFTWARE_VER_MINOR;
	dataBuff->bluetoothInfo.softDate.year = SOFTWARE_DATE_YEAR;
	dataBuff->bluetoothInfo.softDate.month = SOFTWARE_DATE_MONTH;
	dataBuff->bluetoothInfo.softDate.day = SOFTWARE_DATE_DAY;
	dataBuff->bluetoothInfo.protocolVer.major = BLUETOOTH_PROTOCOL_VER_MAJOR;
	dataBuff->bluetoothInfo.protocolVer.minor = BLUETOOTH_PROTOCOL_VER_MINOR;
	dataBuff->bluetoothInfo.baudrate = BLUETOOTH_BAUDRATE;
	dataBuff->bluetoothInfo.parity = BLUETOOTH_PARITY;
}

// 检查参数修改标志
uint32_t Config_CheckUpdate(data_buff_t *dataBuff)
{
	uint8_t i;
	
	if(!dataBuff->configBottle.updateFlag)
		return FALSE;
	
	for(i = 0; i < 6; i++)
	{
		if(dataBuff->configBottle.PSN[i] != 0)
			return TRUE;
	}
	
	return FALSE;
}
