public static void Main(string[] args) { //// If the server domain name does not match localhost just replace it //// e.g. with the IP address or name of the server machine. var client = new OpcClient("opc.tcp://localhost:4840/SampleServer"); client.Connect(); // The class OpcObjectTypes contains all default OpcNodeId's of all nodes typically // provided by default by every OPC UA server. Here we start browsing at the top most // node the ObjectsFolder. Beneath this node there are all further nodes in an // OPC UA server registered. // Creating an OpcBrowseNode does only prepare an OpcBrowseNodeContext which is linked // to the OpcClient which creates it and contains all further browsing relevant // contextual metadata (e.g. the view and the referenceTypeIds). The used overload of // CreateBrowseNode(...) browses the default view of the server while it takes care of // HierarchicalReferences(see ReferenceTypeIds). // After creating the browse node for the ObjectsFolder we traverse the whole node // tree in preorder. // In case there you have the OpcNodeId of a specific node (e.g. after browsing for a // specific node) it is also possible to pass that OpcNodeId to CreateBrowseNode(...) // to browse starting at that node. var node = client.BrowseNode(OpcObjectTypes.ObjectsFolder); Program.Browse(node); client.Disconnect(); Console.ReadKey(true); }
private async void HandleButtonClick(object sender, RoutedEventArgs e) { // ATTENTION: // In UWP it is not possible to take use of the automatic certificate creation. // Therefore you will need to create a certificate for the client manually. // A possible way to go is to use the code in the CreateCertificate method // at the end of this file. // // Query the file information of the client certificate stored in the assets. var certificateFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Client.Uwp.pfx"); try { using (var client = new OpcClient("opc.tcp://opcuaserver.com:48484")) { client.Certificate = OpcCertificateManager.LoadCertificate(certificateFile.Path); client.Connect(); var value = client.ReadNode("ns=1;s=Countries.DE.DEBB049.Temperature"); if (value.Status.IsGood) { this.textBox.Text = $"Temperature: {value.As<string>()} °C"; } else { this.textBox.Text = value.Status.Description; } } } catch (Exception ex) { this.textBox.Text = ex.Message; } }
public static void Main(string[] args) { //// If the server domain name does not match localhost just replace it //// e.g. with the IP address or name of the server machine. #region 1st Way: Use the OpcClient class. { // The OpcClient class interacts with one OPC UA server. While this class // provides session based access to the different OPC UA services of the // server, it does not implement a main loop. var client = new OpcClient("opc.tcp://localhost:4840/SampleServer"); client.Connect(); Program.CommunicateWithServer(client); client.Disconnect(); } #endregion #region 2nd Way: Use the OpcClientApplication class. { //// The OpcClientApplication class uses a single OpcClient instance which is //// wrapped within a main loop. //// //// Remarks //// - The app instance starts a main loop when the session to the server has //// been established. //// - Custom client/session dependent code have to be implemented within the event //// handler of the Started event. //var app = new OpcClientApplication("opc.tcp://localhost:4840/SampleServer"); //app.Started += Program.HandleAppStarted; //app.Run(); } #endregion }
/// <summary> /// отправить в ПЛК задание /// </summary> public void SendTask(ProductionTaskExtended task) { Log.logThis($"SendTask: {task.Task.TaskNumber}"); using (OpcClient client = new OpcClient(endpoint)) { try { client.Connect(); object[] result = client.CallMethod( "ns=3;s=\"OpcUaMethodSendNewTask\"", "ns=3;s=\"OpcUaMethodSendNewTask\".Method", (Int32)task.Task.ID, (string)task.Task.TaskNumber, (Int16)task.Task.Diameter, (Int16)task.Task.Thickness, (float)task.Task.PieceLength1, (Int16)task.Task.PieceQuantity1, (Int16)task.serialLabel.StartSerial, (string)task.Task.Labeling1Piece1, (string)task.Task.Labeling2Piece1, (string)task.serialLabel.EndLabel ); } catch (Exception e) { Log.logThis(e.Message); } } }
public ProductionTask GetCurrentTaskResult() { bool success; string message; ProductionTask taskResult = new ProductionTask(); using (OpcClient client = new OpcClient(endpoint)) { client.Connect(); object[] result = client.CallMethod( "ns=3;s=\"OpcUaMethodGetTaskResult\"", "ns=3;s=\"OpcUaMethodGetTaskResult\".Method" ); success = Convert.ToBoolean(result[0]); message = Convert.ToString(result[1]); if (success) { taskResult.ID = Convert.ToInt32(result[2]); taskResult.PiceAmount = Convert.ToInt16(result[3]); taskResult.Operator = Convert.ToString(result[4]); taskResult.FinishDate = DateTime.Now; } else { throw new Exception(message); } } return(taskResult); }
public static void Main(string[] args) { //// If the server domain name does not match localhost just replace it //// e.g. with the IP address or name of the server machine. var client = new OpcClient("opc.tcp://localhost:4840/SampleServer"); // Just configure the OpcClient instance with an appropriate user identity with // the name of the user and its password to use to authenticate. client.Security.UserIdentity = new OpcClientIdentity("username", "password"); client.Connect(); Console.WriteLine("ReadNode: {0}", client.ReadNode("ns=2;s=Machine_1/IsActive")); try { client.WriteNode("ns=2;s=Machine_1/IsActive", false); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("ReadNode: {0}", client.ReadNode("ns=2;s=Machine_1/IsActive")); client.Disconnect(); Console.ReadKey(true); }
public static void Main() { //// #Starting Notes //// * The Server always tries to offer localized information using the locales preferred by the client. //// * The Server always falls back to its default localization in case a requested local is not supported. //// * The locale strings used are the ISO normalized culture names used by the CultureInfo. //// * The use of multiple locales results into a prioritization by its order and the Server provides the //// localization for the first locale preferred and supported. // 1. Case: Use the current thread culture (see CultureInfo.CurrentCulture). using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connect(); var displayName = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.DisplayName); var description = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.Description); Console.WriteLine("{0} - {1}", displayName, description); } // 2. Case: Use an explict culture e.g. 'fr' for France. using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Locales.Add("fr"); client.Connect(); var displayName = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.DisplayName); var description = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.Description); Console.WriteLine("{0} - {1}", displayName, description); } // 3. Case: Use an explict culture e.g. 'de' for German. using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Locales.Add("de"); client.Connect(); var displayName = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.DisplayName); var description = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.Description); Console.WriteLine("{0} - {1}", displayName, description); } // 4. Case: Use multiple cultures. If a localized information can not offered for the // first the second culture is used instead. using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Locales.Add("it"); // 1st we prefer "Italian". client.Locales.Add("en"); // 2nd if "Italian" is not supported: Give us "English". client.Connect(); var displayName = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.DisplayName); var description = client.ReadNode("ns=2;s=MyFolder", OpcAttribute.Description); Console.WriteLine("{0} - {1}", displayName, description); } Console.Write("Press any key to continue..."); Console.ReadKey(true); }
//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("А я из основного потока. Просто надо так сделать"); }
public static void Main() { using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connected += HandleClientConnected; client.Connect(); Console.WriteLine("Connected and subscribed."); Console.ReadLine(); } }
public static void Main(string[] args) { //// If the server domain name does not match localhost just replace it //// e.g. with the IP address or name of the server machine. var client = new OpcClient("opc.tcp://localhost:4840/SampleServer"); client.Connect(); // The mapping of the UNECE codes to OPC UA (OpcEngineeringUnitInfo.UnitId) is available here: // http://www.opcfoundation.org/UA/EngineeringUnits/UNECE/UNECE_to_OPCUA.csv var temperatureNode = client.BrowseNode("ns=2;s=Machine_1/Temperature") as OpcAnalogItemNodeInfo; if (temperatureNode != null) { var temperatureUnit = temperatureNode.EngineeringUnit; var temperatureRange = temperatureNode.EngineeringUnitRange; var temperature = client.ReadNode(temperatureNode.NodeId); Console.WriteLine( "Temperature: {0} {1}, Range: {3} {1} to {4} {1} ({2})", temperature.Value, temperatureUnit.DisplayName, temperatureUnit.Description, temperatureRange.Low, temperatureRange.High); } var pressureNode = client.BrowseNode("ns=2;s=Machine_1/Pressure") as OpcAnalogItemNodeInfo; if (pressureNode != null) { var pressureUnit = pressureNode.EngineeringUnit; var pressureInstrumentRange = pressureNode.InstrumentRange; var pressure = client.ReadNode(pressureNode.NodeId); Console.WriteLine( "Pressure: {0} {1}, Range: {3} {1} to {4} {1} ({2})", pressure.Value, pressureUnit.DisplayName, pressureUnit.Description, pressureInstrumentRange.Low, pressureInstrumentRange.High); } client.Disconnect(); Console.ReadKey(true); }
public static void Main() { using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connect(); while (true) { var temperature = client.ReadNode("ns=2;s=Temperature"); Console.WriteLine("Current Temperature is {0} °C", temperature); Thread.Sleep(1000); } } }
private string conectOPC(string id_opcClient) { var opcClient = repo._context.sys_opc_clients.Where(t => t.id == id_opcClient).Select(t => t.opc_client).SingleOrDefault(); var client = new OpcClient(opcClient); try { client.Connect(); } catch (Exception e) { return(e.Message); } client.Dispose(); return("Kết nối thành công"); }
static void Main(string[] args) { var client = new OpcClient("opc.tcp://opcuaserver.com:48010"); client.Connected += new EventHandler(ConnectedEvent); client.Disconnected += new EventHandler(DisconnectedEvent); client.Connect(); var node = client.BrowseNode(OpcObjectTypes.ObjectsFolder); Browse(node); Thread.Sleep(6000); client.Disconnect(); }
public bool Connect() { bool result = true; _client.Connect(); _client.SessionTimeout = 120000; Connected = result; if (Connected) { _breakDetectionArmed = true; } return(result); }
public bool ConnectToServer(string machineName) { string url = SetMachineAddress(machineName); AccessPoint = new OpcClient(url); try { AccessPoint.Connect(); return(true); //Connected } catch (OpcException) { return(false); //Not Connected } }
static void Main(string[] args) { var client = new OpcClient("opc.tcp://127.0.0.1:49320"); client.Security.UserIdentity = new OpcClientIdentity("Tim", "1qaz2wsx3edc4rfv"); client.Security.EndpointPolicy = new OpcSecurityPolicy(OpcSecurityMode.SignAndEncrypt, OpcSecurityAlgorithm.Basic256); client.Connect(); // 一次寫取多個Tag OpcWriteNode[] wCommands = new OpcWriteNode[] { new OpcWriteNode("ns=2;s=Channel2.Device1.Tag1", false), // 寫 boolean new OpcWriteNode("ns=2;s=Channel2.Device1.Tag2", "Test"), // 寫 sting new OpcWriteNode("ns=2;s=Channel2.Device1.Tag3", 8.7), // 寫 float new OpcWriteNode("ns=2;s=Channel2.Device1.Tag3", (ushort)88) // 寫 word }; OpcStatusCollection results = client.WriteNodes(wCommands); // 一次讀取多個Tag OpcReadNode[] rCommands = new OpcReadNode[] { new OpcReadNode("ns=2;s=Channel2.Device1.Tag1"), new OpcReadNode("ns=2;s=Channel2.Device1.Tag2"), new OpcReadNode("ns=2;s=Channel2.Device1.Tag3"), new OpcReadNode("ns=2;s=Channel2.Device1.Tag4") }; IEnumerable <OpcValue> job = client.ReadNodes(rCommands); int i = 0; foreach (OpcValue value in job) { Console.WriteLine("ReadNode: {0},\t = {1}", rCommands[i].NodeId, value); i++; } // 訂閱Tag5 OpcSubscription subscription = client.SubscribeDataChange("ns=2;s=Channel2.Device1.Tag5", HandleDataChanged); subscription.PublishingInterval = 1000; subscription.ApplyChanges(); Console.ReadLine(); client.Disconnect(); }
public void SendTask(TaskProxy.Task task) { using (client = new OpcClient("opc.tcp://192.168.10.2:4840")) { client.Connect(); object[] result = client.CallMethod( "ns=3;s=\"SendNewTask\"", "ns=3;s=\"SendNewTask\".Method", (Int16)task.ID, (String)task.Number.Trim(), (String)task.Item.Trim(), (String)task.StartSerial.Trim(), (Int16)task.TargetCount); Log.GetLog().logThis(task.PrintToString()); } }
public static void Main() { consumerControl = new CancellationTokenSource(); dataChanges = new BlockingCollection <OpcValue[]>(); var consumer = new Thread(ConsumeDataChanges); using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connect(); consumer.Start(client); Console.WriteLine("Client started - press any key to exit."); Console.ReadKey(true); consumerControl.Cancel(); consumer.Join(); } }
private string conectOPC(string id_opcClient, string opcnode) { var opcClient = repo._context.sys_opc_clients.Where(t => t.id == id_opcClient).Select(t => t.opc_client).SingleOrDefault(); var client = new OpcClient(opcClient); try { client.Connect(); } catch (Exception e) { writelogcmd("Cannot connection: " + e.Message); return(null); } var Value = client.ReadNode(new OpcReadNode(opcnode, OpcAttribute.Value)); client.Dispose(); return(Value.ToString() ?? ""); }
public JsonResult autoInsert([FromBody] JObject json) { var id_opcClient = json.GetValue("id").ToString(); var opcClient = repo._context.sys_opc_clients.Where(t => t.id == id_opcClient).Select(t => t.opc_client).SingleOrDefault(); var client = new OpcClient(opcClient); try { client.Connect(); } catch (Exception e) { ModelState.AddModelError("connectfail", e.ToString()); return(generateError()); } var node = client.BrowseNode(OpcObjectTypes.ObjectsFolder); Browse(id_opcClient, node); return(generateSuscess()); }
public static void Main(string[] args) { //// To simple use the configuration stored within the XML configuration file //// beside the client application you just need to load the configuration file as the //// following code does demonstrate. //// By default it is not necessary to explicitly configure an OPC UA client. But in case //// of advanced and productive scenarios you will have to. // There are different ways to load the client configuration. OpcApplicationConfiguration configuration = null; // 1st Way: Load client config using a file path. configuration = OpcApplicationConfiguration.LoadClientConfigFile( Path.Combine(Environment.CurrentDirectory, "ClientConfig.xml")); // 2nd Way: Load client config specified in a specific section of your App.config. configuration = OpcApplicationConfiguration.LoadClientConfig("Opc.UaFx.Client"); // If the client uris domain name does not match localhost just replace it // e.g. with the IP address or name of the client machine. var client = new OpcClient("opc.tcp://localhost:4840/SampleClient"); // To take use of the loaded client configuration, just set it on the client instance. client.Configuration = configuration; client.Connect(); client.Disconnect(); // In case you are using the OpcClientApplication class, you can explicitly trigger // loading a configuration file using the App.config as the following code does // demonstrate. var app = new OpcClientApplication("opc.tcp://localhost:4840/SampleClient"); app.LoadConfiguration(); // Alternatively you can assign the manually loaded client configuration on the client // instance used by the application instance, as the following code does demonstrate. app.Client.Configuration = configuration; app.Run(); }
public static void Main() { using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connect(); var filter = OpcFilter.Using(client) .FromEvents("ns=2;i=1042") .Select(); client.SubscribeEvent("ns=3;i=5031", filter, (sender, e) => { if (e.Event is MachineToolAlarmCondition alarm) { Console.WriteLine(new Guid(alarm.EventId).ToString()); Console.WriteLine("- AlarmIdentifier: {0}", alarm.AlarmIdentifier); Console.WriteLine("- AuxParameters: {0}", alarm.AuxParameters); } }); Console.WriteLine("Press any key to exit."); Console.ReadKey(true); } }
public static void Main(string[] args) { //// If the server domain name does not match localhost just replace it //// e.g. with the IP address or name of the server machine. var client = new OpcClient("opc.tcp://localhost:4840/SampleServer"); client.Connect(); // // The data types used in following lines were generated using the OPC Watch. // https://docs.traeger.de/en/software/sdk/opc-ua/net/client.development.guide#generate-data-types // var job = client.ReadNode("ns=2;s=Machines/Machine_1/Job").As <MachineJob>(); Console.WriteLine("Machine 1 - Job"); PrintJob(job); var order = client.ReadNode("ns=2;s=Machines/Machine_2/Order").As <ManufacturingOrder>(); Console.WriteLine(); Console.WriteLine("Machine 2 - Order"); Console.WriteLine(".Order = {0}", order.Order); Console.WriteLine(".Article = {0}", order.Article); Console.WriteLine(); Console.WriteLine("Machine 2 - Order, Jobs"); foreach (var orderJob in order.Jobs) { PrintJob(orderJob); Console.WriteLine('-'); } client.Disconnect(); Console.ReadKey(true); }
// Update is called once per frame void Update() { Debug.Log("OPC: Inside unity Update function"); var client = new OpcClient("opc.tcp://192.168.0.103:53530/OPCUA/SimulationServer"); Debug.Log("OPC: Setting Client Successfull"); /* var certificate = OpcCertificateManager.CreateCertificate(client); * OpcCertificateManager.SaveCertificate("MyClientCertificate.pfx", certificate); * if (!client.CertificateStores.ApplicationStore.Contains(certificate)) * { * client.CertificateStores.ApplicationStore.Add(certificate); * } */ //client.Security.AutoAcceptUntrustedCertificates = true; //client.Security.VerifyServersCertificateDomains = false; //client.Security.UseOnlySecureEndpoints = false; Debug.Log("OPC: Setting security Parameters successfull"); Debug.Log("OPC: Trying to connect OPC using connect"); client.Connect(); // Connect to Server Debug.Log("OPC: opc Client Connected"); OpcValue value = client.ReadNode("ns=5;s=Counter1"); Debug.Log("OPC: Read Value Successfull"); Debug.Log("Counter1: " + value.ToString()); try { opcCurrentData.text = value.ToString(); Debug.Log("OPC: Value Display Successfull"); } catch (Exception e) { Debug.Log("OPC: Value Setting failed" + e.InnerException); } }
private void Awake() { { //將R700實體模型賦予 System_Parameter.R700 = GameObject.Find("R700"); //將Operator實體模型賦予 System_Parameter.Operator = GameObject.Find("Operator"); //將TCP實體模型賦予 System_Parameter.TCP = GameObject.Find("TCP"); try { //opcua進行連線 OpcUaClient.Connect(); Debug.Log("Sucess"); } catch (System.Exception) { Debug.Log("OPCUA Connection Fail"); throw; } } }
public static void Main() { using (var client = new OpcClient("opc.tcp://localhost:4840")) { client.Connect(); Console.WriteLine("Connected!"); Console.WriteLine("Press any key to add a new 'Speed' node with history to the 'Machine' node."); Console.ReadLine(); var result = client.AddNode(new OpcAddDataVariableNode <int>( name: "Speed", nodeId: OpcNodeId.Null, // the server shall define it parentNodeId: "ns=2;s=Machine") { //IsHistorizing = true, Value = 1000, AccessLevel = OpcAccessLevel.CurrentReadOrWrite | OpcAccessLevel.HistoryReadOrWrite, UserAccessLevel = OpcAccessLevel.CurrentReadOrWrite | OpcAccessLevel.HistoryReadOrWrite, }); if (result.IsBad) { Console.WriteLine(result.Description); } else { Console.WriteLine( "Enter a number and press enter to write it as the new speed value " + "which is also added to the history."); while (int.TryParse(Console.ReadLine(), out var speed)) { client.WriteNode(result.NodeId, new OpcValue(speed, DateTime.UtcNow)); } } } }
/// <summary> /// Setup Opc Client /// </summary> public RunOpc() { #region Setup OPC UA Client.ServerAddress = new Uri("opc.tcp://127.0.0.1:49320"); Client.ApplicationName = AppDomain.CurrentDomain.FriendlyName; Client.Security.AutoAcceptUntrustedCertificates = true; Client.Connect(); for (int i = 8; i <= 13; i++) { var readNodeId = new OpcNodeId("2:RFID_Communications.RFID Readers.Station_" + i + "_Read"); OpcSubscriptions.Add(Client.SubscribeDataChange(readNodeId, ReadTag_ValueChanged)); Console.WriteLine("Subscribed to node {0}\nCurrent Node Value {1}\n", readNodeId.Value, Client.ReadNode(readNodeId).Value); } var writeNodeId = new OpcNodeId("2:RFID_Communications.RFID Readers.Station_8_Write"); OpcSubscriptions.Add(Client.SubscribeDataChange(writeNodeId, WriteTag_ValueChanged)); writeNodeId = new OpcNodeId("2:RFID_Communications.RFID Readers.Station_9_Write"); OpcSubscriptions.Add(Client.SubscribeDataChange(writeNodeId, WriteTag_ValueChanged)); #endregion Setup OPC UA }
public static void Main() { using (var client = new OpcClient("opc.tcp://localhost:4841")) { client.Connect(); client.SubscribeEvent("ns=2;s=Machine/Jobs", HandleJobsEvent); while (true) { Console.WriteLine("Press any key to schedule a new job."); Console.ReadLine(); var jobsNode = client.BrowseNode("ns=2;s=Machine/Jobs"); var job = $"JOB{GetLastJob(jobsNode) + 1:D2}"; client.AddNode(new OpcAddDataVariableNode <int>( name: job, nodeId: OpcNodeId.Null, parentNodeId: jobsNode.NodeId, value: 0)); Console.WriteLine($"CLIENT: New job '{job}' schedulded."); } } }
public IActionResult getopcvalue([FromBody] JObject json) { var model = JsonConvert.DeserializeObject <sys_opc_view_model>(json.GetValue("data").ToString()); try { var client = new OpcClient(model.opc_client); client.Connect(); model.value_input = client.ReadNode(new OpcReadNode(model.opc_node_input, OpcAttribute.Value)).ToString(); model.value_output = client.ReadNode(new OpcReadNode(model.opc_node_output, OpcAttribute.Value)).ToString(); model.value_error = client.ReadNode(new OpcReadNode(model.opc_node_output, OpcAttribute.Value)).ToString(); for (int i = 0; i < model.list_param.Count; i++) { model.list_param[i].value = client.ReadNode(new OpcReadNode(model.list_param[i].opc_node, OpcAttribute.Value)).ToString(); } client.Dispose(); } catch (Exception e) { return(Json(e.Message)); } return(Json(model)); }
public static int Main(string[] args) { try { var opcClient = new OpcClient(); opcClient.PixelOrder = PixelOrder.RGB; opcClient.Connect(); //var frame = opcClient.SingleColorFrame(Color.DarkBlue); //opcClient.WriteFrame(frame); //opcClient.BlinkRandomThenBright(); //opcClient.BlinkRandomThenBright(); //RgbyColorTest(opcClient); //SingleLedChase(opcClient, 100); //opcClient.WriteFrame(opcClient.SingleColorFrame(255, 255, 0), 0); //opcClient.SingleLedChase(100); //RainbowCycle(opcClient, 50); opcClient.RainbowCycle(10); //wait for socket to open //TODO: there is an open event, wait for the socket to open before sending messages //Thread.Sleep(1000); //opcWebSocketClient.ListConnectedDevices(); Console.Read(); var breakpoint = 0; } catch (Exception e) { Console.WriteLine(e.ToString()); } return(0); }