Exemple #1
0
//------------------ 调节步命令处理 -------------------
bool C_RC_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	C_RC_NA_1_t		c_rc_na;

	memcpy(&c_rc_na,udata,SizeOfType(typid));

	if (c_rc_na.rco.parts.QU == 1)
		szTemp.assign("短脉冲持续时间 ");
	else if (c_rc_na.rco.parts.QU == 2)
		szTemp.assign("长脉冲持续时间 ");
	else if (c_rc_na.rco.parts.QU == 2)
		szTemp.assign("持续输出 ");
	strcat(DrawStr,szTemp.c_str());

	if (c_rc_na.rco.parts.SE)
		szTemp.assign("选择 ");
	else 
		szTemp.assign("执行 ");
	strcat(DrawStr,szTemp.c_str());
	
	if (c_rc_na.rco.parts.RCS == 2)
		szTemp.assign("步调节:升一步 ");
	else if (c_rc_na.rco.parts.RCS == 1)
		szTemp.assign("步调节:降一步 ");
	else
		szTemp.assign("步调节:不允许 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #2
0
//------------------ 累计量召唤命令处理 -------------------
bool C_CI_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	C_CI_NA_1_t		c_ci_na;

	memcpy(&c_ci_na,udata,SizeOfType(typid));
	
	if (c_ci_na.qcc.parts.RQT > 0 && c_ci_na.qcc.parts.RQT <= 5)
	{
		if (c_ci_na.qcc.parts.RQT == 5)
			szTemp.assign("总的请求计数量 ");
		else
		{
			sprintf(tmp,"请求计数量第%d组 ",c_ci_na.qcc.parts.RQT);
			szTemp.assign(tmp);
		}
	}
	else
		szTemp.assign("使用保留 ");
	strcat(DrawStr,szTemp.c_str());

	if (c_ci_na.qcc.parts.FRZ == 0)
		szTemp.assign("读 ");
	else if (c_ci_na.qcc.parts.FRZ == 1)
		szTemp.assign("计数量冻结不带复位 ");
	else if (c_ci_na.qcc.parts.FRZ == 2)
		szTemp.assign("计数量冻结带复位 ");
	else if (c_ci_na.qcc.parts.FRZ == 3)
		szTemp.assign("计数量复位 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #3
0
//------------------ 累计量处理 -------------------
bool M_IT_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_IT_NA_1_t		m_it_na;

	memcpy(&m_it_na,udata,SizeOfType(typid));

	if (m_it_na.bcr.parts.IV)
	{
		szTemp.assign("无效 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_it_na.bcr.parts.CY)
	{
		szTemp.assign("进位 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_it_na.bcr.parts.CA)
	{
		szTemp.assign("计数器被调整 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_it_na.bcr.parts.SQ)
	{
		szTemp.assign("顺序号 ");
		strcat(DrawStr,szTemp.c_str());
	}
	sprintf(tmp,"值:%d ",m_it_na.bcr.parts.counter);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #4
0
//------------------ 带变位检出的成组单点信息处理 -------------------
bool M_PS_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_PS_NA_1_t		m_ps_na;
	int				i,j;

	memcpy(&m_ps_na,udata,SizeOfType(typid));

	for (i = 1,j = 0; i <= 16; i++,j++)
	{
		memset(tmp,0,sizeof(tmp));
		sprintf(tmp,"位%02d状态:%d ",j,(m_ps_na.scd.parts.ST >> j) & 0x01);
		szTemp.assign(tmp);
		strcat(DrawStr,szTemp.c_str());
		if (!(i % 8))
			strcat(DrawStr,"\r\n");
	}

	for (i = 1,j = 0; i <= 16; i++,j++)
	{
		memset(tmp,0,sizeof(tmp));
		sprintf(tmp,"位%02d检出:%d ",j,(m_ps_na.scd.parts.CD >> j) & 0x01);
		szTemp.assign(tmp);
		strcat(DrawStr,szTemp.c_str());
		if (!(i % 8))
			strcat(DrawStr,"\r\n");
	}
	
	qds_desc(DrawStr,&m_ps_na.qds);

	return true;
}
Exemple #5
0
//------------------ 单点命令处理 -------------------
bool C_SC_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	C_SC_NA_1_t		c_sc_na;

	memcpy(&c_sc_na,udata,SizeOfType(typid));

	if (c_sc_na.sco.parts.QU == 1)
		szTemp.assign("短脉冲持续时间 ");
	else if (c_sc_na.sco.parts.QU == 2)
		szTemp.assign("长脉冲持续时间 ");
	else if (c_sc_na.sco.parts.QU == 2)
		szTemp.assign("持续输出 ");
	strcat(DrawStr,szTemp.c_str());

	if (c_sc_na.sco.parts.SE)
		szTemp.assign("选择 ");
	else 
		szTemp.assign("执行 ");
	strcat(DrawStr,szTemp.c_str());
	
	if (c_sc_na.sco.parts.SCS)
		szTemp.assign("遥控:合 ");
	else 
		szTemp.assign("遥控:分 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #6
0
AJ_Status AJ_MarshalArgs(AJ_Message* msg, const char* sig, ...)
{
    AJ_Status status = AJ_OK;
    AJ_Arg arg;
    va_list argp;

    va_start(argp, sig);
    while (*sig) {
        uint8_t u8;
        uint16_t u16;
        uint32_t u32;
        uint64_t u64;
        uint8_t typeId = (uint8_t)*sig++;
        void* val;
        if (!IsBasicType(typeId)) {
            status = AJ_ERR_UNEXPECTED;
            break;
        }
        if (IsScalarType(typeId)) {
            if (SizeOfType(typeId) == 8) {
                u64 = va_arg(argp, uint64_t);
                val = &u64;
            } else if (SizeOfType(typeId) == 4) {
                u32 = va_arg(argp, uint32_t);
                val = &u32;
            } else if (SizeOfType(typeId) == 2) {
                u16 = (uint16_t)va_arg(argp, uint32_t);
                val = &u16;
            } else {
                u8 = (uint8_t)va_arg(argp, uint32_t);
                val = &u8;
            }
        } else {
            val = va_arg(argp, char*);
        }
        InitArg(&arg, typeId, val);
        status = AJ_MarshalArg(msg, &arg);
        if (status != AJ_OK) {
            break;
        }
    }
    va_end(argp);
    return status;
}
Exemple #7
0
//------------------ 收集传输延时处理 -------------------
bool C_CD_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	C_CD_NA_1_t		c_cd_na;

	memcpy(&c_cd_na,udata,SizeOfType(typid));
	
	cp16time_desc(DrawStr,&c_cd_na.tm);

	return true;
}
Exemple #8
0
//------------------ 带时标的继电保护装置事件处理 -------------------
bool M_EP_TA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_EP_TA_1_t		m_ep_ta;

	memcpy(&m_ep_ta,udata,SizeOfType(typid));

	if (m_ep_ta.sep.parts.IV)
	{
		szTemp.assign("无效 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_ta.sep.parts.NT)
	{
		szTemp.assign("非当前值 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_ta.sep.parts.SB)
	{
		szTemp.assign("被替换 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_ta.sep.parts.BL)
	{
		szTemp.assign("被闭锁 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_ta.sep.parts.EI)
	{
		szTemp.assign("动作时间无效 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_ta.sep.parts.ES == 2)
	{
		szTemp.assign("状态:合 ");
	}
	else if (m_ep_ta.sep.parts.ES == 1)
	{
		szTemp.assign("状态:分 ");
	}
	else
	{
		szTemp.assign("状态:中态 ");
	}
	strcat(DrawStr,szTemp.c_str());

	szTemp.assign("动作");
	strcat(DrawStr,szTemp.c_str());
	cp16time_desc(DrawStr,&m_ep_ta.tm16);

	cp24time_desc(DrawStr,&m_ep_ta.tm24);

	return true;
}
Exemple #9
0
//------------------ 测量值,不带品质描述词的规一化值处理 -------------------
bool M_ME_ND_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_ME_ND_1_t		m_me_nd;

	memcpy(&m_me_nd,udata,SizeOfType(typid));

	sprintf(tmp,"值:%d ",m_me_nd.nva.value);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #10
0
//------------------ 测试命令处理 -------------------
bool C_TS_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	C_TS_NA_1_t		c_ts_na;

	memcpy(&c_ts_na,udata,SizeOfType(typid));
	
	sprintf(tmp,"固定测试字: %4XH ",c_ts_na.fbp.HEX);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #11
0
//------------------ 设定值命令,32比特串处理 -------------------
bool C_BO_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	C_BO_NA_1_t		c_bo_na;

	memcpy(&c_bo_na,udata,SizeOfType(typid));
	
	sprintf(tmp,"设值:%d(%08XH) ",c_bo_na.bsi.bits,c_bo_na.bsi.bits);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #12
0
//------------------ 带时标的继电保护装置成组启动事件处理 -------------------
bool M_EP_TB_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_EP_TB_1_t		m_ep_tb;

	memcpy(&m_ep_tb,udata,SizeOfType(typid));

	if (m_ep_tb.spe.parts.GS)
	{
		szTemp.assign("总启动 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tb.spe.parts.SL1)
	{
		szTemp.assign("A相保护启动 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tb.spe.parts.SL2)
	{
		szTemp.assign("B相保护启动 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tb.spe.parts.SL3)
	{
		szTemp.assign("C相保护启动 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tb.spe.parts.SIE)
	{
		szTemp.assign("接地电流保护启动 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tb.spe.parts.SRD)
	{
		szTemp.assign("反向保护启动 ");
		strcat(DrawStr,szTemp.c_str());
	}

	qdp_desc(DrawStr,&m_ep_tb.qdp);

	szTemp.assign("继电器动作持续");
	strcat(DrawStr,szTemp.c_str());
	cp16time_desc(DrawStr,&m_ep_tb.tm16);

	cp24time_desc(DrawStr,&m_ep_tb.tm24);

	return true;
}
Exemple #13
0
AJ_Status AJ_UnmarshalArgs(AJ_Message* msg, const char* sig, ...)
{
    AJ_Status status = AJ_OK;
    AJ_Arg arg;
    va_list argp;

    va_start(argp, sig);
    while (*sig) {
        uint8_t typeId = (uint8_t)*sig++;
        void* val = va_arg(argp, void*);

        if (!IsBasicType(typeId)) {
            status = AJ_ERR_UNEXPECTED;
            break;
        }
        status = AJ_UnmarshalArg(msg, &arg);
        if (status != AJ_OK) {
            break;
        }
        if (arg.typeId != typeId) {
            status = AJ_ERR_UNMARSHAL;
            break;
        }
        if (IsScalarType(typeId)) {
            switch (SizeOfType(typeId)) {
            case 1:
                *((uint8_t*)val) = *arg.val.v_byte;
                break;

            case 2:
                *((uint16_t*)val) = *arg.val.v_uint16;
                break;

            case 4:
                *((uint32_t*)val) = *arg.val.v_uint32;
                break;

            case 8:
                *((uint64_t*)val) = *arg.val.v_uint64;
                break;
            }
        } else {
            *((const char**)val) = arg.val.v_string;
        }
    }
    va_end(argp);
    return status;
}
Exemple #14
0
//------------------ 测量值,短浮点数处理 -------------------
bool M_ME_NC_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_ME_NC_1_t		m_me_nc;

	memcpy(&m_me_nc,udata,SizeOfType(typid));

	sprintf(tmp,"值:%f ",m_me_nc.std.f);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());
	
	qds_desc(DrawStr,&m_me_nc.qds);

	return true;
}
Exemple #15
0
//------------------ 测量值参数,标度化值处理 -------------------
bool P_ME_NB_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	P_ME_NB_1_t		p_me_nb;

	memcpy(&p_me_nb,udata,SizeOfType(typid));

	qpm_desc(DrawStr,&p_me_nb.qpm);

	sprintf(tmp,"值:%d ",p_me_nb.sva.bits);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #16
0
//------------------ 复位进程命令处理 -------------------
bool C_RP_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	C_RP_NA_1_t		c_rp_na;

	memcpy(&c_rp_na,udata,SizeOfType(typid));
	
	if (c_rp_na.qrp.qrp == 1)
		szTemp.assign("进程总复位 ");
	else if (c_rp_na.qrp.qrp == 2)
		szTemp.assign("复位事件缓冲区等待处理的带时标的信息 ");
	else 
		szTemp.assign("使用保留 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #17
0
//------------------ 带CP56Time2a时标的双点信息处理 -------------------
bool M_DP_TB_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_DP_TB_1_t		m_dp_tb;

	memcpy(&m_dp_tb,udata,SizeOfType(typid));

	if (m_dp_tb.diq.parts.IV)
	{
		szTemp.assign("无效 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_dp_tb.diq.parts.NT)
	{
		szTemp.assign("非当前值 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_dp_tb.diq.parts.SB)
	{
		szTemp.assign("被替换 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_dp_tb.diq.parts.BL)
	{
		szTemp.assign("被闭锁 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_dp_tb.diq.parts.DPI == 2)
	{
		szTemp.assign("状态:合 ");
	}
	else if (m_dp_tb.diq.parts.DPI == 1)
	{
		szTemp.assign("状态:分 ");
	}
	else
	{
		szTemp.assign("状态:中态 ");
	}
	strcat(DrawStr,szTemp.c_str());	

	cp56time_desc(DrawStr,&m_dp_tb.tm);

	return true;
}
Exemple #18
0
//------------------ 带时标的32比特串处理 -------------------
bool M_BO_TA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_BO_TA_1_t		m_bo_ta;

	memcpy(&m_bo_ta,udata,SizeOfType(typid));

	sprintf(tmp,"值:%d(%08XH) ",m_bo_ta.bsi.bits,m_bo_ta.bsi.bits);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());
	
	qds_desc(DrawStr,&m_bo_ta.qds);

	cp24time_desc(DrawStr,&m_bo_ta.tm);

	return true;
}
Exemple #19
0
//------------------ 带时标的测量值,标度化值处理 -------------------
bool M_ME_TB_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_ME_TB_1_t		m_me_tb;

	memcpy(&m_me_tb,udata,SizeOfType(typid));

	sprintf(tmp,"值:%d ",m_me_tb.sva.bits);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());
	
	qds_desc(DrawStr,&m_me_tb.qds);

	cp24time_desc(DrawStr,&m_me_tb.tm);

	return true;
}
Exemple #20
0
//------------------ 参数激活处理 -------------------
bool P_AC_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	P_AC_NA_1_t		p_ac_na;

	memcpy(&p_ac_na,udata,SizeOfType(typid));

	if (p_ac_na.qpa.qpa == 1)
		szTemp.assign("激活/停止激活这之前装载的参数 ");
	else if (p_ac_na.qpa.qpa == 2)
		szTemp.assign("激活/停止激活所寻址信息对象的参数 ");
	else if (p_ac_na.qpa.qpa == 3)
		szTemp.assign("激活/停止激活所寻址的持续循环或周期传输的信息对象 ");
	else
		szTemp.assign("使用保留 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #21
0
//------------------ 设定值命令,短浮点数处理 -------------------
bool C_SE_NC_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	C_SE_NC_1_t		c_se_nc;

	memcpy(&c_se_nc,udata,SizeOfType(typid));

	if (c_se_nc.qos.parts.SE)
		szTemp.assign("选择 ");
	else 
		szTemp.assign("执行 ");
	strcat(DrawStr,szTemp.c_str());
	
	sprintf(tmp,"设值:%f",c_se_nc.std.f);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #22
0
//------------------ 带时标的单点信息处理 -------------------
bool M_SP_TA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_SP_TA_1_t		m_sp_ta;

	memcpy(&m_sp_ta,udata,SizeOfType(typid));

	if (m_sp_ta.siq.parts.IV)
	{
		szTemp.assign("无效 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_sp_ta.siq.parts.NT)
	{
		szTemp.assign("非当前值 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_sp_ta.siq.parts.SB)
	{
		szTemp.assign("被替换 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_sp_ta.siq.parts.BL)
	{
		szTemp.assign("被闭锁 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_sp_ta.siq.parts.SPI)
	{
		szTemp.assign("状态:合 ");
	}
	else
	{
		szTemp.assign("状态:分 ");
	}
	strcat(DrawStr,szTemp.c_str());

	cp24time_desc(DrawStr,&m_sp_ta.tm);

	return true;
}
Exemple #23
0
//------------------ 步位置信息处理 -------------------
bool M_ST_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	M_ST_NA_1_t		m_st_na;

	memcpy(&m_st_na,udata,SizeOfType(typid));

	if (m_st_na.vti.parts.transient)
	{
		szTemp.assign("设备在瞬间状态 ");
		strcat(DrawStr,szTemp.c_str());
	}

	sprintf(tmp,"值:%d ",m_st_na.vti.parts.value);
	szTemp.assign(tmp);
	strcat(DrawStr,szTemp.c_str());
	
	qds_desc(DrawStr,&m_st_na.qds);

	return true;
}
Exemple #24
0
//------------------ 带时标的继电保护装置成组输出电路信息处理 -------------------
bool M_EP_TC_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_EP_TC_1_t		m_ep_tc;

	memcpy(&m_ep_tc,udata,SizeOfType(typid));

	if (m_ep_tc.oci.parts.GC)
	{
		szTemp.assign("总命令输出至输出电路 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tc.oci.parts.CL1)
	{
		szTemp.assign("命令输出至A相输出电路 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tc.oci.parts.CL2)
	{
		szTemp.assign("命令输出至B相输出电路 ");
		strcat(DrawStr,szTemp.c_str());
	}
	if (m_ep_tc.oci.parts.CL3)
	{
		szTemp.assign("命令输出至C相输出电路 ");
		strcat(DrawStr,szTemp.c_str());
	}
	
	qdp_desc(DrawStr,&m_ep_tc.qdp);

	szTemp.assign("继电器动作");
	strcat(DrawStr,szTemp.c_str());
	cp16time_desc(DrawStr,&m_ep_tc.tm16);

	cp24time_desc(DrawStr,&m_ep_tc.tm24);

	return true;
}
Exemple #25
0
static void EndianSwap(AJ_Message* msg, uint8_t typeId, void* data, uint32_t num)
{
    if (msg->hdr->endianess != HOST_ENDIANESS) {
        switch (SizeOfType(typeId)) {
        case 2:
            {
                uint16_t* p = (uint16_t*)data;
                while (num--) {
                    uint16_t v = *p;
                    *p++ = ENDSWAP16(v);
                }
            }
            break;

        case 4:
            {
                uint32_t* p = (uint32_t*)data;
                while (num--) {
                    uint32_t v = *p;
                    *p++ = ENDSWAP32(v);
                }
            }
            break;

        case 8:
            {
                uint32_t* p = (uint32_t*)data;
                while (num--) {
                    uint32_t v = p[0];
                    uint32_t u = p[1];
                    *p++ = ENDSWAP32(u);
                    *p++ = ENDSWAP32(v);
                }
            }
            break;
        }
    }
}
Exemple #26
0
//------------------ 初始化结束处理 -------------------
bool M_EI_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	string			szTemp;
	M_EI_NA_1_t		m_ei_na;

	memcpy(&m_ei_na,udata,SizeOfType(typid));
	
	if (m_ei_na.coi.parts.cause == 0)
		szTemp.assign("当地电源合上 ");
	else if (m_ei_na.coi.parts.cause == 1)
		szTemp.assign("当地手动复位 ");
	else if (m_ei_na.coi.parts.cause == 2)
		szTemp.assign("远方复位 ");
	strcat(DrawStr,szTemp.c_str());

	if (m_ei_na.coi.parts.state)
		szTemp.assign("改变当地参数后的初始化 ");
	else
		szTemp.assign("未改变当地参数后的初始化 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #27
0
//------------------ 总召唤命令处理 -------------------
bool C_IC_NA_desc(char* DrawStr,unsigned char typid,char* udata)
{
	char			tmp[512] = {'\0'};
	string			szTemp;
	C_IC_NA_1_t		c_ic_na;

	memcpy(&c_ic_na,udata,SizeOfType(typid));
	
	if (c_ic_na.qoi.qoi >= 20 && c_ic_na.qoi.qoi <= 36)
	{
		if (c_ic_na.qoi.qoi == 20)
			szTemp.assign("站召唤(全局) ");
		else
		{
			sprintf(tmp,"第%d组召唤 ",c_ic_na.qoi.qoi);
			szTemp.assign(tmp);
		}
	}
	else
		szTemp.assign("使用保留 ");
	strcat(DrawStr,szTemp.c_str());

	return true;
}
Exemple #28
0
//Ïîäïðîãðàììà ñîðòèðîâêè ïîëó÷åííûõ äàííûõ (ñêëàäûâàåò èõ â ñòðóêòóðó MRAS)
MTBusMessage_t SortingData(MTree_t *Tree)
{
uint8_t        *pData;  
uint8_t        *pBuff;
VarStatus_t    VarStatus    = UNKNOWN_VAR;
MTBusMessage_t MTBusMessage = FREE;
uint16_t i;
uint16_t MRASIdx;
uint8_t inc;
uint8_t j;

//---Ïîèñê ïåðåìåííîé â òàáëèöå, è çàïîëíèå ñòðîêè òàáëèöè, åñëè îíà åñòü äëÿ ýòîé ïåðåìåííîé
for(i=0;i!=MRAS_COUNT;i++)
  {
  if((MRAS[i].DevAddr==Tree->DevAddr)&&(MRAS[i].vIdx==Tree->IdxRAS))
    {
    switch(Tree->Command)
      {
      case _cmdReadRAM:
      case _cmdReadRAM_EXT:

        MRAS[i].DevAddr   = Tree->DevAddr;
        MRAS[i].vIdx      = Tree->IdxRAS;
        MRAS[i].vType     = Tree->VarType;
        MRAS[i].vCnt      = Tree->VarCnt;
        pData             = &Tree->data[0];
        //-------Âû÷èñëåíèå èíäåêñà ñâîáîäíîãî ìåñòà â áóôåðå äàííûõ---------
        MRAS[i].pData     = &DataBuffer[0];
        
		for(MRASIdx=0;MRASIdx!=i;MRASIdx++)
          MRAS[i].pData+=MRAS[MRASIdx].vCnt*SizeOfType(MRAS[MRASIdx].vType);
        //-------------------------------------------------------------------
        pBuff=MRAS[i].pData;
		for(inc=0;inc!=MRAS[i].vCnt*SizeOfType(MRAS[i].vType);inc++)
          *pBuff++=*pData++;  
          
        if(VARIABLE_NOT_INIT_STATUS == MRAS[i].Status)
          MRAS[i].Status = VARIABLE_PART_INIT_STATUS;
        else if(VARIABLE_PART_INIT_STATUS==MRAS[i].Status)
          MRAS[i].Status = VARIABLE_IS_INIT_STATUS;

      break;

      case _cmdGetVarList:
        MRAS[i].DevAddr = Tree->DevAddr;
        MRAS[i].vIdx    = Tree->IdxRAS;
        MRAS[i].vType   = Tree->VarType;
        MRAS[i].vCnt    = Tree->VarCnt;
        MRAS[i].vWRE    = Tree->VarWRE;
        pData           = &Tree->data[0];
        //-------Âû÷èñëåíèå èíäåêñà ñâîáîäíîãî ìåñòà â áóôåðå äàííûõ---------
        MRAS[i].pData   = &DataBuffer[0];
        for(MRASIdx=0;MRASIdx!=i;MRASIdx++)
          MRAS[i].pData+=MRAS[MRASIdx].vCnt*SizeOfType(MRAS[MRASIdx].vType);
        //-------------------------------------------------------------------
        //MTBusModule->TBusConf.data+=1;
        for(j=0;j!=18;j++)
          MRAS[i].vInfo[j]=*pData++;
                  
        if(VARIABLE_NOT_INIT_STATUS == MRAS[i].Status)
          MRAS[i].Status = VARIABLE_PART_INIT_STATUS;
        else if(VARIABLE_PART_INIT_STATUS==MRAS[i].Status)
          MRAS[i].Status = VARIABLE_IS_INIT_STATUS;

      break;
      default:break;
      }
    VarStatus=KNOWN_VAR;
    }
  }
//-------------------------------------------------------------------------

//------------- Ïðèåì äàííûõ è äðóãîé èíôû ðàíåå íåèçâåñòíîé ïåðåìåííîé----
if(UNKNOWN_VAR==VarStatus)
  {
 
  for(i=0;i!=MRAS_COUNT;i++)
    {
    if(0x00==MRAS[i].DevAddr)//Íàéäåíà ñâîáîäíàÿ ñòðîêà â òàáëèöå
      {
      switch(Tree->Command)
        {
        case _cmdReadRAM:
        case _cmdReadRAM_EXT:
          MRAS[i].DevAddr = Tree->DevAddr;
          MRAS[i].vIdx    = Tree->IdxRAS;
          MRAS[i].vType   = Tree->VarType;
          MRAS[i].vCnt    = Tree->VarCnt;
          pData           = &Tree->data[0];

          //-------Âû÷èñëåíèå èíäåêñà ñâîáîäíîãî ìåñòà â áóôåðå äàííûõ---------
          MRAS[i].pData=&DataBuffer[0];
          for( MRASIdx=0;MRASIdx!=i;MRASIdx++)
                MRAS[i].pData+=MRAS[MRASIdx].vCnt*SizeOfType(MRAS[MRASIdx].vType);
          //-------------------------------------------------------------------
          pBuff=MRAS[i].pData;
          for( inc=0;inc!=MRAS[i].vCnt*SizeOfType(MRAS[i].vType);inc++)
                *pBuff++=*pData;
          CopyStr(&MRAS[i].vInfo[0],(uint8_t*)"New Variable");
          MTBusMessage=NEW_VAR_DETECTED;     
            
          if(VARIABLE_NOT_INIT_STATUS == MRAS[i].Status)
            MRAS[i].Status = VARIABLE_PART_INIT_STATUS;
          else if(VARIABLE_PART_INIT_STATUS==MRAS[i].Status)
            MRAS[i].Status = VARIABLE_IS_INIT_STATUS; 
        break;

        case _cmdGetVarList:
          MRAS[i].DevAddr = Tree->DevAddr;
          MRAS[i].vIdx    = Tree->IdxRAS;
          MRAS[i].vType   = Tree->VarType;
          MRAS[i].vCnt    = Tree->VarCnt;
          MRAS[i].vWRE    = Tree->VarWRE;

          pData = &Tree->data[0]; 
		  //-------Âû÷èñëåíèå èíäåêñà ñâîáîäíîãî ìåñòà â áóôåðå äàííûõ---------
          MRAS[i].pData=&DataBuffer[0];
            for( MRASIdx=0;MRASIdx!=i;MRASIdx++)
          MRAS[i].pData+=MRAS[MRASIdx].vCnt*SizeOfType(MRAS[MRASIdx].vType);
          //-------------------------------------------------------------------
          //MTBusModule->TBusConf.data+=1;
          for( j=0;j!=18;j++)
            MRAS[i].vInfo[j]=*pData++;
                    
          if(VARIABLE_NOT_INIT_STATUS == MRAS[i].Status)
            MRAS[i].Status = VARIABLE_PART_INIT_STATUS;
          else if(VARIABLE_PART_INIT_STATUS==MRAS[i].Status)
            MRAS[i].Status = VARIABLE_IS_INIT_STATUS;

        break;

        default:break;
        }
        break;
      }
    }
  }
return MTBusMessage;
}
Exemple #29
0
void MTBusFlowAnaliser(MTBusModule_t *MTBusModule,uint8_t byte)
{
if(MTBusModule->FlowAnaliser.State!=_CHS_ANALISE_STATE)
  CHS_16(&MTBusModule->FlowAnaliser.crc16,byte,calcCHS);


if(_SIGNATURE_ANALISE_STATE!=MTBusModule->FlowAnaliser.State)
  MTBusModule->FlowAnaliserTimeOutCounter=0;

switch(MTBusModule->FlowAnaliser.State)
  {
  case _SIGNATURE_ANALISE_STATE:

  if(byte==0x50)
    {
    MTBusModule->FlowAnaliser.pReceiveCHS =(uint8_t *)&MTBusModule->Tree.chs;
    MTBusModule->FlowAnaliser.pReceiveCHS++;
    MTBusModule->Tree.CntRAS  = 0x00;
    MTBusModule->Tree.IdxRAS  = 0x00;
    MTBusModule->Tree.error   = _errNone;
    MTBusModule->Tree.DataLen = 0;
    CHS_16(&MTBusModule->FlowAnaliser.crc16,0,resetCHS);
    MTBusModule->FlowAnaliser.State=_DEV_ADDR_RECEIVE_STATE;
    }
  break;  
  
  case _DEV_ADDR_RECEIVE_STATE:
    {
    MTBusModule->Tree.DevAddr=byte;
    MTBusModule->FlowAnaliser.State=_COMMAND_ANALISE_STATE;
    }
  break;

  case _COMMAND_ANALISE_STATE:
  MTBusModule->Tree.Command=(TbusCmd_t)byte;
    switch(MTBusModule->Tree.Command)
      {
      case _cmdReadRAM:
      case _cmdReadFlash:
      case _cmdReadEEPROM:

      case _cmdWriteRAM:
      case _cmdWriteFlash:
      case _cmdWriteEEPROM:

      MTBusModule->FlowAnaliser.State=_VAR_ADDR_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.VarAddr;
      MTBusModule->FlowAnaliser.inc=0;
      break;

      case _cmdId:
      MTBusModule->FlowAnaliser.State=_ID_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.inc=0;
      break;

      case _cmdSetAddr:
      MTBusModule->FlowAnaliser.State=_OLD_DEV_ADDR_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.inc=0;
      break;

      case _cmdGetVarList:
      case _cmdReadRAM_EXT:
      case _cmdWriteRAM_EXT:
      MTBusModule->FlowAnaliser.State=_IDX_RAS_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.IdxRAS;
      MTBusModule->FlowAnaliser.inc=0;
      break;

      case _cmdDataTransfer:
      MTBusModule->FlowAnaliser.State=_RESERVED_RECEIVE_STATE;
      break;  

	  case _cmdGetArch:
	  MTBusModule->FlowAnaliser.State=_ARCH_SIGN_RECEIVE_STATE;
	  break;

      default:
      MTBusModule->FlowAnaliser.State=_SIGNATURE_ANALISE_STATE;
      MTBusModule->Tree.Signature=0x50;
      MTBusModule->Tree.error=_errUnknownCmd;
      break;
      };
  break;  

  case _OLD_DEV_ADDR_RECEIVE_STATE:
  MTBusModule->Tree.OldDevAddr=byte;
  MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
  break;

  case _VAR_ADDR_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;

  if(MTBusModule->FlowAnaliser.inc++>=3)
    {
    MTBusModule->FlowAnaliser.State=_VAR_CNT_RECEIVE_STATE;
    }
  break;

  case _VAR_CNT_RECEIVE_STATE:
  MTBusModule->Tree.VarCnt=byte;
  MTBusModule->FlowAnaliser.State=_VAR_TYPE_ANALISE_STATE;
  break;

  case _VAR_TYPE_ANALISE_STATE:

  MTBusModule->Tree.VarType=(_VarType_t)byte;
  MTBusModule->Tree.VarSize=SizeOfType(MTBusModule->Tree.VarType);
  MTBusModule->Tree.DataLen=MTBusModule->Tree.VarCnt*MTBusModule->Tree.VarSize;

    switch(MTBusModule->Tree.Command)
    {
    case _cmdGetVarList:
      MTBusModule->FlowAnaliser.State=_VAR_WRITE_EN_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.inc=0;
    break;

    case _cmdReadRAM_EXT:
      //MTBusModule->Tree.dataLen=1+MTBusModule->Tree.VarCnt*SizeOfType(MTBusModule->Tree.VarType);
      MTBusModule->FlowAnaliser.State=_DATA_RECEIVE_STATE;
      MTBusModule->FlowAnaliser.inc=0;

    break;

    case _cmdReadRAM:
    case _cmdReadFlash:
    case _cmdReadEEPROM:
    MTBusModule->FlowAnaliser.State=_DATA_RECEIVE_STATE;
    MTBusModule->FlowAnaliser.inc=0;
    break;

    case _cmdWriteRAM:
    case _cmdWriteFlash:
    case _cmdWriteEEPROM:
    case _cmdWriteRAM_EXT: 
      MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
      MTBusModule->FlowAnaliser.inc=0;
    break;


    default:
    MTBusModule->FlowAnaliser.State=_SIGNATURE_ANALISE_STATE;
    break;//MTBusModule->Tree.Command
    }

  break;

  case _ID_RECEIVE_STATE:
  MTBusModule->Tree.data[MTBusModule->FlowAnaliser.inc]=byte;

  if(MTBusModule->FlowAnaliser.inc++>=31)
    {
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->Tree.DataLen=32;
    MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
    }
  break;

  case _IDX_RAS_RECEIVE_STATE:
    *MTBusModule->FlowAnaliser.pReceive++=byte;
     if(MTBusModule->FlowAnaliser.inc++>=1)
      {
      if(_cmdWriteRAM_EXT==MTBusModule->Tree.Command)
        {
        MTBusModule->FlowAnaliser.State=_IDX_MAS_RECEIVE_STATE;
        MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.IdxMAS;
        }
      else
        {
        MTBusModule->FlowAnaliser.State=_CNT_RAS_RECEIVE_STATE;  
        MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.CntRAS;
        }
      MTBusModule->FlowAnaliser.inc=0;
      }
  break;


  case _CNT_RAS_RECEIVE_STATE:
  //for(uint8_t i=0;i!=32;i++)
  // MTBusModule->Tree.data[i]=0;

    *MTBusModule->FlowAnaliser.pReceive++=byte;
     if(MTBusModule->FlowAnaliser.inc++>=1)
      {
      switch(MTBusModule->Tree.Command)
        {
        case _cmdGetVarList:
        case _cmdReadRAM_EXT:
        if((0xFFFF!=MTBusModule->Tree.CntRAS)&&(0xFFFF!=MTBusModule->Tree.IdxRAS))
          {
          MTBusModule->FlowAnaliser.State=_VAR_CNT_RECEIVE_STATE;
          MTBusModule->FlowAnaliser.inc=0;
          }
        else
          MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
        MTBusModule->FlowAnaliser.inc=0;
        break;
        default:MTBusModule->FlowAnaliser.State=_SIGNATURE_ANALISE_STATE;break;
          }
        }
  break;

  
  case _VAR_WRITE_EN_RECEIVE_STATE:
  MTBusModule->Tree.VarWRE = byte;  
  MTBusModule->Tree.DataLen=18;   
  MTBusModule->FlowAnaliser.State=_DATA_RECEIVE_STATE;
  MTBusModule->FlowAnaliser.inc=0;  
  break;  

  case _IDX_MAS_RECEIVE_STATE:
     *MTBusModule->FlowAnaliser.pReceive++=byte;
     if(MTBusModule->FlowAnaliser.inc++>=1)
      {  
      MTBusModule->FlowAnaliser.State=_VAR_CNT_RECEIVE_STATE;  
      MTBusModule->FlowAnaliser.inc=0;
      }
  break;

  case _DATA_RECEIVE_STATE:
  //if(inc==0)
    MTBusModule->Tree.data[MTBusModule->FlowAnaliser.inc]=byte;

  if(MTBusModule->FlowAnaliser.inc++>=MTBusModule->Tree.DataLen-1)
    {
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
    }
  break;

  case _ARCH_SIGN_RECEIVE_STATE:
  MTBusModule->Tree.ArchSign = (ArchSign_t) byte;
  MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchDay;
  MTBusModule->FlowAnaliser.inc=0;
  MTBusModule->FlowAnaliser.State=_ARCH_DAY_RECEIVE_STATE;
  break;

  case _ARCH_DAY_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=1)
    {
    MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchHalfSec;
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->FlowAnaliser.State=_ARCH_HALF_SEC_RECEIVE_STATE;
    }
  break;

  case _ARCH_HALF_SEC_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=3)
	{
	if(ARCH_CELL_FORMAT_SIGN==MTBusModule->Tree.ArchSign)
      {
      MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchCellNumber;
      MTBusModule->FlowAnaliser.inc=0;
      MTBusModule->FlowAnaliser.State=_ARCH_CELL_NUMBER_RECEIVE_STATE;
      }
    else
      {
	  MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchRecCount;
      MTBusModule->FlowAnaliser.inc=0;
	  MTBusModule->FlowAnaliser.State=_ARCH_REC_COUNT_RECEIVE_STATE;
      }
    }
  break;

  case _ARCH_REC_COUNT_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=3)
	{
	if(0xFFFFFFFF==MTBusModule->Tree.ArchRecCount)//Îáíàðóæåí òåðìèíàòîð
	  {
	  MTBusModule->FlowAnaliser.inc=0;
	  MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
	  }
	else
		{
		MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchPeriod;
		MTBusModule->FlowAnaliser.inc=0;
		MTBusModule->FlowAnaliser.State=_ARCH_PERIOD_RECEIVE_STATE;
		}
	}
  break;

  case _ARCH_PERIOD_RECEIVE_STATE:
   *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=1)
    {
    MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchRecSize;
    MTBusModule->FlowAnaliser.inc=0;
	MTBusModule->FlowAnaliser.State=_ARCH_REC_SIZE_RECEIVE_STATE;
    }
  break;


  case _ARCH_REC_SIZE_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=1)
	{
	MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.data[0];
    MTBusModule->FlowAnaliser.inc=0;
	MTBusModule->FlowAnaliser.State=_ARCH_REC_RECEIVE_STATE;
    }
  break;




  case _ARCH_REC_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=(uint8_t)((MTBusModule->Tree.ArchRecSize*MTBusModule->Tree.ArchRecCount)-1))
    {
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
    }

  break;

  case _ARCH_CELL_NUMBER_RECEIVE_STATE: //Ïðèåì íîìåðà àðõèâíîé ÿ÷åéêè
  *MTBusModule->FlowAnaliser.pReceive++=byte;

  if(MTBusModule->FlowAnaliser.inc++>=1)
    {
    MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.ArchCellCnt;
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->FlowAnaliser.State=_ARCH_CELL_CNT_RECEIVE_STATE;
    }
  break;


  case _ARCH_CELL_CNT_RECEIVE_STATE: //Ïðèåì êîëè÷åñòâà àðõèâíûõ ÿ÷ååê
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=1)
    {
    MTBusModule->FlowAnaliser.pReceive=(uint8_t *)&MTBusModule->Tree.data[0];
    MTBusModule->FlowAnaliser.inc=0;
    if(0xFFFF==MTBusModule->Tree.ArchCellNumber)
      MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
    else
      MTBusModule->FlowAnaliser.State=_ARCH_CELL_FORMAT_RECEIVE_STATE;
    }

  break;

  case _ARCH_CELL_FORMAT_RECEIVE_STATE:
  *MTBusModule->FlowAnaliser.pReceive++=byte;
  if(MTBusModule->FlowAnaliser.inc++>=7)
    {
    MTBusModule->FlowAnaliser.inc=0;
    MTBusModule->FlowAnaliser.State=_CHS_ANALISE_STATE;
    }
  break;

  case _RESERVED_RECEIVE_STATE:
  MTBusModule->Tree.Reserved      = byte;  
  MTBusModule->FlowAnaliser.State = _STATE_RECEIVE_STATE;
  break;  
  
  case _STATE_RECEIVE_STATE:
  MTBusModule->Tree.DTState = (MDTState_t)byte;  
  MTBusModule->FlowAnaliser.State = _FRAG_CNT_IDX_RECEIVE_STATE;  
  break;  
 
  case _FRAG_CNT_IDX_RECEIVE_STATE:
  MTBusModule->Tree.FragCnt  = byte>>4;
  MTBusModule->Tree.FragIdx  = 0x0F&byte;
  MTBusModule->FlowAnaliser.State =  _PROT_TYPE_RECEIVE_STATE;
  break;  
  
  case _PROT_TYPE_RECEIVE_STATE:
  MTBusModule->Tree.ProtType=(MProtType_t)byte;  
  MTBusModule->FlowAnaliser.State = _DATA_CNT_RECEIVE_STATE;
  break;  
  
  case _DATA_CNT_RECEIVE_STATE:
  MTBusModule->Tree.DataCnt       = byte;
  MTBusModule->Tree.DataLen       = MTBusModule->Tree.DataCnt;
  MTBusModule->FlowAnaliser.State = _DATA_RECEIVE_STATE;
  MTBusModule->FlowAnaliser.inc   = 0;    
  break;  
  
    
  case _CHS_ANALISE_STATE:
  *MTBusModule->FlowAnaliser.pReceiveCHS--=byte;
  if(MTBusModule->FlowAnaliser.inc++>=1)
    {
    MTBusModule->FlowAnaliser.State=_SIGNATURE_ANALISE_STATE;
    if(MTBusModule->FlowAnaliser.crc16==MTBusModule->Tree.chs)
      {
      MTBusModule->Tree.Signature=0x50;
      }
    else
      {
      MTBusModule->Tree.error     = _errCHS;
      MTBusModule->Tree.Signature = 0x50;
      }
    }
  break;  
  
  default:
  MTBusModule->FlowAnaliser.State=_SIGNATURE_ANALISE_STATE;
  break;
  };
}
Exemple #30
0
//--------Ïîäïðîãðàììà ôîðìèðîâàíèÿ çàïðîñà-------------
void MTBusReq(MTBusModule_t *MTBusModule,MTBusDescriptor_t *Descriptor)
{
uint8_t *pBuff;
uint8_t *pSource;
uint16_t CHS;
uint8_t TxLen;

uint8_t i;
 
MTBusModule->LastTBusReq=*Descriptor;

MTBusModule->TimeOut_=0;

pBuff=&MTBusModule->TxBuff[0];

pSource = (uint8_t *)&Descriptor->ServiceKey;

if(Descriptor->ServiceKey!=NONE_SERVICE_KEY)
  {
	  uint8_t inc;
  for(inc=0;inc!=sizeof(ServiceKey_t);inc++)
    *pBuff++ = *pSource++;
  }

*pBuff++=0x50;

switch(Descriptor->Command)
{
case _cmdReadRAM:
case _cmdReadEEPROM:
case _cmdReadFlash:
  
  TxLen=11;
  
  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;

  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr));
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x08);
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x10);
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x18);

  *pBuff++=Descriptor->VarCnt;
  *pBuff++=Descriptor->VarType;
break;

case _cmdId:
  TxLen=5;
 
  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
break;

case _cmdSetAddr:
  TxLen=6;
  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
  *pBuff++=Descriptor->NewDevAddr;
break;

case _cmdReadRAM_EXT:
case _cmdGetVarList:
  TxLen=9;

  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
  *pBuff++=(uint8_t)Descriptor->IdxRAS;
  *pBuff++=(uint8_t)(Descriptor->IdxRAS>>0x08);
  *pBuff++=(uint8_t)Descriptor->CntRAS;
  *pBuff++=(uint8_t)(Descriptor->CntRAS>>0x08);
break;

case _cmdWriteRAM_EXT:
  TxLen=11+Descriptor->VarCnt*SizeOfType(Descriptor->VarType);

  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
  *pBuff++=(uint8_t)Descriptor->IdxRAS;
  *pBuff++=(uint8_t)(Descriptor->IdxRAS>>0x08);
  *pBuff++=(uint8_t)Descriptor->IdxMAS;
  *pBuff++=(uint8_t)(Descriptor->IdxMAS>>0x08);
  *pBuff++=Descriptor->VarCnt;
  *pBuff++=Descriptor->VarType;
 
 
  for(i=0;i!=TxLen-11;i++)
    *pBuff++=*(Descriptor->pData++);

break;


case _cmdWriteRAM:
case _cmdWriteEEPROM:
case _cmdWriteFlash:

  TxLen=9+SizeOfType(Descriptor->VarType)*Descriptor->VarCnt+2;
   
  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr));
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x08);
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x10);
  *pBuff++=(uint8_t)(((uint32_t )Descriptor->VarAddr)>>0x18);
  *pBuff++=Descriptor->VarCnt;
  *pBuff++=Descriptor->VarType;
  for(i=0;i!=TxLen-11;i++)
    *pBuff++=*(Descriptor->pData++);
break;

case _cmdDataTransfer:
  TxLen=10+Descriptor->DataCnt;

  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;
  *pBuff++=Descriptor->Reserved;
  *pBuff++=(uint8_t)Descriptor->State;
  *pBuff++=((Descriptor->FragCnt<<4)|Descriptor->FragIdx);
  *pBuff++=(uint8_t)Descriptor->ProtType;
  *pBuff++=Descriptor->DataCnt;
  for(i=0;i!=Descriptor->DataCnt;i++)
	*pBuff++=*(Descriptor->pData++);
break;

case _cmdGetArch:
  TxLen=16;//+Descriptor->DataCnt;

  *pBuff++=Descriptor->DevAddr;
  *pBuff++=Descriptor->Command;

  *pBuff++=(uint8_t)Descriptor->ArchSign;
  
  pSource = (uint8_t *)&Descriptor->ArchDay;
  *pBuff++=*pSource++;
  *pBuff++=*pSource++;

  pSource = (uint8_t *)&Descriptor->ArchHalfSec;
  *pBuff++=*pSource++;
  *pBuff++=*pSource++;
  *pBuff++=*pSource++;
  *pBuff++=*pSource++;

  if(ARCH_CELL_FORMAT_SIGN==Descriptor->ArchSign)//Çàïðîñ ôîðìàòà àðõèâíûõ ÿ÷ååê
    {
    pSource = (uint8_t *)&Descriptor->ArchCellNumber;
    *pBuff++=*pSource++;
    *pBuff++=*pSource++;
  
    pSource = (uint8_t *)&Descriptor->ArchCellCnt;
    *pBuff++=*pSource++;
    *pBuff++=*pSource++;
    }
  else
    {
    pSource = (uint8_t *)&Descriptor->ArchRecCount;
    *pBuff++=*pSource++;
    *pBuff++=*pSource++;
    *pBuff++=*pSource++;
    *pBuff++=*pSource++;
     }

  //*pBuff++=Descriptor->Reserved;
  //*pBuff++=(uint8_t)Descriptor->State;
  //*pBuff++=((Descriptor->FragCnt<<4)|Descriptor->FragIdx);
  //*pBuff++=(uint8_t)Descriptor->ProtType;
  //*pBuff++=Descriptor->DataCnt;
break;


default:break;
}
if(Descriptor->ServiceKey!=NONE_SERVICE_KEY)
  {
  if(Descriptor->ServiceKey!=NONE_SERVICE_KEY)
    TxLen+=sizeof(ServiceKey_t);  
  CHS=CALC_CHS_16(&MTBusModule->TxBuff[1+sizeof(ServiceKey_t)],TxLen-3-sizeof(ServiceKey_t));
  }
else
  {
  CHS=CALC_CHS_16(&MTBusModule->TxBuff[1],TxLen-3);
  }
*pBuff++=(uint8_t)(CHS>>0x08);
*pBuff++=(uint8_t)(CHS);

Descriptor->SenderFunct(MTBusModule->TxBuff,TxLen);
}