Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                RSLinxOPCDA rsLinxOPCDA = new RSLinxOPCDA();
                rsLinxOPCDA.Connect("opcda://PLC_Emulator/RSLinx Remote OPC Server");
                Console.WriteLine("Connected: " + rsLinxOPCDA.IsConnected.ToString());

                rsLinxOPCDA.CreateGroup("PLC_NWL", 1000);

                rsLinxOPCDA.AddItem("[PLC_NWL]TAG001");

                //rsLinxOPCDA.OnRead += OnOPCRead;

                rsLinxOPCDA.ReadItemsAsync();

                Console.Read();


                rsLinxOPCDA.StopReadItemsAsync();
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.Message);
            }

            /*int ptimeBias = 0, pPercentDeadBand = 0, serverGroup = 0, revisedUpdateRate= 0, rrid = 0;
             * object unk = null;
             *
             * oPCServer.AddGroup("", 1, 1, 0, ptimeBias, pPercentDeadBand, 1, serverGroup, revisedUpdateRate, rrid, unk);*/
        }
Ejemplo n.º 2
0
        protected void ReadItems(RSLinxOPCDA rsLinxOPCDA)
        {
            do
            {
                Opc.Da.ItemValueResult[] itemValues;
                itemValues = rsLinxOPCDA.m_server.Read(rsLinxOPCDA.m_items);

                foreach (Opc.Da.ItemValueResult itemValue in itemValues)
                {
                    Console.WriteLine("Time: " + itemValue.Timestamp.ToString() + " Item: " + itemValue.ItemName + ", value: " + itemValue.Value.ToString());
                }

                System.Threading.Thread.Sleep(rsLinxOPCDA.m_groupState.UpdateRate);
            } while (true);
        }