Example #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;
 }
Example #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;
 }
Example #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);
        }
Example #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;
 }
Example #5
0
        public static void Main()
        {
            Protocol protocol = new Protocol ();

            Application.Init ();

            mhe.Settings settings = new mhe.Settings() {
                connectionHost = DEFAULT_HOST,
                connectionPort = DEFAULT_PORT
            };

            MainWindow main = new MainWindow(null, protocol, settings);
            main.DeleteEvent += OnDelete;
            main.DestroyEvent += (object o, DestroyEventArgs args) =>
            {
                Application.Quit();
            };
            main.Show();

            Application.Run();
        }