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' :'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(); }