import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
[Bindable] private var serverStatusData:ArrayCollection = new ArrayCollection();

public function initServerTab():void{
    // Initialize refresh timer
    Application.application.currentState = "Server_Status";
    this.timerObj.stop();
    this.timerObj = new Timer(refreshTime*1000,1);
    this.timerObj.addEventListener(TimerEvent.TIMER, requestUpdateServerStatusTab);
    onExecuteCommand(null,"getFMGStatus" , null);
}

public function requestUpdateServerStatusTab(event:Event):void{
    // send a request to get FMG stats
    onExecuteCommand(null,"getFMGStatus" , null);
    this.timerObj.stop();    
}

private function onResultServerStatusTab(info:Object):void{
    this.timerObj.start();
    
    var displayData:ArrayCollection  = new ArrayCollection ();

    var tempString:String;
    var headerArray:Array = new Array();
    headerArray= info.data[info.data.length -1].split(",");
    
    var i:int;
    
    
    
    for( i = (info.data.length -2) ; i>0 ; i--){
        tempString = info.data[i];
        var tempArray:Array= tempString.split(",");
        var tempObj:Object = new Object();
        var count:int = 0;
        var j:String;
        for( j in headerArray){
            tempObj[headerArray[j]] = tempArray[count++];
            
        } 
        displayData.addItem(tempObj);
    }
    serverStatusData =   displayData;
}