Jump to content

John Rachow

Members
  • Posts

    3
  • Joined

  • Last visited

About John Rachow

  • Birthday 10/27/1972

Profile Information

  • Gender
    Male

John Rachow's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Saragani, Despite my best efforts, I have not been able to get either of the programs you mentioned to load. As I stated before, the PLC is making an attempt to connect, but for some reason C# thinks that the PLC is null and therefore does not run the line of code that would initiate the OnConnect method, instead it runs the OnDisconnect method. Is there something I am missing in the PLC that would make it do that? Again I am attaching the PLC code for you to look at.Enettest.vlp Please let me know if there is anything that is missing. As I stated before, Chris had stated that this was working, but for the life of me I cannot get it to connect and therefore must be overlooking something on the PLC.
  2. We are using a V350 to connect and the ComDriver is the latest 1.0.0.47. This is running on Wndows 7 x64 and I am an administrator and am connecting over the network via a switch. I get a response when pressing the F1 button as it is programmed that way but the method that it goes into is OnDisconnect instead of OnConnect which would lead me to believe that for some reason the plc is null. I am able to attach the PLC program for you to peruse and see if there is something that is missing to make C# to think it is null. Do I have to set anything else up on the PLC side to allow connection in C#? Once again thanks for your help. John Enettest.vlp
  3. I know that I am digging up an old post but since Chris is no longer with the company and this is exactly the same program I was hoping that I could just re-open this thread. I am taking over this project and must admit that I know virtually nothing regarding the PLC but am familiar with c#. I am having dificulty communicating with the PLC. From what I have been able to determine is that for some reason the listening PC when it gets a connection request from the PLC it somehow thinks that plc is null and therefore never runs the OnConnect method(See code below) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Unitronics.ComDriver; using Unitronics.ComDriver.Messages.DataRequest; using System.Runtime.Remoting.Messaging; using System.Reflection; using System.Data.SqlClient; namespace TestPLC { public partial class Form1 : Form { System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection ("data source=SQLSERVER;initial catalog=Furnaces;integrated security=SSPI;persist security info=False;workstation id=John;packet size=4096"); System.Data.SqlClient.SqlConnection sqlConnection2 = new System.Data.SqlClient.SqlConnection ("data source=SQLSERVER;initial catalog=Catalog;integrated security=SSPI;persist security info=False;workstation id=John;packet size=4096"); private PLC plc; const int LOCAL_PORT = 502; //private Channel listener; delegate void SetControlValueCallback(Control oControl, string propName, object propValue); public Form1() { InitializeComponent(); Listener(); } void plc_EventAbortCompleted() //This method read/write MI's to PLC { MethodInvoker mi = delegate() { }; UpdateUI(mi); } private void UpdateUI(MethodInvoker del) { if (this.InvokeRequired) this.Invoke(del); else del(); } private void Listener() { try { EthernetListener listener = PLCFactory.GetChannel(502); if (listener == null) listener = new EthernetListener(502, 3, 3000); //label1.Text = listener.Status.ToString(); listener.OnListenerConnectionAccepted += new EthernetListener.ListenerConnectionAcceptedDelegate(OnConnect); listener.OnListenerConnectionClosed += new EthernetListener.ListenerConnectionClosedDelegate(OnDisconnect); PLCFactory.GetPLC(listener); } catch (Exception ex) { MessageBox.Show("Could not connect - Listener" + ex.ToString()); } } private void OnDisconnect(EthernetListener ethernetListener) { EthernetListener listener = PLCFactory.GetChannel(LOCAL_PORT); if (plc != null) { MessageBox.Show("Disconnected"); plc.Disconnect(); } else { if (listener != null) { MessageBox.Show("Disconnected2"); listener.Disconnect(); listener.OnListenerConnectionAccepted -= new EthernetListener.ListenerConnectionAcceptedDelegate(OnConnect); listener.OnListenerConnectionClosed -= new EthernetListener.ListenerConnectionClosedDelegate(OnDisconnect); Listener(); } } } private void OnConnect(PLC oPlc) { plc = oPlc; MessageBox.Show("Connected"); } } } This is just a simple program that is being used to test communication and connection with the PLC. Chris supposedly had this working but when he left it was dropped on my desk and I cannot get the PLC to connect with to the PC. I will also try to attach the test PLC program for you to look at as well. Like I said, I am not sure why it thinks the plc is null. Please forgive my lack of knowledge of PLC programming.
×
×
  • Create New...