aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-11-16 18:07:34 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-11-16 18:07:34 +0200
commitfc703faaa6326e28e146e00615db01c48ded0ece (patch)
tree26b8b3134ab8562d8a7bf3c04bf99b897c5c3edb /Software/Visual_Studio
parent4be586d903da2b0dbba23f4978e14ad7d51edcbf (diff)
downloadTango-fc703faaa6326e28e146e00615db01c48ded0ece.tar.gz
Tango-fc703faaa6326e28e146e00615db01c48ded0ece.zip
Implemented PMR for CCS!
First test working. Parsed and returned Calculate Stub! Implemented custom proto C compiling to achieve shorter struct names!
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs39
-rw-r--r--Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs39
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs2
3 files changed, 67 insertions, 13 deletions
diff --git a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs
index fa52eb42b..dd613ac5e 100644
--- a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs
+++ b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs
@@ -28,5 +28,44 @@ namespace Tango.Core.Helpers
return false;
}
}
+
+
+ public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs)
+ {
+ // Get the subdirectories for the specified directory.
+ DirectoryInfo dir = new DirectoryInfo(sourceDirName);
+
+ if (!dir.Exists)
+ {
+ throw new DirectoryNotFoundException(
+ "Source directory does not exist or could not be found: "
+ + sourceDirName);
+ }
+
+ DirectoryInfo[] dirs = dir.GetDirectories();
+ // If the destination directory doesn't exist, create it.
+ if (!Directory.Exists(destDirName))
+ {
+ Directory.CreateDirectory(destDirName);
+ }
+
+ // Get the files in the directory and copy them to the new location.
+ FileInfo[] files = dir.GetFiles();
+ foreach (FileInfo file in files)
+ {
+ string temppath = Path.Combine(destDirName, file.Name);
+ file.CopyTo(temppath, false);
+ }
+
+ // If copying subdirectories, copy them and their contents to new location.
+ if (copySubDirs)
+ {
+ foreach (DirectoryInfo subdir in dirs)
+ {
+ string temppath = Path.Combine(destDirName, subdir.Name);
+ CopyDirectory(subdir.FullName, temppath, copySubDirs);
+ }
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs
index 0d97c9711..57064ec9f 100644
--- a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs
+++ b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.Helpers;
namespace Tango.Protobuf.Compilers
{
@@ -39,22 +41,35 @@ namespace Tango.Protobuf.Compilers
}
/// <summary>
- /// Compiles the specified .proto message file.
+ /// Compiles all files in the specified folder recursively.
/// </summary>
- /// <param name="inputFile">.proto file to compile</param>
+ /// <param name="sourceFolder">The source folder</param>
/// <returns>
- /// A list of compiled results.
+ /// Compilation result.
/// </returns>
- //public override IEnumerable<CompilerFileResult> CompileFile(string inputFile)
- //{
- // var files = base.CompileFile(inputFile);
+ public override CompilerFolderResult CompileFolder(string sourceFolder)
+ {
+ String temp = PathHelper.GetTempFolderPath();
+ PathHelper.CopyDirectory(sourceFolder, temp, true);
+
+ List<String> directories = Directory.GetDirectories(sourceFolder, "*", SearchOption.AllDirectories).ToList();
+
+ foreach (var file in Directory.GetFiles(temp, "*.proto", SearchOption.AllDirectories))
+ {
+ String str = File.ReadAllText(file);
- // foreach (var file in files)
- // {
- // file.Name = file.Name.Replace(".pb-c", "");
- // }
+ foreach (String dir in directories.Select(x => Path.GetFileName(x)))
+ {
+ str = str.Replace(dir + ".", "");
+ }
- // return files;
- //}
+ var lines = str.ToLines();
+ lines.RemoveAll(x => x.Contains("package "));
+ str = String.Join(Environment.NewLine, lines);
+ File.WriteAllText(file, str);
+ }
+
+ return base.CompileFolder(temp);
+ }
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
index 57e3ddcad..577dd41b4 100644
--- a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
@@ -21,7 +21,7 @@ namespace Tango.MobileEM.UI
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
- Emulator = new MobileEmulator(new ProtoTransporter(new TcpTransportAdapter("127.0.0.1", 9999)));
+ Emulator = new MobileEmulator(new ProtoTransporter(new UsbTransportAdapter("COM9")));
}
}
}