Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/trgen.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **TriggerBox CLI** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/trgen.git
```

[![pkglnk](https://www.pkglnk.dev/badge/trgen.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/trgen)

README

TriggerBox CLI

Unity GitHub release openupm downloads

TriggerBox Banner

A Unity library that manages Ethernet socket communication with the CoSANLab TriggerBox device


Installation

You can install TRGen via OpenUPM using one of the following methods:

Using the OpenUPM CLI

If you have openupm-cli installed:

openupm add com.cosanlab.trgen


## Getting started

To install this package add this package inside the `Packages/manifest.json` file

```json
{
  "name": "OpenUPM",
  "url": "https://package.openupm.com",
  "scopes": [
    "com.cosanlab.trgen"
  ]
}

Example

using System;
using System.Collections;
using Trgen;
using UnityEngine;

public class TrgenExample : MonoBehaviour
{
  // TriggerClient instance is to be kept alive as long as you need it
  TriggerClient client;
  private String timeStr = "";
  private bool isTimerGoing;
  private string timePlaying_Str;
  private TimeSpan timePlaying;
  private float sectionCurrentTime;
    public void StopTimer()
    {
        isTimerGoing = false;
        timeStr = "00:00.0";
    }

  public async void TriggerConnect()
    {
        if (client != null && client.Connected)
            throw new InvalidOperationException("Already connected");
        else
        {
            client = new TriggerClient();
            //client.Connect();
            client.Verbosity = LogLevel.Debug;
            await client.ConnectAsync();
        }
    }

  public void TriggerSend()
  {
    if (!client.Connected)
        throw new InvalidOperationException("Connection failed");

    // Connected! (:
    client.StartTrigger(TriggerPin.NS5);
    // opzionalmente reset
    client.ResetAll(TriggerPin.AllNs);
  }

  public void TriggerSendLoop()
  {
    StartCoroutine(SendLoop());
  }

  private IEnumerator SendLoop()
  {
    if (!client.Connected)
      throw new InvalidOperationException("Connection failed");
    while (isTimerGoing)
    {
      sectionCurrentTime += Time.deltaTime;
      timePlaying = TimeSpan.FromSeconds(sectionCurrentTime);
      timePlaying_Str = timePlaying.ToString("mm':'ss'.'f");
      timeStr = timePlaying_Str;
      client.StartTrigger(TriggerPin.NS5);
      // opzionalmente reset
      client.ResetAll(TriggerPin.AllNs);
      yield return new WaitForSeconds (1);
    }
  }
}

Comments

No comments yet. Be the first!