private async Task OnSummaryByDateAsync(UaClient client) { try { //Get date range var beginDate = Terminal.ReadDate("Begin date (or ENTER to cancel)? ", allowEmpty: true); if (!beginDate.HasValue) { return; } var endDate = Terminal.ReadDate("End date (or ENTER for today)? ", minDate: beginDate.Value, allowEmpty: true); if (!endDate.HasValue) { endDate = DateTime.Now; } await GetSummaryByDateRangeAsync(client, beginDate.Value, endDate.Value).ConfigureAwait(false); } catch (Exception e) { e = e.Unwrap(); Terminal.WriteError(e.Message); }; }
private void LoadUaAppConfiguration() { try { UaClient.UaAppConfigFileAutoCreate = "OPCUAClient"; // auto create a default UA config file to simplify the configuration handling _UaApp = new UaClient(this); _UaApp.LoadConfiguration(); // process the UA configuration } catch (Exception ex) { //MessageBox.Show(ex.Message, "Load UA configuration file failed."); } }
// Gets a submission by its ID private async Task GetSubmissionByIdAsync(UaClient client, int id) { //Call API Terminal.WriteDebug($"Getting submission by Id {id}"); var submission = await client.Submissions.GetByIdAsync("me", id).ConfigureAwait(false); if (submission == null) { Terminal.WriteWarning("No submission found"); } else { WriteSubmission(submission); } }
// Gets latest submissions by a FID private async Task GetLatestSubmissionByFidAsync(UaClient client, string fid) { //Call API Terminal.WriteDebug($"Getting latest submissions for FID {fid}"); var submission = await client.Practitioners.GetLatestAsync("me", fid : fid).ConfigureAwait(false); if (submission == null) { Terminal.WriteWarning("No submission found"); } else { WriteSubmission(submission); Terminal.WriteLine(); }; }
// Gets a summary of the submissions in a given date range private async Task GetSummaryByDateRangeAsync(UaClient client, DateTime beginDate, DateTime endDate) { //Call API Terminal.WriteDebug($"Getting summary submissions between '{beginDate.ToString("MM/dd/yyyy")}' and '{endDate.ToString("MM/dd/yyyy")}'"); var results = await client.Submissions.GetSummaryAsync("me", fromDate : beginDate, toDate : endDate).ConfigureAwait(false); foreach (var result in results) { Terminal.WriteLine($"ID = {result.Id}"); Terminal.WriteLine($"Name = {GetFullName(result.Name)}"); Terminal.WriteLine($"FID = {result.Fid}"); Terminal.WriteLine($"Submit Date = {result.SubmitDate}"); Terminal.WriteLine(); } ; }
public void Initialize() { try { if (uriString.StartsWith("opc.tcp")) { if (opcClientOptions != null) { const string name = "NowFuture"; var options = new Hylasoft.Opc.Ua.UaClientOptions() { ApplicationName = name, ConfigSectionName = name, SessionName = name }; if (!string.IsNullOrWhiteSpace(opcClientOptions.UserName) && !string.IsNullOrWhiteSpace(opcClientOptions.Password)) { options.UserIdentity = new UserIdentity(opcClientOptions.UserName, opcClientOptions.Password); } client = new UaClient(new Uri(uriString), options); } else { client = new UaClient(new Uri(uriString)); } } if (uriString.StartsWith("opcda")) { client = new DaClient(new Uri(uriString)); } client.Connect(); connectionStateChangedEventManager.OnConnectionStateChanged(ConnectionStateChanged, this, new ConnectionStateChangedEventArgs() { IsConnected = true }); } catch (Exception e) { throw new ApplicationException("建立与PLC连接失败,请确认", e); } }
private async Task OnSubmissionByIdAsync(UaClient client) { try { //Get the ID var id = Terminal.ReadInt32("Submission ID (or ENTER to cancel)? ", minValue: 1); if (!id.HasValue) { return; } await GetSubmissionByIdAsync(client, id.Value).ConfigureAwait(false); } catch (Exception e) { e = e.Unwrap(); Terminal.WriteError(e.Message); }; }
private async Task OnSubmissionByFidAsync(UaClient client) { try { //Get the FID var fid = Terminal.ReadString("FID (or ENTER to cancel)? ", allowEmptyStrings: true); if (String.IsNullOrEmpty(fid)) { return; } await GetSubmissionByFidAsync(client, fid).ConfigureAwait(false); } catch (Exception e) { e = e.Unwrap(); Terminal.WriteError(e.Message); }; }
// Gets submissions by a FID private async Task GetSubmissionByFidAsync(UaClient client, string fid) { //Call API Terminal.WriteDebug($"Getting submissions for FID {fid}"); var submissions = await client.Submissions.GetByRequestAsync("me", fid : fid).ConfigureAwait(false); if (!(submissions?.Any() ?? false)) { Terminal.WriteWarning("No submissions found"); } else { foreach (var submission in submissions) { WriteSubmission(submission); Terminal.WriteLine(); } ; }; }
public void Init() { _client = new UaClient(new Uri(ConfigurationManager.AppSettings["UATestEndpoint"])); _client.Connect(); }
private void connectButton_Click(object sender, EventArgs e) { clientTCP = new UaClient(new Uri(serverAddress.Text)); clientTCP.Connect(); connectStatus.Text = "Connected"; }
private Task OnQuitAsync(UaClient client) { _quit = true; return(Task.CompletedTask); }
/// <summary> /// Converts an OPC Foundation node to an Hylasoft OPC UA Node /// </summary> /// <param name="node">The node to convert</param> /// <param name="client">the client the node belongs to</param> /// <param name="parent">the parent node (optional)</param> /// <returns></returns> internal static UaNode ToHylaNode(this OpcF.ReferenceDescription node, UaClient client, Node parent = null) { var name = node.DisplayName.ToString(); var nodeId = node.NodeId.ToString(); return new UaNode(client, name, nodeId, parent); }
public void Init() { _client = new UaClient(new Uri("opc.tcp://giacomo-hyla:51210/UA/SampleServer")); _client.Connect(); }
private SingleOpcClient() { opcClient = new UaClient(); }