📄 form1.cs
字号:
this.radioButton1.Size = new System.Drawing.Size(72, 16);
this.radioButton1.TabIndex = 3;
this.radioButton1.Text = "Default";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(286, 392);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(72, 16);
this.radioButton2.TabIndex = 4;
this.radioButton2.Text = "A-law";
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(372, 392);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(72, 16);
this.radioButton3.TabIndex = 5;
this.radioButton3.Text = "u-law";
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton4
//
this.radioButton4.Location = new System.Drawing.Point(458, 392);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(78, 16);
this.radioButton4.TabIndex = 6;
this.radioButton4.Text = "IMA-ADPCM";
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//
// radioButton5
//
this.radioButton5.Location = new System.Drawing.Point(544, 392);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(72, 16);
this.radioButton5.TabIndex = 7;
this.radioButton5.Text = "GC8";
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
//
// radioButton6
//
this.radioButton6.Location = new System.Drawing.Point(630, 392);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(72, 16);
this.radioButton6.TabIndex = 8;
this.radioButton6.Text = "G729A";
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Location = new System.Drawing.Point(192, 424);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(72, 20);
this.comboBox1.TabIndex = 9;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(312, 424);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(112, 24);
this.button1.TabIndex = 10;
this.button1.Text = "StartListen";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(456, 424);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(112, 24);
this.button2.TabIndex = 11;
this.button2.Text = "StopListen";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(776, 470);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.radioButton6);
this.Controls.Add(this.radioButton5);
this.Controls.Add(this.radioButton4);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.listView1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "SHR_DEvent";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void label1_Click(object sender, System.EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
public void InitChannelState()
{
int nGetChType;
int nChState;
for(int i=0; i<MaxLine; i++)
{
nGetChType = SsmGetChType(i); //Get channel type
if(nGetChType == -1)
{
WriteLog(SsmGetLastErrMsgA());
}
if(nGetChType == 12) //Digital telephone record channel
{
ChannelState[i].WorkState = (int)CH_STATE.CH_IDLE; //Off line state
ChannelState[i].IsListen = (int)CH_LISTEN.UNLISTEN; //UNLISTEN
ChannelState[i].IsRecord = (int)CH_RECORD.UNRECORD; //Unrecord
ChannelState[i].pCallId = new char[MAX_CALLID_LEN]; //Phone number is null
ChannelState[i].Lcd = new char[MAX_LCD_LEN]; //LCD info is null
ChannelState[i].Dir = (int)DIRECTION.UNKNOWN ; //Call direction is "UNKNOWN"
this.comboBox1.Items.Add(i.ToString());
}
else
{
ChannelState[i].WorkState = -1; //Off line state
ChannelState[i].IsListen = -1; //UNLISTEN
ChannelState[i].IsRecord = -1; //Unrecord
ChannelState[i].Dir = -1; //Call direction is "UNKNOWN"
}
nChState = SsmGetChState(i); //Get the state of current channel. -1:error
if(nChState == -1)
{
WriteLog(SsmGetLastErrMsgA());
}
if(nChState == (int)TRUNK_STATUS.S_CALL_OFFLINE) //Off line state
{
ChannelState[i].WorkState = (int)CH_STATE.CH_OFFLINE;
}
}
return;
}
public void UpdateChannelState()
{
int nTemp;
string str = "";
this.listView1.Items.Clear();
for(int i = 0; i < MaxLine; i++)
{
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
nTemp = SsmGetChType(i);
if(nTemp == -1)
MessageBox.Show("Fail to call SsmGetChType");
else if(nTemp == 12)
{
lvi = new ListViewItem();
lvi.Text = i.ToString();
switch(ChannelState[i].WorkState)
{
case (int)CH_STATE.CH_IDLE:
str = "Idle";
break;
case (int)CH_STATE.CH_RING:
str = "Ringing";
break;
case (int)CH_STATE.CH_ACTIVE:
str = "Active";
break;
case (int)CH_STATE.CH_OFFLINE:
str = "Offline";
break;
case (int)CH_STATE.CH_WAITFOR_ONHOOK:
str = "WaitforOnhook";
break;
}
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
str = "";
switch(ChannelState[i].IsListen)
{
case (int)CH_LISTEN.LISTEN:
str = "Listen";
break;
case (int)CH_LISTEN.UNLISTEN:
str = "UNLISTEN";
break;
}
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
str = "";
switch(ChannelState[i].IsRecord)
{
case (int)CH_RECORD.UNRECORD:
str = "Unrecord";
break;
case (int)CH_RECORD.RECORD:
str = "Record";
break;
}
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
lvsi = new ListViewItem.ListViewSubItem();
str = "";
str = new string(ChannelState[i].pCallId);
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
lvsi = new ListViewItem.ListViewSubItem();
str = "";
str = new string(ChannelState[i].Lcd);
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
str = "";
switch(ChannelState[i].Dir)
{
case (int)DIRECTION.UNKNOWN:
str = "Unknown";
break;
case (int)DIRECTION.UP:
str = "Call out";
break;
case (int)DIRECTION.DOWN:
str = "Call in";
break;
}
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = str;
lvi.SubItems.Add(lvsi);
this.listView1.Items.Add(lvi);
}
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@ EVENT POLLING PROGRAM MODE BASE ON D CHANNEL EVENT @@@@@@@@@@@@@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsafe void EventHandler(ref SSM_EVENT pEvent)
{
long dwCondition = pEvent.dwParam & 0xffff; //Reason of state transfer;
int ch = pEvent.nReference; //channel number;
int nIndex;
switch(ChannelState[ch].WorkState) //Judge state
{
case (int)CH_STATE.CH_IDLE: //Idle state
{
switch(pEvent.wEventCode) //Judge event
{
case E_CHG_ChState:
{
if ((pEvent.dwParam & 0xffff) == (int)TRUNK_STATUS.S_CALL_OFFLINE) //Judge channel state
{
ChannelState[ch].Dir = (int)DIRECTION.UNKNOWN;
ChannelState[ch].WorkState = (int)CH_STATE.CH_OFFLINE;
ChannelState[ch].Lcd = new char[MAX_LCD_LEN];
ClearCallID(ref pEvent); //Clear phone number buffer
}
}
break;
case E_RCV_DSTDChannel:
{
switch(pEvent.dwParam) //Judge D-Channel event
{
case DST_OFFHOOK:
{
ChannelState[ch].Dir = (int)DIRECTION.UP;
ChannelState[ch].WorkState = (int)CH_STATE.CH_ACTIVE;
ChannelState[ch].Lcd = new char[MAX_LCD_LEN];
ClearCallID(ref pEvent); //Clear phone number buffer
StartRecord(ch); //Start record
}
break;
case DST_RING_ON:
{
ChannelState[ch].Dir = (int)DIRECTION.DOWN;
ChannelState[ch].WorkState = (int)CH_STATE.CH_RING;
ClearCallID(ref pEvent); //Clear phone number buffer
ChannelState[ch].Lcd = new char[MAX_LCD_LEN];
}
break;
case DST_MSG_CHG:
{
for(nIndex = 0; nIndex < pEvent.dwDataLength; nIndex++)
{
ChannelState[ch].Lcd[nIndex] = (char)pEvent.pvBuffer[nIndex];
}
ChannelState[ch].LCDLen = pEvent.dwDataLength;
}
break;
default:
break;
}
}
break;
default:
break;
}
}
break;
case (int)CH_STATE.CH_RING:
{
switch(pEvent.wEventCode)
{
case E_CHG_ChState:
{
if ((pEvent.dwParam & 0xffff) == (int)TRUNK_STATUS.S_CALL_OFFLINE) //Judge channel state
{
ChannelState[ch].Dir = (int)DIRECTION.UNKNOWN;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -