Jump to content

bwdavis

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by bwdavis

  1. Saragani,

    The suggestion you gave worked perfectly.  It is important to note that the setting of PLCFactory.WorkWithXmlInternally = true MUST happen prior to the call to GetPLC.  I had tried setting it inside the try block with no success, but as it appears below, it works perfectly on Windows 10 build 1607.

    Many thanks for your attention.

    Kind Regards

    Bruce

     

     private void Connect_Click(object sender, EventArgs e)
            {

                PLCFactory.WorkWithXmlInternally = true;
                Ethernet ethernet = new Ethernet("10.10.11.25", 20256, EthProtocol.TCP, 3, 3000);

                try
                {
                    plc = PLCFactory.GetPLC(ethernet, 0); // <-- Add boolean so it will build
                    plc.EventAbortCompleted += new PLC.AbortCompletedDelegate(plc_EventAbortCompleted);
                    setButtonsEnableState(true);
                    PlcVersion version = plc.Version;
                    txtModel.Text = version.OPLCModel;
                    txtHW.Text = version.HWVersion;
                    txtOS.Text = version.OSVersion;
                    txtBoot.Text = version.Boot;
                    txtBinLib.Text = version.BinLib;
                    txtFactoryBoot.Text = version.FactoryBoot;
                    try
                    {
                        txtPlcName.Text = plc.PlcName;
                    }
                    catch
                    {
                    }
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message);
                    setButtonsEnableState(false);
                    ethernet.Disconnect();
                    System.Windows.Forms.MessageBox.Show("Could not establish a connection to the PLC");
                }
            }

     

  2. 2 minutes ago, Saragani said:

    Run the program as administrator. There is also a property called PLCFactory.WorkWithXMLInternally (or something similar), which if set to true, the .net driver will not try to extract the xml to the drive (which results an access denied, and an error which makes the driver think that there is a communication problem).

    Sorry, I posted that prematurely.  New on the forum and all that.  I did try PLCFactory.WorkWithXMLInternally = true;  I placed the code directly above the commented line at the top of the try block below.  It made no difference.  I will try your suggestions.

     

    Hi, I'm trying to communicate with a unitronics plc and am using the C# sample code provided by an email from Unitronics, Boston Support as below:

            private void Connect_Click(object sender, EventArgs e)
            {
                Ethernet ethernet = new Ethernet("10.10.11.25", 20256, EthProtocol.TCP, 3, 3000);

                try
                {
                    // plc = PLCFactory.GetPLC(ethernet, 0); // <-- No overload for method 'GetPLC' takes '2' arguments

                    plc = PLCFactory.GetPLC(ethernet, 0, true); // <-- Add boolean so it will build
                    plc.EventAbortCompleted += new PLC.AbortCompletedDelegate(plc_EventAbortCompleted);
                    setButtonsEnableState(true);
                    PlcVersion version = plc.Version;
                    txtModel.Text = version.OPLCModel;
                    txtHW.Text = version.HWVersion;
                    txtOS.Text = version.OSVersion;
                    txtBoot.Text = version.Boot;
                    txtBinLib.Text = version.BinLib;
                    txtFactoryBoot.Text = version.FactoryBoot;
                    try
                    {
                        txtPlcName.Text = plc.PlcName;
                    }
                    catch
                    {
                    }
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message);
                    setButtonsEnableState(false);
                    ethernet.Disconnect();
                    System.Windows.Forms.MessageBox.Show("Could not establish a connection to the PLC");
                }
            }

    This code is straight from the sample code provided with latest Unicom.CommDriver.dll.  Trying to build this on VS 2008 C#, I first get:

    No overload for method 'GetPLC' takes 2 arguments

    Editing that, and adding a boolean, true or false so that it will build, and then running it,  I get: Cannot communicate with the PLC with the specified UnitID!

    Tried running in compatibility mode as administrator for Windows XP SP3, same result.

    Application code broke with upgrade to windows 10.

    Environment

    Windows 10 build 1607

    Visual Studio 9.0 (2008)

    C#.NET

    Bruce D

     

    I have not seen your code. Try running your code as administrator.

     

×
×
  • Create New...