-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPortManager.cs
60 lines (48 loc) · 1.36 KB
/
PortManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
*-VR-Shield Project-*
hard and software system that simplifies linking i2c sensors to other systems over bluetooth
*Required hardware: ESP32-Wroom32 Dev Board C, Custom VR-Shield PCB (v03 or up)
*Supported sensors: MPU6050, QMC5883L, BH1750 (Attached using VR-Dapter board)
@author MWehning
@version 3.0 22/04/2023
*/
using System;
using System.Collections.Generic;
using System.Drawing.Text;
using System.Text;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
public class PortManager : MonoBehaviour
{
[SerializeField]
private List<PortDescr> portDescriptions;
//private bool scanPort = false;
private static List<Port> ports;
private static List<Device> devices;
private void Awake()
{
ports = new List<Port>();
devices = new List<Device>();
foreach (PortDescr portDescription in portDescriptions)
{
Port port = new Port(portDescription.portName, portDescription.portNumber, portDescription.mcuID);
ports.Add(port);
foreach (DeviceDescr deviceDescription in portDescription.devices)
{
Device device = new Device(port,deviceDescription.deviceName, deviceDescription.stringDeviceAddress);
devices.Add(device);
}
}
}
public static Device GetDevice(string deviceName)
{
foreach (Device device in devices)
{
if (device.deviceName == deviceName)
{
return device;
}
}
return null;
}
}