public void Run() { string json_config = @" { 'opcServerURL':'opc.tcp://localhost:4840/freeopcua/server/', 'reconnectPeriod':10, 'publishingInterval': 1000, 'nodesDatabase':{ 'isInMemory':true }, 'loggerConfig' :{ 'loglevel' :'debug' }, 'nodesLoader' : { 'targetIdentifier' : 'browseName', 'whiteList':['MyVariable','MyVariable2','MyVariable3'] } }"; var j = JObject.Parse(json_config); var s = new serviceManager(j); var prom = new opcPromConnect(); s.addConnector(prom); s.run(); }
static int Main(string[] args) { init_logging(); logger.Info("OPC-Proxy starting up..."); JObject config = JObject.Parse( "{isInMemory:true, filename:'pollo.dat', stopTimeout:-1, autoAccept:false, endpointURL:'opc.tcp://xeplc.physik.uzh.ch:4840/s7OPC'}" ); serviceManager man = new serviceManager(config); man.connectOpcClient(); man.browseNodesFillCache(); HttpImpl opcHttpConnector = new HttpImpl(); InfluxImpl influx = new InfluxImpl(); man.addConnector(opcHttpConnector); man.addConnector(influx); man.subscribeOpcNodes(); man.initConnectors(); /*System.Timers.Timer aTimer = new System.Timers.Timer(2000); * aTimer.AutoReset = true; * aTimer.Enabled = true; * aTimer.Elapsed += man.OnTimedEvent; */ //man.writeToOPCserver("ciao",4); ManualResetEvent quitEvent = new ManualResetEvent(false); try { Console.CancelKeyPress += (sender, eArgs) => { quitEvent.Set(); eArgs.Cancel = true; }; } catch { } // wait for timeout or Ctrl-C quitEvent.WaitOne(-1); return((int)OPCclient.ExitCode); // db.Dispose(); }
public void run() { string json_config = @" { 'opcServerURL':'opc.tcp://localhost:4840/freeopcua/server/', 'reconnectPeriod':10, 'publishingInterval': 1000, 'nodesDatabase':{ 'isInMemory':true }, 'loggerConfig' :{ 'loglevel' :'info' }, 'nodesLoader' : { 'targetIdentifier' : 'browseName', 'whiteList':['MyVariable','MyVariable2','MyVariable3'] } }"; var j = JObject.Parse(json_config); var s = new serviceManager(j); Thread t = new Thread(async() => { Thread.Sleep(5000); var resp = await s.writeToOPCserver(new string[] { "MyVariable", "MyVariable2", "MyVariable3" }, new object[] { 7, 8, 9 }); Assert.True(resp[0].success); Assert.True(resp[1].success); Assert.True(resp[2].success); Assert.Equal("MyVariable", resp[0].name); Assert.Equal("MyVariable2", resp[1].name); Assert.Equal("MyVariable3", resp[2].name); Assert.Equal(StatusCodes.Good, resp[0].statusCode); resp = await s.writeToOPCserver(new string[] { "MyVariable", "pippo" }, new object[] { "ciao", 8 }); Assert.Equal(StatusCodes.BadNoEntryExists, resp[1].statusCode); Assert.False(resp[1].success); Assert.Equal(StatusCodes.BadTypeMismatch, resp[0].statusCode); Assert.False(resp[0].success); s.cancellationToken.Cancel(); }); t.Start(); s.run(); }
public void setServiceManager(serviceManager serv) { _serv = serv; }
public void setManager(serviceManager m) { _serv = m; }