3
« on: July 10, 2017, 12:34:30 PM »
I should mention that I am only referencing your library from a raw C# program.
Here is my simple test program:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AdvancedHMIDrivers;
using MfgControl;
namespace AHMI_TestSubscription
{
public partial class Form1 : Form
{
EthernetIPforCLXCom testplc = new EthernetIPforCLXCom();
string[] plcResults = new string[7];
int subID;
int t = 500;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
testplc.IPAddress = "192.168.100.99";
testplc.ProcessorSlot = 0;
}
private void btnStart_Click(object sender, EventArgs e)
{
try
{
subID = testplc.Subscribe("dateTime[0]", 6, t, the_callback);
testplc.PollRateOverride = 0;
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex));
}
MessageBox.Show("Subscription " + Convert.ToString(subID) + " is subscribed" ,"Subscription ID");
}
private void the_callback(object sender, MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs e)
{
txtOutput.Text = e.Values[0];
label1.Text = "Connected";
}
private void button1_Click(object sender, EventArgs e)
{
plcResults = testplc.Read("dateTime[0]", 6);
txtOutput.Text = plcResults[0];
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
testplc.UnSubscribe(subID);
MessageBox.Show(subID + " is unsubscribed");
}
}
}