Пример #1
0
        //private BackgroundWorker backgroundWorker;


        public MainWindow()
        {
            //opcUaWorker.OPCNotify += OpcUaWorker_OPCNotify;
            InitializeComponent();
            Firstcheck = false;
            on         = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            error      = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            neutral    = new SolidColorBrush(Color.FromRgb(221, 221, 221));
            Main_pressure.IsReadOnly    = true;
            Crio_pressure.IsReadOnly    = true;
            ForVac_pressure.IsReadOnly  = true;
            PnePressure.IsReadOnly      = true;
            CamTemperature.IsReadOnly   = true;
            Crio_temperature.IsReadOnly = true;


            UpdateTimerCallBack = new TimerCallback(delegate  {
                UpdateGUI(null);
            });
            UpdateTimer = new Timer(UpdateTimerCallBack, null, 0, 1000);



            var client = new OpcClient("opc.tcp://192.168.0.10:4840/");

            client.Connect();

            var node = client.BrowseNode("ns=3;s=\"Crio_DB\".\"Crio\".\"Input\"");

            if (node is OpcVariableNodeInfo variablenode)
            {
                OpcNodeId       datatypeid = variablenode.DataTypeId;
                OpcDataTypeInfo datatype   = client.GetDataTypeSystem().GetType(datatypeid);

                Console.WriteLine(datatype.TypeId);
                Console.WriteLine(datatype.Encoding);

                Console.WriteLine(datatype.Name);

                foreach (OpcDataFieldInfo field in datatype.GetFields())
                {
                    Console.WriteLine(".{0} : {1}", field.Name, field.FieldType);
                }

                Console.WriteLine();
                Console.WriteLine("data type attributes:");
                Console.WriteLine(
                    "\t[opcdatatype(\"{0}\")]",
                    datatype.TypeId.ToString(OpcNodeIdFormat.Foundation));
                Console.WriteLine(
                    "\t[opcdatatypeencoding(\"{0}\", namespaceuri = \"{1}\")]",
                    datatype.Encoding.Id.ToString(OpcNodeIdFormat.Foundation),
                    datatype.Encoding.Namespace.Value);
            }
            Console.WriteLine("А я из основного потока. Просто надо так сделать");
        }