public Event(HermesMiddleware.DataAcquisitionServiceProxy.Event hermesEvent) { this.sEventName = hermesEvent.name; //I am skipping the service name. //this.sService; this.sVariable = hermesEvent.sensorData.variable; this.sBaseStationID = hermesEvent.sensorData.baseStation; this.sSensorID = hermesEvent.sensorData.sensorID; this.dataArray = new HermesMiddleware.DataAcquisitionServiceServer.dataItem[hermesEvent.sensorData.dataArray.Length]; for (int i = 0; i < hermesEvent.sensorData.dataArray.Length; i++) { this.dataArray[i] = new HermesMiddleware.DataAcquisitionServiceServer.dataItem(); this.dataArray[i].timestamp = hermesEvent.sensorData.dataArray[i].timestamp; this.dataArray[i].value = hermesEvent.sensorData.dataArray[i].value; } }
public void Notify() { if (events.Count == 0) { // no events collected => just return return; } try { // prepare events HermesMiddleware.DataAcquisitionServiceProxy.Event[] tmpEvents = new HermesMiddleware.DataAcquisitionServiceProxy.Event[events.Count]; for (int i = 0; i < events.Count; i++) { Event myEvent = (Event)events[i]; // prepare data HermesMiddleware.DataAcquisitionServiceProxy.Event tmpEvent = new HermesMiddleware.DataAcquisitionServiceProxy.Event(); // put name of the subscription as event name tmpEvent.name = subscription.sName; myEvent.sEventName = subscription.sName; tmpEvent.sensorData = new HermesMiddleware.DataAcquisitionServiceProxy.SensorData(); tmpEvent.sensorData.variable = myEvent.sVariable; tmpEvent.sensorData.sensorID = myEvent.sSensorID; tmpEvent.sensorData.baseStation = myEvent.sBaseStationID; tmpEvent.sensorData.dataArray = new HermesMiddleware.DataAcquisitionServiceProxy.dataItem[myEvent.dataArray.Length]; for (int k = 0; k < myEvent.dataArray.Length; k++) { tmpEvent.sensorData.dataArray[k] = new HermesMiddleware.DataAcquisitionServiceProxy.dataItem(); tmpEvent.sensorData.dataArray[k].timestamp = myEvent.dataArray[k].timestamp; tmpEvent.sensorData.dataArray[k].value = myEvent.dataArray[k].value; } tmpEvents[i] = tmpEvent; } if (sCallbackURL.Contains("http")) { //This is a wsdl address. // initialize service proxy HermesMiddleware.DataAcquisitionServiceProxy.DataAcquisitionService serviceProxy = new HermesMiddleware.DataAcquisitionServiceProxy.DataAcquisitionService(); serviceProxy.Url = sCallbackURL;//"http\\localhost"; // call client serviceProxy.EventCallback(sService, tmpEvents); } else { for (int i = 0; i < events.Count; i++) { RawClientCommunicator rwc = new RawClientCommunicator(sCallbackURL); rwc.SendEvent((Event)events[i]); rwc.Close(); } } // increment counters lNotifyCounter++; lEventsCounter += events.Count; // measure performance int nTickcount = System.Environment.TickCount; if (nTickcount > nLastPerformanceTickCount + nPerformanceTickCountDelta) { // calculate performance dEventsPerSecond = (double)nPerformanceEventsCounter / (double)(nTickcount - nLastPerformanceTickCount) * 1000; // reset counters nPerformanceEventsCounter = 0; nLastPerformanceTickCount = nTickcount; } else { nPerformanceEventsCounter += events.Count; } global.mainService.PrintStatus("Notifications: " + lNotifyCounter.ToString() + ", Events: " + lEventsCounter.ToString() + ", Events per Notification: " + ((int)(lEventsCounter / lNotifyCounter)).ToString() + ", Events per second: " + dEventsPerSecond.ToString()); //Console.WriteLine("Event count: " + events.Count + ", Notifications: " + lNotifyCounter.ToString() + ", Events: " + lEventsCounter.ToString()); } catch (Exception exp) { Console.WriteLine(exp); } // in every case clear events events.Clear(); }
//This function takes and event and sends it by serialiazing it. public void SendEvent(HermesMiddleware.DataAcquisitionServiceProxy.Event myEvent) { SendEvent(new Event(myEvent)); }