Module: nagvis Branch: master Commit: 9442cd1455f0c0fbf29b5ae7add48d38d90a67b8 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=9442cd1455f0c0fbf29b5ae7add48d38d90a67b8
Author: Roman Kyrylych <[email protected]> Date: Tue Aug 11 12:30:38 2009 +0300 gmap: Initial work on Poller Signed-off-by: Roman Kyrylych <[email protected]> --- share/netmap/Location.php | 30 +++++++++++++++++++++- uifx/src/modules/gmap/mate/LocationsEM.mxml | 9 ++++++ uifx/src/modules/gmap/mate/PreinitEM.mxml | 3 +- uifx/src/modules/gmap/mate/StartupEM.mxml | 6 +++- uifx/src/modules/gmap/mate/UIInitEM.mxml | 1 + uifx/src/modules/gmap/mediator/Poller.as | 37 +++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 3 deletions(-) diff --git a/share/netmap/Location.php b/share/netmap/Location.php index 5319fb6..e01671f 100644 --- a/share/netmap/Location.php +++ b/share/netmap/Location.php @@ -23,14 +23,20 @@ class Location { + const STATE_UNKNOWN = 0; + const STATE_OK = 1; + const STATE_WARNING = 2; + const STATE_ERROR = 3; + public $id; public $point; public $label; public $address; public $description; public $object; + public $state; - public function __construct($id = "", $point = "", $label = "", $address = "", $description = "", $object = null) + public function __construct($id = "", $point = "", $label = "", $address = "", $description = "", $object = null, $state = self::STATE_UNKNOWN) { $this->id = $id; $this->point = $point; @@ -38,6 +44,7 @@ class Location $this->address = $address; $this->description = $description; $this->object = $object; + $this->state = $state; } private function fromXML($node) @@ -196,6 +203,27 @@ class Location } /** + * @return array of Location + */ + public function checkAll() + { + if (($xml = @simplexml_load_file('locations.xml')) === FALSE) + throw new Exception('Could not read locations.xml'); + + $locations = array(); + foreach ($xml->location as $node) + { + $location = Location::fromXML($node); + // TODO: check status of $location->children() here + $location->state = self::STATE_OK; + + $locations[] = $location; + } + + return $locations; + } + + /** * @param array $hosts * @return array of Location */ diff --git a/uifx/src/modules/gmap/mate/LocationsEM.mxml b/uifx/src/modules/gmap/mate/LocationsEM.mxml index 840febf..1e1e730 100644 --- a/uifx/src/modules/gmap/mate/LocationsEM.mxml +++ b/uifx/src/modules/gmap/mate/LocationsEM.mxml @@ -15,6 +15,7 @@ import modules.gmap.events.LocationEvent; import modules.gmap.mediator.MainMD; + import modules.gmap.mediator.Poller; ]]> </mx:Script> @@ -58,4 +59,12 @@ </RemoteObjectInvoker> </EventHandlers> + <EventHandlers type="{Poller.TIMEOUT}"> + <RemoteObjectInvoker instance="{LocationsService}" method="checkAll"> + <resultHandlers> + <InlineInvoker method="Alert.show" arguments="state checked"/> + </resultHandlers> + </RemoteObjectInvoker> + </EventHandlers> + </EventMap> diff --git a/uifx/src/modules/gmap/mate/PreinitEM.mxml b/uifx/src/modules/gmap/mate/PreinitEM.mxml index 5d22abb..36d0ede 100644 --- a/uifx/src/modules/gmap/mate/PreinitEM.mxml +++ b/uifx/src/modules/gmap/mate/PreinitEM.mxml @@ -8,8 +8,9 @@ import modules.gmap.data.CurrentLocation; import modules.gmap.data.LocationsExtData; import modules.gmap.data.LocationsData; - import mx.events.FlexEvent; import modules.gmap.data.ViewpointsData; + + import mx.events.FlexEvent; ]]> </mx:Script> diff --git a/uifx/src/modules/gmap/mate/StartupEM.mxml b/uifx/src/modules/gmap/mate/StartupEM.mxml index c9f1647..e4264f1 100644 --- a/uifx/src/modules/gmap/mate/StartupEM.mxml +++ b/uifx/src/modules/gmap/mate/StartupEM.mxml @@ -11,6 +11,7 @@ import modules.gmap.mediator.MainMD; import modules.gmap.mediator.MapMD; + import modules.gmap.mediator.Poller; import modules.gmap.data.ViewpointsData; import modules.gmap.data.LocationsData; @@ -21,6 +22,8 @@ <MethodInvoker generator="{MainMD}" method="init"/> + <ObjectBuilder generator="{Poller}" constructorArguments="{scope.dispatcher}"/> + <RemoteObjectInvoker destination="zend" source="Viewpoint" method="getAll" debug="true"> <resultHandlers> <MethodInvoker generator="{ViewpointsData}" method="fill" arguments="{resultObject}"/> @@ -29,8 +32,9 @@ <RemoteObjectInvoker destination="zend" source="Location" method="getAll" debug="true"> <resultHandlers> <MethodInvoker generator="{LocationsData}" method="fill" arguments="{resultObject}"/> + <MethodInvoker generator="{Poller}" method="resourceReady"/> </resultHandlers> - </RemoteObjectInvoker> + </RemoteObjectInvoker> </Injectors> diff --git a/uifx/src/modules/gmap/mate/UIInitEM.mxml b/uifx/src/modules/gmap/mate/UIInitEM.mxml index 0ff52e3..7b0ec30 100644 --- a/uifx/src/modules/gmap/mate/UIInitEM.mxml +++ b/uifx/src/modules/gmap/mate/UIInitEM.mxml @@ -17,6 +17,7 @@ import modules.gmap.mediator.MainMD; import modules.gmap.mediator.MapMD; + import modules.gmap.mediator.Poller; import modules.gmap.data.ViewpointsData; import modules.gmap.data.CurrentLocation; diff --git a/uifx/src/modules/gmap/mediator/Poller.as b/uifx/src/modules/gmap/mediator/Poller.as new file mode 100644 index 0000000..1b5b5ef --- /dev/null +++ b/uifx/src/modules/gmap/mediator/Poller.as @@ -0,0 +1,37 @@ +package modules.gmap.mediator +{ + import flash.events.Event; + import flash.events.IEventDispatcher; + import flash.events.TimerEvent; + import flash.utils.Timer; + + public class Poller + { + public static const TIMEOUT : String = "PollerTimeout"; + + private var _semaphor : int = 1; + private var _dispatcher : IEventDispatcher; + private var _timer : Timer; + + public function Poller(dispatcher : IEventDispatcher) + { + _dispatcher = dispatcher; + + _timer = new Timer(5000); + _timer.addEventListener(TimerEvent.TIMER, onTimer); + } + + public function resourceReady():void + { + _semaphor--; + + if(_semaphor === 0) + _timer.start(); + } + + protected function onTimer(event : TimerEvent) : void + { + _dispatcher.dispatchEvent(new Event(TIMEOUT)); + } + } +} \ No newline at end of file ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
