001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenix6.wpiutils; 008 009import edu.wpi.first.wpilibj.MotorSafety; 010 011/** 012 * Implem of MotorSafety interface from WPILib. This also allows late/lazy 013 * construction of WPILib's motor safety object. 014 */ 015public class MotorSafetyImplem extends MotorSafety { 016 private final Runnable m_stopMotor; 017 private final String m_description; 018 019 /** 020 * Constructor for MotorSafetyImplem 021 * @param stopMotor Lambda to stop the motor 022 * @param description Description of motor controller 023 */ 024 public MotorSafetyImplem(Runnable stopMotor, String description) { 025 m_stopMotor = stopMotor; 026 m_description = description; 027 } 028 029 /** 030 * Stops the controller 031 */ 032 public void stopMotor() { m_stopMotor.run(); } 033 034 /** 035 * @return Description of motor controller 036 */ 037 public String getDescription() { return m_description; } 038}