⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db_ms.c

📁 DVB软件,基于CT216软件的开发源程序.
💻 C
📖 第 1 页 / 共 5 页
字号:
	DBFS_RelationGetNet(_network_get_relation_index(m_enSystemType, u16NetIdx), &stNetRel);
	DBFS_InfoWrite(EN_SAT_TABLE, stNetRel.u16LogicAddress, (u8*)pstNetDetail);

	_update_tp_with_sat(m_enSystemType, u16NetIdx, pstNetDetail);
	return TRUE;
}
/*******************************************************************************************/

s16 DVB_Get_OthersSatIdx(void)
{
    return (m_as16NetTotal[EN_SYSTEM_TYPE_DVBS]-1);
}
/*******************************************************************************************/

static u16 _del_srv_by_tp(EN_SYSTEM_TYPE enSysType, EN_SERVICE_TYPE enSrvType, u16 u16TpIdx, bool8 b8DeleteTP)
{
	u16			u16Idx, u16Idx2, u16Deleted;
	u16			u16RelIdx;
	DB_SrvRel	stSrvRel;
	DB_ExtraSrv	stExtraSrv;
	DB_TpRel	stTpRel;
	DB_SatRel	stNetRel;
	
	for(u16Idx = u16Idx2 = 0; u16Idx < m_as16SrvTotal[enSysType][enSrvType]; u16Idx++)
	{
		u16RelIdx = _service_get_relation_index(enSysType, enSrvType, u16Idx);
		DBFS_RelationGetSrv(u16RelIdx, &stSrvRel);
		
		if(stSrvRel.u16TpIdx == u16TpIdx)
		{
			DBFS_InfoDestroy(EN_SRV_TABLE, stSrvRel.u16LogicAddress);
			continue;
		}
		if(b8DeleteTP && (stSrvRel.u16TpIdx  > u16TpIdx))
		{
			stSrvRel.u16TpIdx--;
		}	
		_extra_srvinfo_get(u16RelIdx, &stExtraSrv);
		
		u16RelIdx = _service_get_relation_index(enSysType, enSrvType, u16Idx2);
		DBFS_RelationSetSrv(u16RelIdx, &stSrvRel);
		_extra_srvinfo_set (u16RelIdx, &stExtraSrv);
		u16Idx2++;
	}
	
	for(u16Idx = u16Idx2; u16Idx < m_as16SrvTotal[enSysType][enSrvType]; u16Idx++)
	{
		memset(&stSrvRel,   0xFF, sizeof(DB_SrvRel  ));
		memset(&stExtraSrv, 0xFF, sizeof(DB_ExtraSrv));
		
		u16RelIdx = _service_get_relation_index(enSysType, enSrvType, u16Idx);
		DBFS_RelationSetSrv(u16RelIdx, &stSrvRel  );
		_extra_srvinfo_set (u16RelIdx, &stExtraSrv);
	}
	
	u16Deleted = m_as16SrvTotal[enSysType][enSrvType] - u16Idx2;
	m_as16SrvTotal[enSysType][enSrvType] = u16Idx2;
	
	// Update network relation
	DBFS_RelationGetTp(_tp_get_relation_index(enSysType, u16TpIdx), &stTpRel);
	for(u16Idx = stTpRel.u16SatIdx; u16Idx < m_as16NetTotal[enSysType]; u16Idx++)
	{
		u16RelIdx = _network_get_relation_index(enSysType, u16Idx);
		DBFS_RelationGetNet(u16RelIdx, &stNetRel);
		if(	(stNetRel.as16SrvStartIdx[enSrvType] < 0) || 
			(stNetRel.as16SrvEndIdx  [enSrvType] < 0) )
		{
			continue;
		}
		if(u16Idx > stTpRel.u16SatIdx)
		{
			stNetRel.as16SrvStartIdx[enSrvType] -= u16Deleted;
		}	
		stNetRel.as16SrvEndIdx  [enSrvType] -= u16Deleted;

		if(	(stNetRel.as16SrvStartIdx[enSrvType] < 0) || 
			(stNetRel.as16SrvEndIdx[enSrvType]   < 0) )
		{
			stNetRel.as16SrvStartIdx[enSrvType] =
			stNetRel.as16SrvEndIdx  [enSrvType] = -1;
		}
		DBFS_RelationSetNet(u16RelIdx, &stNetRel);
	}

	return u16Deleted;
}
/*******************************************************************************************/

static u16 _del_tp_by_net(EN_SYSTEM_TYPE enSysType, u16 u16NetIdx)
{
	DB_TpRel	stTpRel;
	u16			u16Idx, u16Idx2, u16Deleted;
	
	for(u16Idx = u16Idx2 = 0; u16Idx < m_as16TpTotal[enSysType]; u16Idx++)
	{
		DBFS_RelationGetTp(_tp_get_relation_index(enSysType, u16Idx), &stTpRel);
		
		if(stTpRel.u16SatIdx == u16NetIdx)
		{
			_del_srv_by_tp(enSysType, EN_SERVICE_TYPE_TV   , u16Idx2, TRUE);
			_del_srv_by_tp(enSysType, EN_SERVICE_TYPE_RADIO, u16Idx2, TRUE);
			
			DBFS_InfoDestroy(EN_TP_TABLE, stTpRel.u16LogicAddress);
			continue;
		}
		if(stTpRel.u16SatIdx  > u16NetIdx)	
		{
			stTpRel.u16SatIdx--;
		}
		
		DBFS_RelationSetTp(_tp_get_relation_index(enSysType, u16Idx2), &stTpRel);
		u16Idx2++;
	}
	
	for(u16Idx = u16Idx2; u16Idx < m_as16TpTotal[enSysType]; u16Idx++)
	{
		memset(&stTpRel, 0xFF, sizeof(DB_TpRel));
		DBFS_RelationSetTp(_tp_get_relation_index(enSysType, u16Idx), &stTpRel);
	}
	
	u16Deleted = m_as16TpTotal[enSysType] - u16Idx2;
	m_as16TpTotal[enSysType] = u16Idx2;
	return u16Deleted;
}
/*******************************************************************************************/

void DVB_NetDelete(u16 u16NetIdx)
{
	DB_SatRel	stNetRel;
	u16			u16idx;

	DBMS_DBG((" DVB_NetDelete()-SysType=%d,u16NetIdx=%d,Total=%d\n",
		 m_enSystemType, u16NetIdx, m_as16NetTotal[m_enSystemType]));

	if(m_enSystemType == EN_SYSTEM_TYPE_DVBS)
	{
		if(u16NetIdx >= m_as16NetTotal[m_enSystemType] - 1)	return;
	}
	else
	{
		if(u16NetIdx >= m_as16NetTotal[m_enSystemType])		return;
	}

	_del_tp_by_net (m_enSystemType, u16NetIdx);

	// Remove satellite info
	DBFS_RelationGetNet(_network_get_relation_index(m_enSystemType, u16NetIdx), &stNetRel);
	DBFS_InfoDestroy(EN_SAT_TABLE, stNetRel.u16LogicAddress);

	//Update network relation
	for(u16idx = u16NetIdx + 1; u16idx < m_as16NetTotal[m_enSystemType]; u16idx++)
	{
		DBFS_RelationGetNet(_network_get_relation_index(m_enSystemType, u16idx  ), &stNetRel);
		DBFS_RelationSetNet(_network_get_relation_index(m_enSystemType, u16idx-1), &stNetRel);
	}

	memset(&stNetRel, 0xFF, sizeof(stNetRel));
	DBFS_RelationSetNet(_network_get_relation_index(m_enSystemType, u16idx-1), &stNetRel);

	m_as16NetTotal[m_enSystemType]--;
}
/*******************************************************************************************/

bool8 DVB_TPAddEx(u16 *pu16TpIdx, DVB_TPInfoEx *pstTpInfo)
{
	DB_TpRel		stTpRel;
	DB_TpDetailEx	stTpDetail;

	_dvb_tp_2_db(m_enSystemType, pstTpInfo, &stTpRel, &stTpDetail);

	DBMS_DBG((" DVB_TPAddEx()-SysType=%d,u16NetIdx=%d,Total=%d\n",
		 m_enSystemType, stTpRel.u16SatIdx, _tp_get_total_all_system()));

	return DVB_TPAddDetailEx(pu16TpIdx, &stTpDetail, stTpRel.u16SatIdx);
}
/*******************************************************************************************/

bool8 DVB_TPAddDetailEx(u16 *pu16TpIdx, DB_TpDetailEx *pstTpItem, u16 u16NetIdx)
{
	s16			s16idx;
	DB_TpRel	stTpRel;
	DB_SrvRel	stSrvRel;
	u16			u16InsertIdx, u16RelIdx;
	EN_SERVICE_TYPE	enSrvType;

	DBMS_DBG((" DVB_TPAddDetailEx()-SysType=%d,u16NetIdx=%d,Total=%d\n",
		 m_enSystemType, u16NetIdx, _tp_get_total_all_system()));

	if(_tp_get_total_all_system() >= MAX_NUM_OF_TP)
	{
		DBMS_DBG(( "\nTP List Full\n"));
		return FALSE;
	}

	/* Find the insert position */
	for(s16idx = m_as16TpTotal[m_enSystemType] - 1; s16idx >= 0; s16idx--)
	{
		DBFS_RelationGetTp(_tp_get_relation_index(m_enSystemType, s16idx), &stTpRel);
		if(stTpRel.u16SatIdx == u16NetIdx)
		{
			break;
		}	
	}

	if(s16idx < 0)	
	{
		u16InsertIdx = m_as16TpTotal[m_enSystemType];
	}	
	else
	{
		u16InsertIdx = s16idx + 1;
	}
	
	/* Shift backward TP relation */
	for(s16idx = m_as16TpTotal[m_enSystemType] - 1; s16idx >= u16InsertIdx; s16idx--)
	{
		DBFS_RelationGetTp(_tp_get_relation_index(m_enSystemType, s16idx  ), &stTpRel);
		DBFS_RelationSetTp(_tp_get_relation_index(m_enSystemType, s16idx+1), &stTpRel);
	}

	/* Update service relation */
	for(enSrvType = 0; enSrvType < EN_SERVICE_TYPE_TOTAL; enSrvType++)
	{
		for(s16idx = 0; s16idx < m_as16SrvTotal[m_enSystemType][enSrvType]; s16idx++)
		{
			u16RelIdx = _service_get_relation_index(m_enSystemType, enSrvType, s16idx);
			DBFS_RelationGetSrv(u16RelIdx, &stSrvRel);
			
			if(stSrvRel.u16TpIdx < u16InsertIdx)
			{
				continue;
			}	
			stSrvRel.u16TpIdx++;
			DBFS_RelationSetSrv(u16RelIdx, &stSrvRel);
		}
	}

	/* Insert one */
	stTpRel.u16LogicAddress = DBFS_InfoNew(EN_TP_TABLE, (u8*)pstTpItem);
	stTpRel.u16SatIdx       = u16NetIdx;
	DBFS_RelationSetTp(_tp_get_relation_index(m_enSystemType, u16InsertIdx), &stTpRel);

	*pu16TpIdx = u16InsertIdx;
	m_as16TpTotal[m_enSystemType]++;
	return TRUE;
}
/*******************************************************************************************/

bool8 DVB_GetFirstServicebyTP(EN_SERVICE_TYPE enSrvType, u16 u16TpIdx, DVB_ServiceInfo *pstService, u16 *pu16Index)
{
	u16			u16idx, u16RelIdx;
	DB_SrvRel	stSrvRel;

	DBMS_DBG((" DVB_GetFirstServicebyTP()-SysType=%d,enSrvType=%d,Total=%d\n",
		 m_enSystemType, enSrvType, u16TpIdx, m_as16SrvTotal[m_enSystemType][enSrvType]));

	for(u16idx = 0; u16idx < m_as16SrvTotal[m_enSystemType][enSrvType]; u16idx++)
	{
		u16RelIdx = _service_get_relation_index(m_enSystemType, enSrvType, u16idx);
		DBFS_RelationGetSrv(u16RelIdx, &stSrvRel);
		if(stSrvRel.u16TpIdx == u16TpIdx)
		{
			*pu16Index = u16idx;
			DVB_ServiceRead(enSrvType, *pu16Index, pstService);
			return TRUE;
		}
	}

	return FALSE;
}
/*******************************************************************************************/

bool8 DVB_GetFirstServicebyFB(EN_SERVICE_TYPE enSrvType, u32 u32Freq, u8 u8BandWidth, DVB_ServiceInfo *pstService, u16 *pu16Index)
{
	u16			u16idx, u16RelIdx, u16TpIdx = 0;
	DB_SrvRel	stSrvRel;
	DVB_TPInfoEx stTpInfo;
	
	DBMS_DBG((" DVB_GetFirstServicebyTP()-SysType=%d,enSrvType=%d,Total=%d\n",
		 m_enSystemType, enSrvType, u16TpIdx, m_as16SrvTotal[m_enSystemType][enSrvType]));

	//Get TP Index by Frequency & Bandwidth
	for(u16TpIdx = 0; u16TpIdx < m_as16TpTotal[m_enSystemType]; u16TpIdx++)
	{
		DVB_TPReadEx(u16TpIdx, &stTpInfo);
		if((stTpInfo.tpTerre.u32FrequencyKHz == u32Freq) && (stTpInfo.tpTerre.u8BandwidthMHz == u8BandWidth))
		{
			break;
		}	
	}

	//Get First Service by TP index
	for(u16idx = 0; u16idx < m_as16SrvTotal[m_enSystemType][enSrvType]; u16idx++)
	{
		u16RelIdx = _service_get_relation_index(m_enSystemType, enSrvType, u16idx);
		DBFS_RelationGetSrv(u16RelIdx, &stSrvRel);
		if(stSrvRel.u16TpIdx == u16TpIdx)
		{
			*pu16Index = u16idx;
			DVB_ServiceRead(enSrvType, *pu16Index, pstService);
			return TRUE;
		}
	}

	return FALSE;
}
/*******************************************************************************************/

void DVB_ServiceDelByTp(u16 u16TpIdx)
{
	DBMS_DBG((" DVB_ServiceDelByTp()-SysType=%d,u16TpIndex=%d,Total=%d\n",
		 m_enSystemType, u16TpIdx, m_as16TpTotal[m_enSystemType]));

    _del_srv_by_tp(m_enSystemType, EN_SERVICE_TYPE_TV   , u16TpIdx, FALSE);
    _del_srv_by_tp(m_enSystemType, EN_SERVICE_TYPE_RADIO, u16TpIdx, FALSE);
}
/*******************************************************************************************/

void DVB_TPDelete(u16 u16TpIndex, u16* pu16NofTV, u16* pu16NofRadio )
{
	DB_TpRel	stTpRel;
	u16			u16idx;

	DBMS_DBG((" DVB_TPDelete()-SysType=%d,u16TpIndex=%d,Total=%d\n",
		 m_enSystemType, u16TpIndex, m_as16TpTotal[m_enSystemType]));

	if(u16TpIndex >= m_as16TpTotal[m_enSystemType])
	{
		return;
	}
    *pu16NofTV    = _del_srv_by_tp(m_enSystemType, EN_SERVICE_TYPE_TV   , u16TpIndex, TRUE);
    *pu16NofRadio = _del_srv_by_tp(m_enSystemType, EN_SERVICE_TYPE_RADIO, u16TpIndex, TRUE);

	/* Remove TP info */
	DBFS_RelationGetTp(_tp_get_relation_index(m_enSystemType, u16TpIndex), &stTpRel);
	DBFS_InfoDestroy(EN_TP_TABLE, stTpRel.u16LogicAddress);

	/* Shift forward TP relation */
	for(u16idx = u16TpIndex+1; u16idx < m_as16TpTotal[m_enSystemType]; u16idx++)
	{
		DBFS_RelationGetTp(_tp_get_relation_index(m_enSystemType, u16idx  ), &stTpRel);
		DBFS_RelationSetTp(_tp_get_relation_index(m_enSystemType, u16idx-1), &stTpRel);
	}

	memset(&stTpRel, 0xFF, sizeof(DB_TpRel));
	DBFS_RelationSetTp(_tp_get_relation_index(m_enSystemType, u16idx-1), &stTpRel);

	m_as16TpTotal[m_enSystemType]--;
}
/*******************************************************************************************/

bool8 DVB_TPReadEx(u16 u16TpIndex, DVB_TPInfoEx *pstTpInfo)
{
	DB_TpRel		stTpRel;
	DB_TpDetailEx	stTpDetail;

	DBMS_DBG((" DVB_TPReadEx()-TpIdx=%d,Total=%d,SysType=%d\n",
		 u16TpIndex, m_as16TpTotal[m_enSystemType], m_enSystemType));

	memset(pstTpInfo, 0, sizeof(DVB_TPInfoEx));
	if(DVB_TPReadDetailEx(u16TpIndex, &stTpDetail, &stTpRel) == FALSE)
	{
		return FALSE;
	}
	_db_2_dvb_tp(m_enSystemType, pstTpInfo, &stTpRel, &stTpDetail);
	return TRUE;
}
/*******************************************************************************************/

bool8 DVB_TPReadDetailEx(u16 u16TpIndex, DB_TpDetailEx *pstTpItem, DB_TpRel *pstTpRel)
{
	DBMS_DBG((" DVB_TPReadDetailEx()-TpIdx=%d,Total=%d,SysType=%d\n",
		 u16TpIndex, m_as16TpTotal[m_enSystemType], m_enSystemType));

	memset(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -