Exemple #1
0
        protected void Initialize()
        {
            try
            {
                _apiHandle = CanInterfaceDll.Init();
            }
            catch (DllNotFoundException)
            {
                _logger.LogError("Failed to initialize motors: NTCAN drivers not installed");

                PeripheralState = PeripheralState.DriversNotInstalled;
                return;
            }

            if (_apiHandle.Equals(IntPtr.Zero))
            {
                PeripheralState = PeripheralState.NotConnected;
                _logger.LogInformation("No physical CAN interface found");
            }
            else
            {
                _logger.LogInformation("Starting motor calibration...");
                PeripheralState = PeripheralState.Initializing;
                CanInterfaceDll.StartCalibration(_apiHandle, _calibrationDone);
            }
        }
Exemple #2
0
 public void MoveBar(Bar bar, uint position, uint angle)
 {
     if (PeripheralState == PeripheralState.Ready)
     {
         CanInterfaceDll.MoveBar(_apiHandle, bar, (int)position, (int)(angle % 360));
     }
 }
Exemple #3
0
 public void RotateBar(Bar bar, uint angle)
 {
     CanInterfaceDll.MoveBar(_apiHandle, bar, -1, (int)angle);
 }
Exemple #4
0
 public void ShiftBar(Bar bar, uint position)
 {
     CanInterfaceDll.MoveBar(_apiHandle, bar, (int)position, -1);
 }