Exemplo n.º 1
0
            private void BuildServoGroups()
            {
                var servoGroupsField = IRControllerType.GetField("ServoGroups");

                if (servoGroupsField == null)
                {
                    LogFormatted("Failed Getting ServoGroups fieldinfo");
                }
                else if (IRWrapper.ActualController == null)
                {
                    LogFormatted("ServoController Instance not found");
                }
                else
                {
                    actualServoGroups = servoGroupsField.GetValue(IRWrapper.ActualController);
                }
            }
Exemplo n.º 2
0
        internal static bool InitWrapper()
        {
            isWrapped        = false;
            ActualController = null;
            IRController     = null;
            LogFormatted("Attempting to Grab IR Types...");

            IRControllerType = null;

            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "InfernalRobotics_v3.Command.Controller")
                {
                    IRControllerType = t;
                }
            });

            if (IRControllerType == null)
            {
                return(false);
            }

            LogFormatted("IR Version:{0}", IRControllerType.Assembly.GetName().Version.ToString());

            IRMotorType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "InfernalRobotics_v3.Interfaces.IMotor")
                {
                    IRMotorType = t;
                }
            });

            if (IRMotorType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Motor Type");
                return(false);
            }

            IRServoType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "InfernalRobotics_v3.Interfaces.IServo")
                {
                    IRServoType = t;
                }
            });

            if (IRServoType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Servo Type");
                return(false);
            }

            IRControlGroupType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t =>
            {
                if (t.FullName == "InfernalRobotics_v3.Command.ControlGroup")
                {
                    IRControlGroupType = t;
                }
            });

            if (IRControlGroupType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab ControlGroup Type");
                return(false);
            }

            LogFormatted("Got Assembly Types, grabbing Instance");

            try
            {
                var propertyInfo = IRControllerType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);

                if (propertyInfo == null)
                {
                    LogFormatted("[IR Wrapper] Cannot find Instance Property");
                }
                else
                {
                    ActualController = propertyInfo.GetValue(null, null);
                }
            }
            catch (Exception e)
            {
                LogFormatted("No Instance found, " + e.Message);
            }

            if (ActualController == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            LogFormatted("Got Instance, Creating Wrapper Objects");
            IRController = new InfernalRoboticsAPI();
            isWrapped    = true;
            return(true);
        }
Exemplo n.º 3
0
 private void DetermineReady()
 {
     LogFormatted("Getting APIReady Object");
     apiReady = IRControllerType.GetProperty("APIReady", BindingFlags.Public | BindingFlags.Static);
     LogFormatted("Success: " + (apiReady != null));
 }
Exemplo n.º 4
0
        internal bool InternalInitWrapper()
        {
            instance         = this;
            isWrapped        = false;
            ActualController = null;
            IRController     = null;
            LogFormatted("Attempting to Grab IR Types...");

            IRControllerType = AssemblyLoader.loadedAssemblies
                               .Select(a => a.assembly.GetExportedTypes())
                               .SelectMany(t => t)
                               .FirstOrDefault(t => t.FullName == "InfernalRobotics.Command.ServoController");

            if (IRControllerType == null)
            {
                return(false);
            }

            LogFormatted("IR Version:{0}", IRControllerType.Assembly.GetName().Version.ToString());

            IRServoMechanismType = AssemblyLoader.loadedAssemblies
                                   .Select(a => a.assembly.GetExportedTypes())
                                   .SelectMany(t => t)
                                   .FirstOrDefault(t => t.FullName == "InfernalRobotics.Control.IMechanism");

            if (IRServoMechanismType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Mechanism Type");
                return(false);
            }

            IRServoMotorType = AssemblyLoader.loadedAssemblies
                               .Select(a => a.assembly.GetExportedTypes())
                               .SelectMany(t => t)
                               .FirstOrDefault(t => t.FullName == "InfernalRobotics.Control.IServoMotor");

            if (IRServoMotorType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab ServoMotor Type");
                return(false);
            }

            IRServoType = AssemblyLoader.loadedAssemblies
                          .Select(a => a.assembly.GetExportedTypes())
                          .SelectMany(t => t)
                          .FirstOrDefault(t => t.FullName == "InfernalRobotics.Control.IServo");

            if (IRServoType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Servo Type");
                return(false);
            }

            IRServoPartType = AssemblyLoader.loadedAssemblies
                              .Select(a => a.assembly.GetExportedTypes())
                              .SelectMany(t => t)
                              .FirstOrDefault(t => t.FullName == "InfernalRobotics.Control.IPart");

            if (IRServoType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab ServoPart Type");
                return(false);
            }

            IRControlGroupType = AssemblyLoader.loadedAssemblies
                                 .Select(a => a.assembly.GetExportedTypes())
                                 .SelectMany(t => t)
                                 .FirstOrDefault(t => t.FullName == "InfernalRobotics.Command.ServoController+ControlGroup");

            if (IRControlGroupType == null)
            {
                var irassembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.FullName.Contains("InfernalRobotics"));
                if (irassembly == null)
                {
                    LogFormatted("[IR Wrapper] cannot find InvernalRobotics.dll");
                    return(false);
                }
                foreach (Type t in irassembly.assembly.GetExportedTypes())
                {
                    LogFormatted("[IR Wrapper] Exported type: " + t.FullName);
                }

                LogFormatted("[IR Wrapper] Failed to grab ControlGroup Type");
                return(false);
            }

            LogFormatted("Got Assembly Types, grabbing Instance");

            try {
                var propertyInfo = IRControllerType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);

                if (propertyInfo == null)
                {
                    LogFormatted("[IR Wrapper] Cannot find Instance Property");
                }
                else
                {
                    ActualController = propertyInfo.GetValue(null, null);
                }
            } catch (Exception e) {
                LogFormatted("No Instance found, " + e.Message);
            }

            if (ActualController == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            LogFormatted("Got Instance, Creating Wrapper Objects");
            IRController = new InfernalRoboticsAPI();
            isWrapped    = true;
            return(true);
        }
Exemplo n.º 5
0
        internal bool InternalInitWrapper()
        {
            instance     = this;
            isWrapped    = false;
            IRController = null;
            LogFormatted("Attempting to Grab IR Types...");

            IRControllerType = null;

            AssemblyLoader.loadedAssemblies.TypeOperation(t => {
                if (t.FullName == "InfernalRobotics_v3.Command.Controller")
                {
                    IRControllerType = t;
                }
            });

            if (IRControllerType == null)
            {
                return(false);
            }

            LogFormatted("IR Version:{0}", IRControllerType.Assembly.GetName().Version.ToString());

            IRMotorType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t => {
                if (t.FullName == "InfernalRobotics_v3.Interfaces.IMotor")
                {
                    IRMotorType = t;
                }
            });

            if (IRMotorType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Motor Type");
                return(false);
            }

            IRServoType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t => {
                if (t.FullName == "InfernalRobotics_v3.Interfaces.IServo")
                {
                    IRServoType = t;
                }
            });

            if (IRServoType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab Servo Type");
                return(false);
            }

            IRControlGroupType = null;
            AssemblyLoader.loadedAssemblies.TypeOperation(t => {
                if (t.FullName == "InfernalRobotics_v3.Command.ControlGroup")
                {
                    IRControlGroupType = t;
                }
            });

            if (IRControlGroupType == null)
            {
                LogFormatted("[IR Wrapper] Failed to grab ControlGroup Type");
                return(false);
            }

            LogFormatted("Got Assembly Types, grabbing Instance");

            Controller = IRControllerType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
            if (Controller == null)
            {
                LogFormatted("[IR Wrapper] Cannot find Instance Property");
                return(false);
            }

            LogFormatted("Got Instance, Creating Wrapper Objects");
            IRController = new InfernalRoboticsAPI();
            isWrapped    = true;
            return(true);
        }