示例#1
0
        public async Task <bool> InitializeAsync()
        {
            s7Connector = new Sharp7Connector(plcConnectionSettings, varaibleNameParser)
            {
                Logger = Logger
            };
            ConnectionState = s7Connector.ConnectionState;

            await s7Connector.InitializeAsync();

#pragma warning disable 4014
            Task.Run(async() =>
            {
                try
                {
                    await s7Connector.Connect();
                }
                catch (Exception e)
                {
                    Logger?.LogError(e, "Error while connecting to PLC");
                }
            });
#pragma warning restore 4014

            RunNotifications(s7Connector, TimeSpan.FromMilliseconds(100))
            .AddDisposableTo(Disposables);

            return(true);
        }
示例#2
0
        public async Task <bool> InitializeAsync()
        {
            s7Connector     = new Sharp7Connector(ipAddress, rackNumber, cpuMpiAddress);
            ConnectionState = s7Connector.ConnectionState;

            await s7Connector.InitializeAsync();

#pragma warning disable 4014
            Task.Run(async() =>
            {
                try
                {
                    await s7Connector.Connect();
                }
                catch (Exception)
                {
                }
            });
#pragma warning restore 4014

            return(true);
        }