📄 ntscclsh.c
字号:
// INPUT : lpCluster - pointer to a DM3CLUSTER object
// dwErrorCode - error code
// OUTPUT : NONE
// RETURNS : pointer to a VOID object
// CAUTIONS :
/////////////////////////////////////////////////////////////////////////////
LPVOID NETTSCClusterSlotAssignCmplt(LPDM3CLUSTER lpCluster,
DWORD dwErrorCode)
{
DM3STATUS dm3Status;
LPVOID lpvRet=NULL;
LPNETTSCCLUSTER lpNETTSCCluster;
lpNETTSCCluster = (LPNETTSCCLUSTER) lpCluster->lpUserInfo;
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_LISTENCMPLT;
if(dwErrorCode == NO_ERROR) {
// activate the ctbus output port
dm3Status = Dm3ClusterActivate(lpCluster);
if(dm3Status != DM3SUCCESS) {
lpNETTSCCluster->dwErrorCode = GetLastError();
}
}
else {
lpNETTSCCluster->dwErrorCode = dwErrorCode;
}
return lpvRet;
}
///////////////////////////////////////////////////////////////////////////////////
// NAME : OnNETTSCClusterGetCompCmplt(lpCluster, qcdCompAddr, dwErrorCode)
// DESCRIPTION : The method called when getting a component instance from the given
// lpCluster completes. This method is initiated using
// .Dm3ClusterGetComp()
// If the get component is successful (indicated by the dwErrorCode),
// then the qcdCompFwAddr is a valid Comp FW address. The component
// pertains to the last queried component using Dm3ClusterGetComp()
// method.
// This method must be filled in by the Dm3Cluster user.
// INPUT : lpCluster - pointer to the Dm3Cluster object
// qcdCompAddr - contains the address of the component instance
// dwErrorCode - errorCode identifying the error
// OUTPUT : NONE
// RETURNS : pointer to a VOID object
// CAUTIONS :
///////////////////////////////////////////////////////////////////////////////////
LPVOID OnNETTSCClusterGetCompCmplt(LPDM3CLUSTER lpCluster,
QCompDesc qcdCompAddr,
DWORD dwErrorCode)
{
LPNETTSCCLUSTER lpNETTSCCluster;
LPVOID lpvRet = NULL;
BOOL fGetAllCompsCmplt = FALSE;
lpNETTSCCluster = (LPNETTSCCLUSTER) lpCluster->lpUserInfo;
if(dwErrorCode == NO_ERROR) {
if(NETTSCClusterGotComponent(lpNETTSCCluster, qcdCompAddr) != DM3SUCCESS) {
fGetAllCompsCmplt = TRUE;
}
else if(lpNETTSCCluster->ucNumCompsFound == 1) {
fGetAllCompsCmplt = TRUE;
}
}
else {
fGetAllCompsCmplt = TRUE;
}
if(fGetAllCompsCmplt) {
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_GETALLCOMPSCMPLT;
lpNETTSCCluster->dwErrorCode = dwErrorCode;
}
return lpvRet;
}
//////////////////////////////////////////////////////////////////////////////////////////
// NAME : NETTSCClusterFindCmplt
// DESCRIPTION : The internal method called when the given lpCluster object
// find completes. The cluster find is initiated by the
// Dm3ClusterFind() method If the cluster is successfully found
// (indicated by the dwErrorCode), then the lpCluster object will have
// a valid Cluster FW address.
// INPUT : lpCluster - pointer to the DM3CLUSTER object
// qcdAddr - a valid QCompDesc if the error code == NO_ERROR;
// dwErrorCode - error code
// OUTPUT : NONE
// RETURNS : pointer to a VOID object
// CAUTIONS :
////////////////////////////////////////////////////////////////////////////////////////////
LPVOID NETTSCClusterFindCmplt(LPDM3CLUSTER lpCluster,
QCompDesc qcdAddr,
DWORD dwErrorCode)
{
QCompAttr CompAttrs[2];
LPVOID lpvRet = NULL;
DM3STATUS dm3Status;
if(dwErrorCode == NO_ERROR) {
// save cluster address
lpCluster->qcdClusterAddr = qcdAddr;
lpCluster->State = DM3CLUSTER_ALLOCATED;
/*
* find ctbus component in the cluster
*/
lpCluster->fFindingCTBusComp = TRUE;
lpCluster->fFindingComp = TRUE;
lpCluster->fCTBusCompFound = FALSE;
// prepare the component attributes for Dm3ClusterGetComp
CompAttrs[0].key = Std_ComponentType;
CompAttrs[0].value = QSCRES_Std_Component_Type;
CompAttrs[1].key = QATTR_NULL;
dm3Status = Dm3ClusterGetComp(lpCluster, CompAttrs,(UCHAR) 1);
if(dm3Status != DM3SUCCESS) {
// problem in getting component - ignore getting ctbus comp
lpCluster->fFindingCTBusComp = FALSE;
lpCluster->fFindingComp = FALSE;
}
}
return lpvRet;
}
//////////////////////////////////////////////////////////////////////////////////////////
// NAME : ClusterDeactivateCmplt
// DESCRIPTION : The internal method called when the given lpCluster object
// dactivation of the CTBus oputput port completes.
// This method is initiated by the Dm3ClusterListen() method.
// INPUT : lpCluster - pointer to a DM3CLUSTER object
// dwErrorCode - error code
// OUTPUT : NONE
// RETURNS : pointer to a VOID object
// CAUTIONS :
///////////////////////////////////////////////////////////////////////////////////////////
LPVOID NetTSCClusterDeactivateCmplt(LPDM3CLUSTER lpCluster,DWORD dwErrorCode)
{
if(dwErrorCode == NO_ERROR) {
// Deactivate the ctbus output port
Dm3ClusterUnAssign(lpCluster);
}
return (NULL);
}
////////////////////////////////////////////////////////////////////////////////////////
// NAME : DecodeClusterMsgReply
// DESCRIPTION : Method that handles all the reply messages for this lpCluster
// INPUT : lpReplyMsg - pointer to the reply message.
// ulReplyType - reply type
// pfComplete - pointer to complete flag
// pErrorCode - poiner to error code, in case of error
// pTimeSlot - pointer to time slot number
// pqcdAddr - pointer to componenmt descriptor
// OUTPUT : NONE
// RETURNS : LPVOID - pointer to a VOID object (manipulated by the user of Dm3Cluster).
// CAUTIONS : NONE
//////////////////////////////////////////////////////////////////////////////////////////
LPVOID DecodeClusterMsgReply(QMsgRef lpReplyMsg,
ULONG ulReplyType,
BOOL *pfComplete,
DWORD *pErrorCode,
USHORT *pTimeSlot,
QCompDesc *pqcdAddr)
{
LPVOID lpRet = NULL;
UINT unOffset = 0;
switch(ulReplyType) {
case QResultError:
{
//get error code
QResultError_t ResultError;
QResultError_get(lpReplyMsg, &ResultError, unOffset);
*pErrorCode = ResultError.errorCode;
*pfComplete = FALSE;
}
break;
case QResultComplete:
{
//set cmd complete as succesful
*pErrorCode = 0;
*pfComplete = TRUE;
}
break;
case QClusterResult:
{
// get address
QClusterResult_t ClusterResult;
QClusterResult_get(lpReplyMsg, &ClusterResult, unOffset);
*pqcdAddr = ClusterResult.desc;
*pErrorCode = NO_ERROR;
*pfComplete = TRUE;
}
break;
case QComponentResult:
{
QComponentResult_t ComponentResult;
QComponentResult_get(lpReplyMsg, &ComponentResult, unOffset);
*pqcdAddr = ComponentResult.theInstance;
*pErrorCode = NO_ERROR;
*pfComplete = TRUE;
}
break;
case QClusterSlotInfoResult:
{
/*
* get the timeslot
*/
QClusterSlotInfoResult_t SlotInfoResult;
QClusterSlotInfoResult_get(lpReplyMsg,
&SlotInfoResult,
unOffset);
// only one timeslot assigned to the port
unOffset = QClusterSlotInfoResult_varStart;
// so we retrieve only the first assigned timeslot
qMsgVarFieldGet(lpReplyMsg,
1,
&unOffset,
QClusterSlotInfoResult_slotId,
pTimeSlot);
/*
* set as cmd completed
*/
*pfComplete = TRUE;
*pErrorCode = NO_ERROR;
}
break;
default:
*pErrorCode = GetLastError();
break;
}
return lpRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -