Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Runtime/Scripts/Communication/Link/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public string Type
[SerializeField]
private string _clientPath;
[SerializeField]
private string _type;
private string _type = "FB_Device";
[SerializeField]
private Hierarchy _parent;
[SerializeField]
Expand All @@ -79,6 +79,16 @@ public string Type

protected List<ClientVariable> _variables = new();

public Link()
{

}

public Link(string type)
{
_type = type;
}

public void Initialize(Component component)
{
_component = component;
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataByte : Link
public byte ControlData;
public byte StatusData;

public LinkDataByte(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataDWord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataDWord : Link
public uint ControlData;
public uint StatusData;

public LinkDataDWord(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataFloat : Link
public float ControlData;
public float StatusData;

public LinkDataFloat(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataLWord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataLWord : Link
public long ControlData;
public long StatusData;

public LinkDataLWord(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataRobot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataRobot : Link
public float[] JointTarget = new float[12];
public float[] JointStatus = new float[12];

public LinkDataRobot(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Scripts/Communication/Link/LinkDataWord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class LinkDataWord : Link
public short ControlData;
public short StatusData;

public LinkDataWord(string type) : base(type){}

protected override List<ClientVariableDescription> GetClientVariableDescriptions()
{
var descriptions = new List<ClientVariableDescription>
Expand Down
50 changes: 11 additions & 39 deletions Runtime/Scripts/Components/Cylinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@ public class Cylinder : Actor, IDevice, ICustomInspector, IInteractable
{
public Link Link => _link;
public IProperty<bool> Override => _override;

#region Control
public IProperty<bool> Minus => _minus;
public IProperty<bool> Plus => _plus;
public IPropertyReadOnly<float> Progress => _progress;
public IPropertyReadOnly<bool> IsActive => _isActive;
public IPropertyReadOnly<bool> OnLimitMin => _onLimitMin;
public IPropertyReadOnly<bool> OnLimitMax => _onLimitMax;
public IProperty<Vector2> Limits => _limits;
public IProperty<CylinderType> Type => _type;
public IProperty<float> TimeToMin => _timeToMin;
public IProperty<float> TimeToMax => _timeToMax;

[SerializeField]
protected Property<bool> _override = new (false);
[SerializeField]
protected Property<bool> _minus = new (false);
[SerializeField]
protected Property<bool> _plus = new (false);

#endregion

#region Status

public IPropertyReadOnly<float> Progress => _progress;
public IPropertyReadOnly<bool> IsActive => _isActive;
public IPropertyReadOnly<bool> OnLimitMin => _onLimitMin;
public IPropertyReadOnly<bool> OnLimitMax => _onLimitMax;

[SerializeField]
protected Property<float> _progress = new (0);
[SerializeField]
Expand All @@ -41,16 +37,6 @@ public class Cylinder : Actor, IDevice, ICustomInspector, IInteractable
protected Property<bool> _onLimitMin = new (false);
[SerializeField]
protected Property<bool> _onLimitMax = new (false);

#endregion

#region Settings

public IProperty<Vector2> Limits => _limits;
public IProperty<CylinderType> Type => _type;
public IProperty<float> TimeToMin => _timeToMin;
public IProperty<float> TimeToMax => _timeToMax;

[SerializeField]
protected Property<Vector2> _limits = new (new Vector2(0, 100));
[SerializeField]
Expand All @@ -61,17 +47,11 @@ public class Cylinder : Actor, IDevice, ICustomInspector, IInteractable
protected Property<float> _timeToMax = new (0.5f);
[SerializeField]
private AnimationCurve _profile = AnimationCurve.Linear(0, 0, 1, 1);

#endregion

#region Events


public UnityEvent<bool> OnActiveChanged;
public UnityEvent<bool> OnLimitMinEvent;
public UnityEvent<bool> OnLimitMaxEvent;

#endregion


public bool JogMinus
{
set => _minus.Value = value;
Expand All @@ -85,7 +65,7 @@ public bool JogPlus
}

[SerializeField]
protected Link _link;
protected Link _link = new() { Type = "FB_Cylinder" };

private void Start()
{
Expand All @@ -103,14 +83,6 @@ private void OnValidate()
_plus.OnValidate();
}

public void Reset()
{
_link = new Link
{
Type = "FB_Cylinder"
};
}

private void FixedUpdate()
{
GetLinkData();
Expand Down
32 changes: 0 additions & 32 deletions Runtime/Scripts/Components/Device.cs

This file was deleted.

33 changes: 0 additions & 33 deletions Runtime/Scripts/Components/DeviceDWord.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Runtime/Scripts/Components/DeviceDWord.cs.meta

This file was deleted.

33 changes: 0 additions & 33 deletions Runtime/Scripts/Components/DeviceWord.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Runtime/Scripts/Components/DeviceWord.cs.meta

This file was deleted.

12 changes: 2 additions & 10 deletions Runtime/Scripts/Components/Drive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OC.Components
[AddComponentMenu("Open Commissioning/Actor/Drive")]
[SelectionBase]
[DisallowMultipleComponent]
public abstract class Drive : Actor, IDeviceMetadata, ICustomInspector, IInteractable, IOverride
public abstract class Drive : Actor, IDevice, IMetadataAsset, ICustomInspector, IInteractable
{
public Link Link => _link;
public IProperty<bool> Override => _override;
Expand All @@ -24,7 +24,7 @@ public abstract class Drive : Actor, IDeviceMetadata, ICustomInspector, IInterac
[SerializeField]
protected Property<bool> _override = new (false);
[SerializeField]
protected LinkDataFloat _link;
protected LinkDataFloat _link = new("FB_Drive");
[HideInInspector]
[SerializeField]
protected DriveStateObserver _stateObserver = new ();
Expand All @@ -34,14 +34,6 @@ private void Start()
_link.Initialize(this);
_stateObserver.IsActive.OnValueChanged += value => OnActiveChanged?.Invoke(value);
}

public void Reset()
{
_link = new LinkDataFloat
{
Type = "FB_Drive"
};
}

private void FixedUpdate()
{
Expand Down
10 changes: 1 addition & 9 deletions Runtime/Scripts/Components/LinkByte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,13 @@ public class LinkByte : MonoComponent, IDevice
public UnityEvent<bool> OnBit7Changed;

[SerializeField]
private LinkDataByte _link;
private LinkDataByte _link = new("FB_DeviceByte");

private void Start()
{
Link.Initialize(this);
}

public void Reset()
{
_link = new LinkDataByte
{
Type = "FB_DeviceByte"
};
}

private void Update()
{
if (!_link.Connected) return;
Expand Down
10 changes: 1 addition & 9 deletions Runtime/Scripts/Components/Robot6R.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,14 @@ public class Robot6R : MonoComponent, IDevice
[SerializeField]
protected Property<bool> _override = new (false);
[SerializeField]
private LinkDataRobot _link;
private LinkDataRobot _link = new("FB_Robot");

private readonly float[] _value = new float[12];

private void Start()
{
_link.Initialize(this);
}

private void Reset()
{
_link = new LinkDataRobot
{
Type = "FB_Robot"
};
}

private void FixedUpdate()
{
Expand Down
17 changes: 17 additions & 0 deletions Runtime/Scripts/Components/SampleDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using OC.Communication;
using UnityEngine;

namespace OC.Components
{
[SelectionBase]
[DisallowMultipleComponent]
public abstract class SampleDevice : MonoComponent, IDevice
{
public abstract Link Link { get; }
public IProperty<bool> Override => _override;
public abstract int AllocatedBitLength { get; }

[SerializeField]
protected Property<bool> _override = new (false);
}
}
Loading