Bir Eklenti Oluşturmak

Genel Bakış

Eklentiler, kişisel araçların, düzenlerin, veri kaynakları/türlerinin ve kişiselleştirilmiş temaların oluşturulmasına imkan tanımaktadır. Shuffleboard, aşağıdaki gömülü eklentileri sağlamaktadır.

  • NetworkTables Plugin: To connect to data published over NetworkTables

  • Base Plugin: To display custom FRC® data types in custom widgets

  • CameraServer Plugin: To view streams from the CameraServer

Tüyo

An example custom Shuffleboard plugin which creates a custom data type and a simple widget for displaying it can be found here.

Create a Custom Plugin

Bir eklenti tanımlamak için eklenti sınıfı edu.wpi.first.shuffleboard.api.Plugin altı sınıfı veya alt sınıfın bir alt sınıfı olmalıdır. Bir eklenti sınıfı örneği aşağıdaki gibi olacaktır.

import edu.wpi.first.shuffleboard.api.plugin.Description;
import edu.wpi.first.shuffleboard.api.plugin.Plugin;
@Description(group = "com.example", name = "MyPlugin", version = "1.2.3", summary = "An example plugin")
public class MyPlugin extends Plugin {
}

Sürüm numaraları da dahil olmak üzere, bu özniteliklerin nasıl kullanıldığına dair daha fazla açıklamaya buradan ulaşabilirsiniz.

Note the @Description annotation is needed to tell the plugin loader the properties of the custom plugin class. Plugin classes are permitted to have a default constructor but it cannot take any arguments.

Building plugin

Bir eklenti oluşturmanın en kolay yolu shufflebloard kaynak ağıcındaki* example-plugins klasörünü kullanmaktır. Git clone https://github.com/wpilibsuite/shuffleboard.git kullanrak Shuffleboard’u kopyalayınız ve cihazınızda yüklü olan WPILib sürümü ile eşleşen sürümü kitaplıktan seçiniz (örn. 2023.2.1). git checkout v2023.2.1

Eklentinizi example-plugins\PLUGIN-NAME veri havuzuna ekleyiniz. example-plugins\custom-data-and-widget üzerinden custom-data-and-widget.gradle’ı koyalayınız ve eklentinizin adıyla eşleşecek şekilde kopyaladığınız dosyayı yeniden adlandırınız. Shuffleboard kök dizinindeki settings.gradle’ı, include "example-plugins:PLUGIN-NAME"’i ekleyecek şekilde düzenleyiniz.

Plugins are allowed to have dependencies on other plugins and libraries, however, they must be included correctly in the maven or gradle build file. When a plugin depends on other plugins, it is good practice to define those dependencies so the plugin does not load when the dependencies do not load as well. This can be done using the @Requires annotation as shown below:

@Requires(group = "com.example", name = "Good Plugin", minVersion = "1.2.3")
@Requires(group = "edu.wpi.first.shuffleboard", name = "Base", minVersion = "1.0.0")
@Description(group = "com.example", name = "MyPlugin", version = "1.2.3", summary = "An example plugin")
public class MyPlugin extends Plugin {
}

The minVersion specifies the minimum allowable version of the plugin that can be loaded. For example, if the minVersion is 1.4.5, and the plugin with the version 1.4.7 is loaded, it will be allowed to do so. However, if the plugin with the version 1.2.4 is loaded, it will not be allowed to since it is less than the minVersion.

Deploying Plugin To Shuffleboard

Shuffleboard’a eklenti aktarmak için eklentinin bir jar dosyaysı halini oluşturmanız ve oluşturduğunuz dosyayı ~/Shuffleboard/plugins klasörüne eklemeniz gerekecektir. Bu işlem Shuffleboard kökünden gradlew :example-plugins:PLUGIN-NAME:installPlugin’in çalıştırılmasıyla kendi kendiliğine gerçekleştirilebilmektedir.

After deploying, Shuffleboard will cache the path of the plugin so it can be automatically loaded the next time Shuffleboard loads. It may be necessary to click on Clear Cache under the plugins menu to remove a plugin or reload a plugin into Shuffleboard.

Manually Adding Plugin

Shuffleboard’a eklenti eklemenin bir diğer yoluysa eklentiyi jar dosyası olarak derlemek ve Shuffleboard üzerinden eklemektir. Jar dosyası shuffleboard kökü Open Shuffleboard’da gradlew build’ın çalıştırılmasını takiben example-plugins\PLUGIN-NAME\build\libs bulunmaktadır, sol üstteki dosya sekmesine tıklayıp açılır listedeki Plugins - Eklentiler seçeneğini seçiniz.

Kişiselleştirilmiş eklentilerin elle eklenmesi

From the plugins window, choose the “Load plugin” button in the bottom right, and select your jar file.