-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
209 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DatawoodGH.Utility; | ||
|
||
namespace DatawoodGH.Network.SocketConnection | ||
{ | ||
public class ModFileObject | ||
{ | ||
public List<string> MovesFull { get; private set; } | ||
public Dictionary<string, string> Speeds { get; private set; } | ||
public Dictionary<string, string> Zones { get; private set; } | ||
public List<MoveObject> Voves { get; set; } | ||
|
||
/// <summary> | ||
/// Reads the modfile and puts the Moves, speeds and zones in their respective variables. | ||
/// </summary> | ||
/// <param name="path">path of the modfile</param> | ||
public ModFileObject(string path) { | ||
MovesFull = new List<string>(); | ||
Speeds = new Dictionary<string, string>(); | ||
Zones = new Dictionary<string, string>(); | ||
ReadModFile(path); | ||
} | ||
|
||
private void ReadModFile(string path) { | ||
string[] lines = System.IO.File.ReadAllLines(path); | ||
foreach (var line in lines) | ||
{ | ||
ReadMoves(line); | ||
ReadSpeeds(line); | ||
ReadZones(line); | ||
} | ||
} | ||
|
||
private void ReadMoves(string line) { | ||
if (line.Contains("MoveL") || line.Contains("MoveAbsJ")) | ||
{ | ||
MovesFull.Add(line); | ||
} | ||
} | ||
|
||
private void ReadSpeeds(string line) { | ||
if (line.Contains("speeddata")) { | ||
var startName = Utils.GetNthIndex(line, 'S', 3); | ||
var endName = line.IndexOf(':'); | ||
var speedName = line.Substring(startName, endName - startName); | ||
|
||
var startData = line.IndexOf('['); | ||
var endData = line.IndexOf(']') + 1; | ||
|
||
var speedData = line.Substring(startData, endData - startData); | ||
|
||
Speeds.Add(speedName, speedData); | ||
} | ||
} | ||
|
||
private void ReadZones(string line) { | ||
if (line.Contains("zonedata")) | ||
{ | ||
var startName = line.IndexOf('Z'); | ||
var endName = line.IndexOf(':'); | ||
var zoneName = line.Substring(startName, endName - startName); | ||
|
||
var startData = line.IndexOf('['); | ||
var endData = line.IndexOf(']') + 1; | ||
|
||
var zoneData = line.Substring(startData, endData - startData); | ||
|
||
Speeds.Add(zoneName, zoneData); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DatawoodGH.Utility; | ||
|
||
namespace DatawoodGH.Network.SocketConnection | ||
{ | ||
public class MoveAbsJObject : MoveObject | ||
{ | ||
public string RobJoint { get; set; } | ||
public MoveAbsJObject(string line, Dictionary<string, string> speeds, Dictionary<string, string> zones) : base(line, speeds, zones) | ||
{ | ||
ReadRobJoint(line); | ||
} | ||
|
||
private void ReadRobJoint(string line) { | ||
int openBracket = Utils.GetNthIndex(line, '[', 2); | ||
int closeBracket = line.IndexOf(']') + 1; | ||
|
||
RobJoint = line.Substring(openBracket, closeBracket - openBracket); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DatawoodGH.Utility; | ||
|
||
namespace DatawoodGH.Network.SocketConnection | ||
{ | ||
public class MoveLObject : MoveObject | ||
{ | ||
public string Pos { get; set; } | ||
public string Orient { get; set; } | ||
|
||
public MoveLObject(string line, Dictionary<string, string> speeds, Dictionary<string, string> zones) : base(line, speeds, zones) | ||
{ | ||
ReadPos(line); | ||
ReadOrient(line); | ||
} | ||
|
||
private void ReadPos(string line) { | ||
int openBracket = Utils.GetNthIndex(line, '[', 2); | ||
int closeBracket = line.IndexOf(']') + 1; | ||
|
||
Pos = line.Substring(openBracket, closeBracket - openBracket); | ||
} | ||
|
||
private void ReadOrient(string line) { | ||
int openBracket = Utils.GetNthIndex(line, '[', 3); | ||
int closeBracket = Utils.GetNthIndex(line, ']', 2) + 1; | ||
|
||
Orient = line.Substring(openBracket, closeBracket - openBracket); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace DatawoodGH.Network.SocketConnection | ||
{ | ||
public abstract class MoveObject | ||
{ | ||
|
||
|
||
public string Name { get; set; } | ||
public string Speed { get; set; } | ||
public string Zone { get; set; } | ||
public string ExternalJoint { get; set; } | ||
|
||
public MoveObject(string line, Dictionary<string , string> speeds, Dictionary<string, string> zones) { | ||
ReadExternalJoint(line); | ||
ReadSpeed(line, speeds); | ||
ReadZone(line, zones); | ||
} | ||
|
||
private void ReadExternalJoint(string line) { | ||
int openBracket = line.LastIndexOf('['); | ||
int closeBracket = line.LastIndexOf(']'); | ||
ExternalJoint = line.Substring(openBracket, closeBracket - openBracket); | ||
} | ||
|
||
private void ReadSpeed(string line, Dictionary<string, string> speeds) { | ||
string[] values = line.Split(','); | ||
string speedKey = null; | ||
foreach (var value in values) | ||
{ | ||
if (value.Contains("Speed")) | ||
{ | ||
speedKey = value; | ||
} | ||
} | ||
|
||
speeds.TryGetValue(speedKey, out string speedValue); | ||
|
||
Speed = speedValue; | ||
} | ||
|
||
private void ReadZone(string line, Dictionary<string, string> zones) { | ||
string[] values = line.Split(','); | ||
string zoneKey = null; | ||
foreach (var value in values) | ||
{ | ||
if (value.Contains("Zone")) | ||
{ | ||
zoneKey = value; | ||
} | ||
} | ||
|
||
zones.TryGetValue(zoneKey, out string zoneValue); | ||
|
||
Zone = zoneValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters