예제 #1
0
 static bool ParseGetCommand(out Protocol.Command command, out byte[] args, string[] cmdline, Protocol protocol, DataModel dataModel)
 {
     command = Protocol.Command.GET_VAR;
     args = null;
     var globalVar = GetGlobalVar(cmdline, dataModel);
     if (globalVar == null)
         return false; // not implemented yet
     return true;
 }
예제 #2
0
 public MainWindow(DataModel dataModel, Protocol protocol, Settings settings)
     : base(Gtk.WindowType.Toplevel)
 {
     this.Build ();
     this.dataModel = dataModel;
     this.protocol = protocol;
     this.settings = settings;
     pollTimer = new Timer(2000);
     pollTimer.Elapsed += OnTimer;
     pollTimer.Enabled = true;
 }
예제 #3
0
        public static bool Parse(out Protocol.Command command, out byte[] args, string cmdline, Protocol protocol, DataModel dataModel)
        {
            var splitted = cmdline.Split('=');
            for (int i = 0; i < splitted.Length; ++i)
                splitted[i] = splitted[i].Trim();

            if (splitted.Length == 1)
            {
                return ParseGetCommand(out command, out args, splitted, protocol, dataModel);
            }
            else
                return ParseSetCommand (out command, out args, splitted, protocol, dataModel);
        }
예제 #4
0
 static bool ParseSetCommand(out Protocol.Command command, out byte[] args, string[] cmdline, Protocol protocol, DataModel dataModel)
 {
     command = Protocol.Command.SET_VAR;
     args = null;
     var globalVar = GetGlobalVar(cmdline, dataModel);
     if (globalVar == null)
         return false; // not implemented yet
     string[] varvalue = new string[cmdline.Length - 1];
     for (int i = 1; i < cmdline.Length; ++i)
         varvalue[i - 1] = cmdline[i];
     if (!globalVar.IsCorrect(varvalue))
         return false;
     byte[] varName = Protocol.EncodeString(globalVar.Name);
     byte[] varValue = EncodeVarValue(globalVar, varvalue);
     if (varValue == null)
         return false;
     args = new byte[varName.Length + varValue.Length];
     Array.Copy(varName, args, varName.Length);
     Array.Copy(varValue, 0, args, varName.Length, varValue.Length);
     return true;
 }
예제 #5
0
 static GlobalVar GetGlobalVar(string[] cmdline, DataModel dataModel)
 {
     return dataModel.GetGlobalVar(cmdline[0]);
 }
예제 #6
0
 private void OnTimer(Object o, ElapsedEventArgs e)
 {
     UpdateConnectionState();
     if (!protocol.IsConnected)
     {
         protocol.Connect(settings.connectionHost, settings.connectionPort);
         protocol.SendGetAllCommand((s) =>
         {
             dataModel = new DataModel(s);
         });
     }
     else
     {
         RequestStats();
         RequestProfilerData();
     }
 }