SI_COMM has complete built in support for the new .NET development
environment. The following code is from an example program included with SI_COMM.
The program is a simple break out monitor that displays the state of the modem signals RI,
CTS, DCD, and DSR. Shown below is the compiled program running under Windows 2000.
/*************************************************************************
* This source file is provided as a supplement to the SI_COMM ActiveX.
*
* SI_COMM.OCX Copyright (C) 1998-2003 Software Innovations Inc
* All rights reserved.
*
* Software Innovations Inc.
* 72 Prospect Hill Rd.
* Wallkill, NY 12589
*
* tel 845-566-1919
* fax 845-566-1118
* email support@sinnovations.com
* http://www.sinnovations.com
*
************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace BreakOutBox
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private AxSI_COMMLib.AxSI_COMM axSI_COMM1;
private System.Windows.Forms.Label lbl_DCD_State;
private System.Windows.Forms.Label lbl_CTS_State;
private System.Windows.Forms.Label lbl_DSR_State;
private System.Windows.Forms.Label
lbl_RING_State;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container
components = null;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void
Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void
InitializeComponent()
{
// Designer initializiation code removed for clarity...
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//'
****************************************************************
//' These routines will check the state of the specified signal and
//' update the programs display accordingly.
//' ****************************************************************
private void
UpdateCTS()
{
if (this.axSI_COMM1.CTS == true)
{
lbl_CTS_State.Text = "CTS : HIGH";
lbl_CTS_State.ForeColor = System.Drawing.Color.Green;
}
else
{
lbl_CTS_State.Text = "CTS : LOW";
lbl_CTS_State.ForeColor = System.Drawing.Color.Black;
}
}
private void
UpdateDCD()
{
if (this.axSI_COMM1.DCD == true)
{
lbl_DCD_State.Text = "DCD : HIGH";
lbl_DCD_State.ForeColor = System.Drawing.Color.Green;
}
else
{
lbl_DCD_State.Text = "DCD : LOW";
lbl_DCD_State.ForeColor = System.Drawing.Color.Black;
}
}
private void
UpdateRing()
{
if (this.axSI_COMM1.RI == true)
{
lbl_RING_State.Text = "RING : HIGH";
lbl_RING_State.ForeColor = System.Drawing.Color.Green;
}
else
{
lbl_RING_State.Text = "RING : LOW";
lbl_RING_State.ForeColor = System.Drawing.Color.Black;
}
}
private void
UpdateDSR()
{
if (this.axSI_COMM1.DSR == true)
{
lbl_DSR_State.Text = "DSR : HIGH";
lbl_DSR_State.ForeColor = System.Drawing.Color.Green;
}
else
{
lbl_DSR_State.Text = "DSR : LOW";
lbl_DSR_State.ForeColor = System.Drawing.Color.Black;
}
}
private void
Form1_Load(object sender, System.EventArgs e)
{
this.axSI_COMM1.PortNumber = SI_COMMLib.enumPortNumber.COMM01;
this.axSI_COMM1.PortOpen = true;
//' Turn on the delta events for the RS232 signals. This
will cause SI_COMM
//' to fire a CommEvent when one of these signals change state.
this.axSI_COMM1.DeltaCTS = true;
this.axSI_COMM1.DeltaDCD = true;
this.axSI_COMM1.DeltaDSR = true;
this.axSI_COMM1.DeltaRI = true;
//'Read in the current state of the ports pins
this.UpdateCTS();
this.UpdateDCD();
this.UpdateDSR();
this.UpdateRing();
}
//'
****************************************************************
//' CommEvent handler. This event will get fired when one of the
//' RS232 signals change.
//' ****************************************************************
private void
axSI_COMM1_CommEvent(object sender,
AxSI_COMMLib._DSI_COMMEvents_CommEventEvent e)
{
switch
((SI_COMMLib.enumEventCode)e.iEventCode)
{
case
SI_COMMLib.enumEventCode.DeltaCTSEvent:
this.UpdateCTS ();
break;
case
SI_COMMLib.enumEventCode.DeltaDCDEvent:
this.UpdateDCD();
break;
case
SI_COMMLib.enumEventCode.DeltaDSREvent:
this.UpdateDSR();
break;
case SI_COMMLib.enumEventCode.DeltaRIEvent:
this.UpdateRing();
break;
}
}
//'
****************************************************************
//' You should always close the port before leaving the program
//' ****************************************************************
private void
Form1_Closed(object sender, System.EventArgs e)
{
this.axSI_COMM1.PortOpen = false;
}
}
}