} // end AddProperty public virtual void Simulate() { try { if (this.HasChildren) { ArrayList children = this.GetChildren(); foreach (object element in children) { DaBaseElement daElement = element as DaBaseElement; if (daElement != null) { daElement.Simulate(); } // end if } // end } // end if m_simulationOn = !m_simulationOn; } catch (Exception e) { Application.Instance.Trace(EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER, "DaBaseElement.Simulate", "Exception" + e.ToString()); } // end try ... catch } // end if
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { try{ int ret = (int)EnumResultCode.E_FAIL; int result = (int)EnumResultCode.S_OK; m_endEvent = new AutoResetEvent(false); MyWin32.HandlerRoutine hr = null; hr = new MyWin32.HandlerRoutine(BISDemo.MyWin32.Handler); MyWin32.SetConsoleCtrlHandler(hr, true); initServer(); // TODO - binary license activation // Fill in your binary license activation keys here // // NOTE: you can activate one or all of the features at the same time // firstly activate the COM-DA Server feature // result = Application.Instance.Activate(EnumFeature.DA_SERVER, "XXXX-XXXX-XXXX-XXXX-XXXX"); if (!ResultCode.SUCCEEDED(result)) { return; } // activate the XML-DA Server Feature // result = Application.Instance.Activate(EnumFeature.XMLDA_SERVER, "XXXX-XXXX-XXXX-XXXX-XXXX"); if (!ResultCode.SUCCEEDED(result)) { return; } // END TODO - binary license activation if (ResultCode.SUCCEEDED(Application.Instance.Initialize(new BISCreator()))) { Application.Instance.EnableTracing( EnumTraceGroup.ALL, EnumTraceGroup.ALL, EnumTraceGroup.SERVER, EnumTraceGroup.SERVER, "Trace.txt", 1000000, 0); ret = Application.Instance.ProcessCommandLine(Environment.CommandLine); if (ret == (uint)EnumResultCode.S_OK) { if (ResultCode.SUCCEEDED(Application.Instance.Start())) { BuildEventCategories(); BuildNamespace(); Application.Instance.Ready(); Console.WriteLine("Press Ctrl-C to exit"); bool bEnd = false; int simulationIndex = 0; Random rand = new Random(); while (!bEnd) { // wait for keyboard entry 'Ctrl + C' or 'Ctrl + Break' if ((bEnd = m_endEvent.WaitOne(100, false)) == true) { continue; } // end if if (simulationIndex % 10 == 0) { device1Node.Simulate(); } // end if if (simulationIndex % 25 == 0) { device2Node.Simulate(); } // end if simulationIndex++; } // end while Application.Instance.Stop(); } } else { if (ret == (uint)EnumResultCode.S_FALSE) { System.Console.WriteLine("Registration operation {0}", Environment.CommandLine); } } Application.Instance.Terminate(); } } catch (Exception e) { Application.Instance.Trace(EnumTraceLevel.ERR, EnumTraceGroup.OPCSERVER, "console.main", "Exception" + e.ToString()); } // end try ... catch }