public ConnectionWrapper(string host, HWS_ConnectionType connectionType, string application = null, string clientDescription = null) { _host = host; _connectionType = connectionType; _appString = string.IsNullOrEmpty(application) ? "Read Data Example" : application; _userString = string.IsNullOrEmpty(clientDescription) ? Environment.MachineName : clientDescription; _user = null; _password = null; _cci = 0; }
static void Main(string[] args) { ResizeWindow(); string host = "localhost"; HWS_ConnectionType connectionType = HWS_ConnectionType.NetTcp_Windows; using (ConnectionWrapper connection = new ConnectionWrapper(host, connectionType) { //// use credentials when connecting to username endpoint //Username = "******", //Password = "******" }) { try { // handles reconnect logic connection.Run((client, cci) => { // test version Version(client); // browse nodes/tags BrowseNodes(client, out string nodePath); BrowseTags(client, nodePath, out List <string> tags); if (tags != null && tags.Count > 0) { DateTime endTime = DateTime.Now; DateTime startTime = endTime.Subtract(TimeSpan.FromHours(1)); List <string> tagSubset = tags.Take(5).ToList(); // read data GetCurrentValue(client, cci, tagSubset); GetRawData(client, cci, tagSubset, startTime, endTime); GetAvailableAggregates(client); GetProcessedData(client, cci, tagSubset, startTime, endTime); } }); } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); } } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }