📄 xms_confdemo_sub.cpp
字号:
}
void DrawPcm_TypeAndAlarm ( PCM_STRUCT *pOnePcm )
{
char StateStr[100];
int iDispRow;
int AlarmVal;
iDispRow = pOnePcm->iSeqID;
AlarmVal = pOnePcm->s32AlarmVal;
// E1 Type
sprintf ( StateStr, "%s", GetString_PcmType (pOnePcm->u8E1Type) );
pdlg->m_ListPcm.SetItemText ( iDispRow, 1, StateStr );
// Alarm
sprintf ( StateStr, "0x%X", AlarmVal );
pdlg->m_ListPcm.SetItemText ( iDispRow, 2, StateStr );
if ( AlarmVal & XMS_E1PORT_MASK_LOST_SIGNAL )
pdlg->m_ListPcm.SetItemText ( iDispRow, 3, " X" );
else
pdlg->m_ListPcm.SetItemText ( iDispRow, 3, "O" );
if ( AlarmVal & XMS_E1PORT_MASK_FAS_ALARM )
pdlg->m_ListPcm.SetItemText ( iDispRow, 4, " X" );
else
pdlg->m_ListPcm.SetItemText ( iDispRow, 4, "O" );
if ( AlarmVal & XMS_E1PORT_MASK_REMOTE_ALARM )
pdlg->m_ListPcm.SetItemText ( iDispRow, 5, " X" );
else
pdlg->m_ListPcm.SetItemText ( iDispRow, 5, "O" );
}
// -------------------------------------------------------------------------------------------------
void InitListConf(void)
{
LV_COLUMN lvc;
DWORD dwExStyle;
dwExStyle = LVS_EX_FULLROWSELECT | /*LVS_EX_GRIDLINES | LVS_EX_SUBITEMIMAGES |*/
LVS_EX_HEADERDRAGDROP;// | LVS_EX_TRACKSELECT;
pdlg->m_ListConf.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));
lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = "ConfGroup" ;
lvc.cx = 70;
pdlg->m_ListConf.InsertColumn ( 0, &lvc );
lvc.iSubItem = 1;
lvc.pszText = "Mod,Ch" ;
lvc.cx = 60;
pdlg->m_ListConf.InsertColumn ( 1, &lvc );
lvc.iSubItem = 2;
lvc.pszText = "State" ;
lvc.cx = 70;
pdlg->m_ListConf.InsertColumn ( 2, &lvc );
lvc.iSubItem = 3;
lvc.pszText = "Member" ;
lvc.cx = 50;
pdlg->m_ListConf.InsertColumn ( 3, &lvc );
lvc.iSubItem = 4;
lvc.pszText = "Detail Infomation" ;
lvc.cx = 250;
pdlg->m_ListConf.InsertColumn ( 4, &lvc );
}
void DrawConf_State( CONF_STRUCT *pOneConf )
{
char StateStr[100];
int iDispRow;
iDispRow = pOneConf->iSeqID;
//
switch( pOneConf->State )
{
case CONF_WAITOPEN:
strcpy(StateStr,"Wait Open");
break;
case CONF_FREE:
strcpy(StateStr,"空闲");
break ;
case CONF_USED:
strcpy(StateStr,"*占用*");
break;
case CONF_WAIT_REMOVE:
strcpy(StateStr,"DSP删除");
break;
default:
strcpy(StateStr,"other");
break;
}
pdlg->m_ListConf.SetItemText ( iDispRow, 2, StateStr );
}
char * GetString_ConfModeStr ( int iConfMode )
{
switch ( iConfMode )
{
case CONF_MODE_NONE:
return " ";
break;
case CONF_MODE_ADD:
return "A";
break;
case CONF_MODE_LISTEN:
return "L";
break;
case CONF_MODE_SPEAKONLY:
return "S";
break;
case CONF_MODE_PLAY:
return "P";
break;
}
return "";
}
void DrawConf_DetailInfo ( CONF_STRUCT *pOneConf )
{
char StateStr[256];
char TmpS[100];
int iDispRow, i;
iDispRow = pOneConf->iSeqID;
sprintf ( StateStr, "%d", pOneConf->lMemberNum );
pdlg->m_ListConf.SetItemText ( iDispRow, 3, StateStr );
strcpy ( StateStr, "" );
strcpy ( TmpS, "" );
for ( i = 0; i < pOneConf->lMemberNum; i ++ )
{
sprintf ( TmpS, "(%s,%d,%d)",
GetString_ConfModeStr(pOneConf->Member[i].lMode),
pOneConf->Member[i].DevID.m_s8ModuleID, pOneConf->Member[i].DevID.m_s16ChannelID );
strcat ( StateStr, TmpS );
}
pdlg->m_ListConf.SetItemText ( iDispRow, 4, StateStr );
}
// -------------------------------------------------------------------------------------------------
void InitListCount(void)
{
LV_COLUMN lvc;
DWORD dwExStyle;
dwExStyle = LVS_EX_FULLROWSELECT | /*LVS_EX_GRIDLINES | LVS_EX_SUBITEMIMAGES |*/
LVS_EX_HEADERDRAGDROP;// | LVS_EX_TRACKSELECT;
pdlg->m_ListCount.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));
lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = "ID" ;
lvc.cx = 40;
pdlg->m_ListCount.InsertColumn ( 0, &lvc );
lvc.iSubItem = 1;
lvc.pszText = "ModID" ;
lvc.cx = 45;
pdlg->m_ListCount.InsertColumn ( 1, &lvc );
lvc.iSubItem = 2;
lvc.pszText = "Pcm/Open" ;
lvc.cx = 70;
pdlg->m_ListCount.InsertColumn ( 2, &lvc );
lvc.iSubItem = 3;
lvc.pszText = "Trk/Open" ;
lvc.cx = 70;
pdlg->m_ListCount.InsertColumn ( 3, &lvc );
lvc.iSubItem = 4;
lvc.pszText = "Voc/Open" ;
lvc.cx = 70;
pdlg->m_ListCount.InsertColumn ( 4, &lvc );
lvc.iSubItem = 5;
lvc.pszText = "VocFree" ;
lvc.cx = 55;
pdlg->m_ListCount.InsertColumn ( 5, &lvc );
lvc.iSubItem = 6;
lvc.pszText = "Conf/Open" ;
lvc.cx = 70;
pdlg->m_ListCount.InsertColumn ( 6, &lvc );
lvc.iSubItem = 7;
lvc.pszText = "ConfFree" ;
lvc.cx = 60;
pdlg->m_ListCount.InsertColumn ( 7, &lvc );
lvc.iSubItem = 8;
lvc.pszText = "ErrFlag" ;
lvc.cx = 60;
pdlg->m_ListCount.InsertColumn ( 8, &lvc );
lvc.iSubItem = 9;
lvc.pszText = "RemoveState" ;
lvc.cx = 80;
pdlg->m_ListCount.InsertColumn ( 9, &lvc );
}
void DrawCount_Pcm ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
sprintf ( TmpStr, "%3d /%3d", AllDeviceRes[s8ModID].lPcmNum, AllDeviceRes[s8ModID].lPcmOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 2, TmpStr );
// total
iDispRow = 0;
sprintf ( TmpStr, "%3d /%3d", g_iTotalPcm, g_iTotalPcmOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 2, TmpStr );
}
void DrawCount_Trunk ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
sprintf ( TmpStr, "%3d/%3d", AllDeviceRes[s8ModID].lTrunkNum, AllDeviceRes[s8ModID].lTrunkOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 3, TmpStr );
// total
iDispRow = 0;
sprintf ( TmpStr, "%3d/%3d", g_iTotalTrunk, g_iTotalTrunkOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 3, TmpStr );
}
void DrawCount_Voc ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
sprintf ( TmpStr, "%3d/%3d", AllDeviceRes[s8ModID].lVocNum, AllDeviceRes[s8ModID].lVocOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 4, TmpStr );
sprintf ( TmpStr, "%3d", AllDeviceRes[s8ModID].lVocFreeNum );
pdlg->m_ListCount.SetItemText ( iDispRow, 5, TmpStr );
// total
iDispRow = 0;
sprintf ( TmpStr, "%3d/%3d", g_iTotalVoice, g_iTotalVoiceOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 4, TmpStr );
sprintf ( TmpStr, "%3d", g_iTotalVoiceFree );
pdlg->m_ListCount.SetItemText ( iDispRow, 5, TmpStr );
}
void DrawCount_Conf ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
sprintf ( TmpStr, "%3d/%3d", AllDeviceRes[s8ModID].lConfNum, AllDeviceRes[s8ModID].lConfOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 6, TmpStr );
sprintf ( TmpStr, "%3d",AllDeviceRes[s8ModID].lConfFreeNum );
pdlg->m_ListCount.SetItemText ( iDispRow, 7, TmpStr );
// total
iDispRow = 0;
sprintf ( TmpStr, "%3d/%3d", g_iTotalConf, g_iTotalConfOpened );
pdlg->m_ListCount.SetItemText ( iDispRow, 6, TmpStr );
sprintf ( TmpStr, "%3d", g_iTotalConfFree );
pdlg->m_ListCount.SetItemText ( iDispRow, 7, TmpStr );
}
void DrawCount_ErrFlag ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
if ( AllDeviceRes[s8ModID].bErrFlag )
sprintf ( TmpStr, "T" );
else
sprintf ( TmpStr, "" );
pdlg->m_ListCount.SetItemText ( iDispRow, 8, TmpStr );
}
void DrawCount_RemoveState ( DJ_S8 s8ModID )
{
char TmpStr[256];
int iDispRow;
iDispRow = AllDeviceRes[s8ModID].iSeqID + 1;
switch ( AllDeviceRes[s8ModID].RemoveState )
{
case DSP_REMOVE_STATE_NONE:
sprintf ( TmpStr, "" );
break;
case DSP_REMOVE_STATE_START:
sprintf ( TmpStr, "Start" );
break;
case DSP_REMOVE_STATE_READY:
sprintf ( TmpStr, "Ready" );
break;
}
pdlg->m_ListCount.SetItemText ( iDispRow, 9, TmpStr );
}
// -------------------------------------------------------------------------------------------------
void ReDrawAll (void)
{
char TmpStr[256];
int i, iDispRow;
TRUNK_STRUCT *pOneTrunk;
CONF_STRUCT *pOneConf;
// m_ListMain
pdlg->m_ListMain.DeleteAllItems ();
for ( i = 0; i < g_iTotalTrunk; i ++ )
{
iDispRow = CalDispRow ( i );
if ( iDispRow < 0 ) continue;
// 固定不变的内容
sprintf ( TmpStr, "%3d", iDispRow );
pdlg->m_ListMain.InsertItem ( iDispRow, TmpStr );
sprintf ( TmpStr, "%d,%d", MapTable_Trunk[i].m_s8ModuleID, MapTable_Trunk[i].m_s16ChannelID );
pdlg->m_ListMain.SetItemText ( iDispRow, 1, TmpStr );
pOneTrunk = &M_OneTrunk(MapTable_Trunk[i]);
pdlg->m_ListMain.SetItemText ( iDispRow, 2, GetString_DeviceSub( pOneTrunk->deviceID.m_s16DeviceSub) );
// 可能改变的内容
DrawMain_LineState ( pOneTrunk );
DrawMain_State ( pOneTrunk );
DrawMain_CallInfo ( pOneTrunk );
DrawMain_DTMF ( pOneTrunk );
}
// m_ListPcm
pdlg->m_ListPcm.DeleteAllItems ();
for ( i = 0; i < g_iTotalPcm; i ++ )
{
sprintf ( TmpStr, "%3d", i );
pdlg->m_ListPcm.InsertItem ( i, TmpStr );
// 可能改变的内容
DrawPcm_TypeAndAlarm ( &M_OnePcm(MapTable_Pcm[i]) );
}
// m_ListConf
pdlg->m_ListConf.DeleteAllItems ();
for ( i = 0; i < g_iTotalConf; i ++ )
{
// 固定不变的内容
sprintf ( TmpStr, "%03d", i );
pdlg->m_ListConf.InsertItem ( i, TmpStr );
sprintf ( TmpStr, "%d,%d", MapTable_Conf[i].m_s8ModuleID, MapTable_Conf[i].m_s16ChannelID );
pdlg->m_ListConf.SetItemText ( i, 1, TmpStr );
pOneConf = &M_OneConf(MapTable_Conf[i]);
// 可能改变的内容
DrawConf_State ( pOneConf );
}
// m_ListCount
pdlg->m_ListCount.DeleteAllItems ();
// 先添加行
pdlg->m_ListCount.InsertItem ( 0, "Total" );
for ( i = 0; i < g_iTotalModule; i ++ )
{
sprintf ( TmpStr, "%3d", i );
pdlg->m_ListCount.InsertItem ( i+1, TmpStr );
sprintf ( TmpStr, "%3d", MapTable_Module[i] );
pdlg->m_ListCount.SetItemText ( i+1, 1, TmpStr );
}
// 再显示内容
for ( i = 0; i < g_iTotalModule; i ++ )
{
DrawCount_Pcm ( MapTable_Module[i] );
DrawCount_Trunk ( MapTable_Module[i] );
DrawCount_Voc ( MapTable_Module[i] );
DrawCount_Conf ( MapTable_Module[i] );
DrawCount_ErrFlag ( MapTable_Module[i] );
DrawCount_RemoveState ( MapTable_Module[i] );
}
}
// -----------------------------------------------------------------------
// next functions are about Init & Exit
// -----------------------------------------------------------------------
bool InitSystem()
{
RetCode_t r;
char MsgStr[160];
pdlg = (CXMS_ConfDemoDlg *)theApp.m_pMainWnd;
// Read From "XMS_ConfDemo.INI"
ReadFromConfig();
// Special code for CAS(SS1)
// Read From "C:\\DJKeygoe\\Samples\\CAS_Common_Code\\SaXMS_CAS_Cfg.INI"
if ( CAS_Common_Cfg_ReadCfg ( &g_Param_CAS ) != 0 )
{
sprintf ( MsgStr, "CAS_Common_Cfg_ReadCfg \"C:\\DJKeygoe\\Samples\\CAS_Common_Code\\XMS_CAS_Cfg.INI\" Error!" );
MessageBox(NULL, MsgStr, "Init System", MB_OK ) ;
}
// end of code for CAS(SS1)
// Init m_ListMain
InitListMain();
// Init m_ListPcm
InitListPcm();
// Init m_ListMsg
InitListMsg();
// Init m_ListConf
InitListConf();
// Init m_ListCount
InitListCount();
// Init Conifg's text box
InitTextBox();
// now open ACS Server
/*调用acsOpenStream 建立与ACS服务器的连接*/
r = XMS_acsOpenStream ( &g_acsHandle,
&cfg_ServerID,
g_u8UnitID, // App Unit ID
32, // sendQSize, in K Bytes
32, // recvQSize, in K Bytes
cfg_s32DebugOn, // Debug On/Off
NULL);
if ( r < 0 )
{
sprintf ( MsgStr, "XMS_acsOpenStream(IP Addr : %s, port : %d) FAIL. ret = %d",
cfg_ServerID.m_s8ServerIp, cfg_ServerID.m_u32ServerPort, r );
MessageBox(NULL, MsgStr, "Init System", MB_OK ) ;
AddMsg ( MsgStr );
return false;
}
else
{
sprintf ( MsgStr, "XMS_acsOpenStream(%s,%d) OK!", cfg_ServerID.m_s8ServerIp, cfg_ServerID.m_u32ServerPort );
AddMsg ( MsgStr );
}
r = XMS_acsSetESR ( g_acsHandle, (EsrFunc)EvtHandler, 0, 1 );
if ( r < 0 )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -