📄 ntscclsh.c
字号:
///////////////////////////////////////////////////////////////////////
// File Name: NTSCCLSTH.C
//
// This file contains functions, for allocating, finding allocated
// component instances, and freeing NTSC cluster.
///////////////////////////////////////////////////////////////////////
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
// TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) 1997 Dialogic Corporation. All Rights Reserved.
///////////////////////////////////////////////////////////////////////
#include "NtscClst.h"
#include "NTSCClsH.h"
#include "Main.h"
#include <Dm3clust.h>
#include <Qkernerr.h>
////////////////////////////////////////////////////////////////////////////////////////
// NAME : NETTSCClusterEvtHndlr
// DESCRIPTION : Method that handles all the reply messages for this lpCluster
// INPUT : lpComp - pointer to the Dm3Comp object associated with the Dm3Cluster
// object
// ulCmdType - type of the message that initiated this reply message
// ulReplyType - type of the reply message
// lpReplyMsg - pointer to the reply message.
// OUTPUT : NONE
// RETURNS : LPVOID - pointer to a VOID object (manipulated by the user of Dm3Cluster).
// CAUTIONS : NONE
//////////////////////////////////////////////////////////////////////////////////////////
LPVOID NETTSCClusterEvtHndlr(LPDM3COMP lpComp,
ULONG ulCmdType,
ULONG ulReplyType,
QMsgRef lpReplyMsg)
{
LPDM3CLUSTER lpCluster;
LPNETTSCCLUSTER lpNETTSCCluster;
LPVOID lpvRet = NULL;
BOOL fComplete;
DWORD dwErrorCode;
QCompDesc qcdAddr;
USHORT usTimeSlot;
UINT unOffset=0;
/*
* Obtain pointer to this Cluster instance data structure
* This was initialized in Dm3ClusterInit()
*/
lpCluster = (LPDM3CLUSTER) lpComp->lpUserInfo;
lpNETTSCCluster = (LPNETTSCCLUSTER)lpCluster->lpUserInfo;
DecodeClusterMsgReply(lpReplyMsg,
ulReplyType,
&fComplete,
&dwErrorCode,
&usTimeSlot,
&qcdAddr);
switch(ulCmdType) {
case QClusterAllocate:
lpvRet = NETTSCClusterAllocateCmplt(lpCluster,
qcdAddr,
dwErrorCode);
break;
case QClusterFind:
lpvRet = NETTSCClusterFindCmplt(lpCluster,
qcdAddr,
dwErrorCode);
break;
case QClusterCompByAttr:
lpvRet = NETTSCClusterCompByAttrCmplt(lpCluster,
qcdAddr,
dwErrorCode);
break;
case QClusterSlotAssign:
lpvRet = NETTSCClusterSlotAssignCmplt(lpCluster,
dwErrorCode);
break;
case QClusterDeactivate:
lpvRet = NetTSCClusterDeactivateCmplt(lpCluster,
dwErrorCode);
break;
case QClusterSlotInfo:
lpvRet = OnNETTSCClusterGetXmitTimeSlotCmplt(lpCluster,
usTimeSlot,
dwErrorCode);
break;
default:
// ignoring unsolicited messages coming to this cluster
lpvRet = NULL;
break;
}
return lpvRet;
}
//////////////////////////////////////////////////////////////////////////////
// NAME : NETTSCClusterAllocateCmplt
// DESCRIPTION : The internal method called when the given lpCluster object
// allocation completes. * The cluster allocation is initiated
// by the Dm3ClusterAllocate() method If the allocation complete
// is successful (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 NETTSCClusterAllocateCmplt(LPDM3CLUSTER lpCluster,
QCompDesc qcdAddr,
DWORD dwErrorCode)
{
QCompAttr CompAttrs[2];
LPVOID lpvRet = NULL;
DM3STATUS dm3Status;
NETTSCCLUSTER *lpNETTSCCluster;
lpNETTSCCluster= (NETTSCCLUSTER *)lpCluster->lpUserInfo;
if(dwErrorCode == NO_ERROR) {
// save cluster address
lpCluster->qcdClusterAddr = qcdAddr;
lpCluster->State = DM3CLUSTER_ALLOCATED;
lpCluster->fAlloc = TRUE;
/*
* 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;
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_INITCMPLT;
lpNETTSCCluster->dwErrorCode = GetLastError();
}
}
else {
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_INITCMPLT;
lpNETTSCCluster->dwErrorCode = dwErrorCode;
}
return lpvRet;
}
//////////////////////////////////////////////////////////////////////////////
// NAME : NETTSCClusterCompByAttrCmplt(lpCluster,qcdAddr, dwErrorCode)
//
// DESCRIPTION : The internal method called when the component
// instances for the given lpCluster object were found.
// 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 NETTSCClusterCompByAttrCmplt(LPDM3CLUSTER lpCluster,
QCompDesc qcdAddr,
DWORD dwErrorCode)
{
LPVOID lpvRet = NULL;
NETTSCCLUSTER *lpNETTSCCluster;
lpNETTSCCluster= (NETTSCCLUSTER *)lpCluster->lpUserInfo;
lpCluster->fFindingComp = FALSE;
if(lpCluster->fFindingCTBusComp) {
// cluster's request for finding CTBusComp
lpCluster->fFindingCTBusComp = FALSE;
//the component is a CTBus component
if(dwErrorCode == NO_ERROR) {
lpCluster->qcdCTBusCompAddr = qcdAddr;
lpCluster->fCTBusCompFound = TRUE;
lpNETTSCCluster->State = NETTSCCLUSTER_INITCMPLT;
}
else {
if(dwErrorCode == (DWORD) QCLUST_ErrCompNotFound) {
lpCluster->fCTBusCompFound = FALSE;
}
}
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_INITCMPLT;
lpNETTSCCluster->dwErrorCode = dwErrorCode;
}
else {
// cluster user's request
lpvRet = OnNETTSCClusterGetCompCmplt(lpCluster,
qcdAddr,
dwErrorCode);
}
return lpvRet;
}
//////////////////////////////////////////////////////////////////////////////////
// NAME : OnNETTSCClusterGetXmitTimeSlotCmplt(lpCluster, usTimeslot, dwErrorCode)
// DESCRIPTION : This method is called when the GetXmitTimeSlot event completes.
// INPUT : lpCluster - pointer to the DM3CLUSTER object
// usTimeSlot - transmit timeslot assigned to the CTBus comp' port
// in this cluster if the dwErrorcode = NO_ERROR,
// otherwise un defined.
// dwErrorCode - error code associated with this event
// OUTPUT : NONE
// RETURNS : pointer to a VOID object
// CAUTIONS : NONE
////////////////////////////////////////////////////////////////////////////////////
LPVOID OnNETTSCClusterGetXmitTimeSlotCmplt(LPDM3CLUSTER lpCluster,
USHORT usTimeSlot,
DWORD dwErrorCode)
{
LPNETTSCCLUSTER lpNETTSCCluster;
LPVOID lpvRet = NULL;
lpNETTSCCluster = (LPNETTSCCLUSTER) lpCluster->lpUserInfo;
lpNETTSCCluster->unTxTimeSlot = usTimeSlot;
lpNETTSCCluster->dwErrorCode = dwErrorCode;
lpNETTSCCluster->lastEvent = NETTSCCLUSTEREVENT_GETXMITSLOTCMPLT;
return lpvRet;
}
///////////////////////////////////////////////////////////////////////////
// NAME : NETTSCClusterSlotAssignCmplt(lpCluster, dwErrorCode)
// DESCRIPTION : The internal method called when the given lpCluster
// object timeslot assignment to the CTBus input port
// completes.
// This method is initiated by the Dm3ClusterListen() method.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -