Exemple #1
0
            private void BuildServoGroups()
            {
                var servoGroupsField = IR3ServoControllerType.GetField("ServoGroups");

                if (servoGroupsField == null)
                {
                    LogFormatted("Failed Getting ServoGroups fieldinfo");
                }
                else if (IR3Wrapper.ActualServoController == null)
                {
                    LogFormatted("ServoController Instance not found");
                }
                else
                {
                    actualServoGroups = servoGroupsField.GetValue(IR3Wrapper.ActualServoController);
                }
            }
Exemple #2
0
        internal static bool InitWrapper()
        {
            // Prevent the init function from continuing to initialize if InfernalRobotics is not installed.
            if (hasAssembly == null)
            {
                LogFormatted("Attempting to Grab IR3 Assembly...");
                hasAssembly = AssemblyLoader.loadedAssemblies.Any(a => a.dllName.Equals("InfernalRobotics_v3"));
                if (hasAssembly.Value)
                {
                    LogFormatted("Found IR3 Assembly!");
                }
                else
                {
                    LogFormatted("Did not find IR3 Assembly.");
                }
            }
            if (!hasAssembly.Value)
            {
                isWrapped = false;
                return(isWrapped);
            }

            isWrapped             = false;
            ActualServoController = null;
            IR3Controller         = null;
            LogFormatted("Attempting to Grab IR3 Types...");

            IR3ServoControllerType = GetType("InfernalRobotics_v3.Command.Controller");

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

            LogFormatted("IR3 Version:{0}", IR3ServoControllerType.Assembly.GetName().Version.ToString());

            IR3ServoMechanismType = GetType("InfernalRobotics_v3.Control.IServo");

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

            IR3ServoMotorType = GetType("InfernalRobotics_v3.Control.IMotor");

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

            IR3ServoType = GetType("InfernalRobotics_v3.Control.IServo");

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

            IR3ServoPartType = GetType("InfernalRobotics_v3.Control.IServo");

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

            IR3ControlGroupType = GetType("InfernalRobotics_v3.Command.ControlGroup");

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

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

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

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

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

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

            LogFormatted("Got Instance, Creating Wrapper Objects");
            IR3Controller = new InfernalRoboticsAPI();
            isWrapped     = true;
            return(true);
        }
Exemple #3
0
 private void DetermineReady()
 {
     LogFormatted("Getting APIReady Object");
     apiReady = IR3ServoControllerType.GetProperty("APIReady", BindingFlags.Public | BindingFlags.Static);
     LogFormatted("Success: " + (apiReady != null));
 }