Exemplo n.º 1
0
        public string LoadPlugin(string Path, string ClassName, bool DoRun)
        {
            string result = "OK";

            try
            {
                System.Reflection.Assembly plugindll = System.Reflection.Assembly.LoadFrom(Path);
                Type plugin;

                //retrieve the nodoinfo
                foreach (System.Type objType in plugindll.GetTypes())
                {
                    //Only look at public, non abstract types
                    if (objType.IsPublic && !objType.IsAbstract)
                    {
                        //See if this type implements our interface
                        plugin = objType.GetInterface("VVVV.PluginInterfaces.V1.IPlugin");
                        if (plugin != null)
                        {
                            PropertyInfo pi   = objType.GetProperty("PluginInfo");
                            object       a    = pi.GetValue(null, null);
                            IPluginInfo  info = (IPluginInfo)a;

                            FNodeInfoName = info.Name;
                            break;
                        }
                    }
                }
                FNodeName = System.IO.Path.GetFileName(Path) + "|" + ClassName;

                FHostedPlugin = plugindll.CreateInstance(ClassName) as IPlugin;

                //hand the host over to the plugin
                FHostedPlugin.SetPluginHost(this);

                if (DoRun)
                {
                    OnPinCountChanged();
                }
            }
            catch (Exception e)
            {
                result = "ERROR: " + e.Message;
            }

            //save starttime
            HighPerfTimer.Update();
            FStartTime = HighPerfTimer.Ticks / 1000D;

            if ((FHostedPlugin != null) && (DoRun))
            {
                FTimer.Enabled = true;
            }

            return(result);
        }
Exemplo n.º 2
0
        public void Log(TLogType LogType, string Message)
        {
            if (OnLog != null)
            {
                HighPerfTimer.Update();
                long   runningtime = (long)(HighPerfTimer.Ticks / 1000D - FStartTime);
                long   sec         = runningtime % 60;
                long   min         = runningtime % 3600 / 60;
                long   hour        = runningtime % 216000 / 3600;
                string time        = hour.ToString("d2") + ":" + min.ToString("d2") + ":" + sec.ToString("d2");

                switch (LogType)
                {
                case TLogType.Debug: OnLog(time + "    " + Message); break;

                case TLogType.Message: OnLog(time + " -  " + Message); break;

                case TLogType.Warning: OnLog(time + " *  " + Message); break;

                case TLogType.Error: OnLog(time + " ERR  " + Message); break;
                }
            }
        }
Exemplo n.º 3
0
 public void GetCurrentTime(out double CurrentTime)
 {
     HighPerfTimer.Update();
     CurrentTime = HighPerfTimer.Ticks / 1000D;              //DateTime.UtcNow.ToOADate();
 }