Actions

Difference between revisions of "AlphaCom SDK Stentofon.AlphaCom.Example.CallRequests.exe"

From Zenitel Wiki

 
Line 1: Line 1:
#REDIRECT [[AlphaCom SDK Stentofon.AlphaCom.Example.Stations.exe]]
+
== AlphaCom SDK Stentofon.AlphaCom - Call Reqeuest Handling ==
 +
 
 +
 
 +
=== About the application ===
 +
 
 +
[[Image:AlphaComSDK_ExampleAppConfig.JPG|thumb|200px]]
 +
[[Image:AlphaComSDK_ExampleApp2.JPG|thumb|300px]]
 +
 
 +
==== Config ====
 +
 
 +
The application is a Windows Forms project with two Forms, the Main Window and Config window for inserting the IP address of the AlphaCom.
 +
The application config file is the default config file for the [[Stentofon.AlphaCom.AlphaNet.dll]] named '''Stentofon.AlphaCom.AlphaNet.xml''' defined in the namespace
 +
'''Stentofon.AlphaCom.AlphaNet.Config'''.
 +
 
 +
If no config file at startup the application will open the config window. The config window can also be opened by clicking the 'Config' button in the Main Window.
 +
 
 +
==== Application Initialisation ====
 +
 
 +
The '''AlphaNetClient''' object is initialized with the '''AlphaNetClientConfig''' object containing the IP address etc. The '''AutoDiscoverAllNodes''' and '''AutoGetStationState ''' properties is also set to get all StationState objects:
 +
 
 +
<code>_client = new AlphaNetClient(_formConfig.ClientConfig) { AutoDiscoverAllNodes = true, AutoGetStationState = true };</code>
 +
 
 +
All The StationState objects will be stored in InMemory structure using the [[Stentofon.AlphaCom.Data.dll]]:
 +
 
 +
<code>_stateStorage = new AlphaComState(AlphaComStateStorages.IN_MEMORY);</code>
 +
 
 +
Handlers For TCP Up/Down, Node Connection Up/down, StationState, StationBusy/StationFree, StationConnect/StationDisconnect is registered:
 +
 
 +
<code>
 +
_client.OnTCPConnectionUp += HandleTCPUp;<br/>
 +
_client.OnTCPConnectionDown += HandleTCPDown;<br/>
 +
_client.OnNodeConnectionUp += HandleNodeUp;<br/>
 +
_client.OnNodeConnectionDown += HandleNodeDown;<br/>
 +
_client.OnStationStateReceived += HandleStationState;<br/>
 +
_client.OnStationBusyReceived += HandleStationBusy;<br/>
 +
_client.OnStationFreeReceived += HandleStationFree;<br/>
 +
_client.OnStationConnect += HandleStationConnect;<br/>
 +
_client.OnStationDisconnect += HandleStationDisconnect;<br/>
 +
</code>
 +
 
 +
Do the connection:
 +
 
 +
<code>
 +
try{<br/>             
 +
_client.StartListening();<br/>         
 +
_client.StartMonitorThread();<br/>       
 +
}<br/>
 +
catch (Exception ex){<br/>
 +
connected = false;<br/>
 +
}
 +
</code>
 +
 
 +
==== Storing Station State info ====
 +
 
 +
Adding or updating on a StationState messages:
 +
 
 +
<code>
 +
if (_stateStorage.UpdateStation(st) > 0)      // If added<br/>
 +
_registeredStationCounter++;
 +
</code>
 +
 
 +
Update the station busy flag in the state storage on StationFree Message received:
 +
 
 +
<code>
 +
var station = _stateStorage.GetStationState(sf.Station);<br/>
 +
if (station != null)<br/>
 +
station.SetBusyState(false);    // Update the state storage object <br/>
 +
</code>
 +
 
 +
==== Retriving StationState objects ====
 +
 
 +
Get a list of StationStates objects matching the Display Text or Directory number (if string is numeric):
 +
 
 +
<code>
 +
var stList = GetStationList(textBoxStationSearch.Text);
 +
</code>
 +
 
 +
==== Sending Station Commands ====
 +
 
 +
Set IPStationOutput on a selected Station:
 +
 
 +
<code>
 +
_selectedStation.MakeCommandSetIpStationOutput(outNo, outState);<br/>
 +
var cmdSent = _client.SendAlphaCommand(_selectedStation);<br/>
 +
</code>
 +
 
 +
Send a DialDigits command:
 +
 
 +
<code>
 +
_selectedStation.MakeCommandDialDigits("1000");<br/>
 +
var cmdSent = _client.SendAlphaCommand(_selectedStation);<br/>
 +
</code>
 +
 
 +
Simulate C-Key:
 +
 
 +
<code>
 +
_selectedStation.MakeCommandCKey();<br/>
 +
var cmdSent = _client.SendAlphaCommand(_selectedStation);<br/>
 +
</code>
 +
 
 +
Simulate M-Key Press:
 +
 
 +
<code>
 +
_selectedStation.MakeCommandMKey(KeyPressState.Press);<br/>
 +
var cmdSent = _client.SendAlphaCommand(_selectedStation);<br/>
 +
</code>
 +
 
 +
Simulate M-Key Release:
 +
 
 +
<code>
 +
_selectedStation.MakeCommandMKey(KeyPressState.Release);<br/>
 +
var cmdSent = _client.SendAlphaCommand(_selectedStation);<br/>
 +
</code>

Revision as of 06:48, 19 June 2009

AlphaCom SDK Stentofon.AlphaCom - Call Reqeuest Handling

About the application

AlphaComSDK ExampleAppConfig.JPG
AlphaComSDK ExampleApp2.JPG

Config

The application is a Windows Forms project with two Forms, the Main Window and Config window for inserting the IP address of the AlphaCom. The application config file is the default config file for the Stentofon.AlphaCom.AlphaNet.dll named Stentofon.AlphaCom.AlphaNet.xml defined in the namespace Stentofon.AlphaCom.AlphaNet.Config.

If no config file at startup the application will open the config window. The config window can also be opened by clicking the 'Config' button in the Main Window.

Application Initialisation

The AlphaNetClient object is initialized with the AlphaNetClientConfig object containing the IP address etc. The AutoDiscoverAllNodes and AutoGetStationState properties is also set to get all StationState objects:

_client = new AlphaNetClient(_formConfig.ClientConfig) { AutoDiscoverAllNodes = true, AutoGetStationState = true };

All The StationState objects will be stored in InMemory structure using the Stentofon.AlphaCom.Data.dll:

_stateStorage = new AlphaComState(AlphaComStateStorages.IN_MEMORY);

Handlers For TCP Up/Down, Node Connection Up/down, StationState, StationBusy/StationFree, StationConnect/StationDisconnect is registered:

_client.OnTCPConnectionUp += HandleTCPUp;
_client.OnTCPConnectionDown += HandleTCPDown;
_client.OnNodeConnectionUp += HandleNodeUp;
_client.OnNodeConnectionDown += HandleNodeDown;
_client.OnStationStateReceived += HandleStationState;
_client.OnStationBusyReceived += HandleStationBusy;
_client.OnStationFreeReceived += HandleStationFree;
_client.OnStationConnect += HandleStationConnect;
_client.OnStationDisconnect += HandleStationDisconnect;

Do the connection:

try{
_client.StartListening();
_client.StartMonitorThread();
}
catch (Exception ex){
connected = false;
}

Storing Station State info

Adding or updating on a StationState messages:

if (_stateStorage.UpdateStation(st) > 0) // If added
_registeredStationCounter++;

Update the station busy flag in the state storage on StationFree Message received:

var station = _stateStorage.GetStationState(sf.Station);
if (station != null)
station.SetBusyState(false); // Update the state storage object

Retriving StationState objects

Get a list of StationStates objects matching the Display Text or Directory number (if string is numeric):

var stList = GetStationList(textBoxStationSearch.Text);

Sending Station Commands

Set IPStationOutput on a selected Station:

_selectedStation.MakeCommandSetIpStationOutput(outNo, outState);
var cmdSent = _client.SendAlphaCommand(_selectedStation);

Send a DialDigits command:

_selectedStation.MakeCommandDialDigits("1000");
var cmdSent = _client.SendAlphaCommand(_selectedStation);

Simulate C-Key:

_selectedStation.MakeCommandCKey();
var cmdSent = _client.SendAlphaCommand(_selectedStation);

Simulate M-Key Press:

_selectedStation.MakeCommandMKey(KeyPressState.Press);
var cmdSent = _client.SendAlphaCommand(_selectedStation);

Simulate M-Key Release:

_selectedStation.MakeCommandMKey(KeyPressState.Release);
var cmdSent = _client.SendAlphaCommand(_selectedStation);