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); } }
public void MoveBar(Bar bar, uint position, uint angle) { if (PeripheralState == PeripheralState.Ready) { CanInterfaceDll.MoveBar(_apiHandle, bar, (int)position, (int)(angle % 360)); } }
public void RotateBar(Bar bar, uint angle) { CanInterfaceDll.MoveBar(_apiHandle, bar, -1, (int)angle); }
public void ShiftBar(Bar bar, uint position) { CanInterfaceDll.MoveBar(_apiHandle, bar, (int)position, -1); }