Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="gert">Add-on card controller.</param>
        /// <param name="mc">Motor controller.</param>
        public GpioController(GertbotUartController gert, MotorController mc)
        {
            this.gertController  = gert;
            this.motorController = mc;

            this.semaphore = new System.Threading.SemaphoreSlim(
                1, // Initial count > 0: the semaphore is initially free
                1  // Max count: only one thread can enter at a time
                );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="uiSync">User interface synchronizer object.</param>
        public Robot(IUiDataSync uiSync)
        {
            this.uiDataSync = uiSync;

            // Recognizing if running on device or on PC. If run on desktop, considering the app is being run on a desktop simulator.
            var analyticsInfo = Windows.System.Profile.AnalyticsInfo.VersionInfo;

            this.runOnSimulator = (analyticsInfo.DeviceFamily.Trim().ToLower() == "windows.desktop");

            uiSync.setSimulatorMode(this.runOnSimulator);

            // Initialize hardware related objects if not run on simulator
            if (!this.runOnSimulator)
            {
                this.gertController   = new GertbotUartController();
                this.sensorController = new SensorController(this.gertController);
                this.motorController  = new MotorController(this.gertController);
                this.gertbotGeneral   = new GertbotGeneral(this.gertController);
                this.gpioController   = new GpioController(this.gertController, this.motorController);
            }
        }