├── .gitignore
├── 3rdpartylicenses.txt
├── LICENSE
├── README.md
├── README.txt
├── VMCProtocolMonitor.sln
├── VMCProtocolMonitor
├── App.config
├── HTTP.cs
├── Main.cs
├── OSC.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Setting.cs
├── VMCProtocolMonitor.csproj
├── packages.config
└── setting.json
├── index.htm
├── script.js
├── setting.json
└── worker.js
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/3rdpartylicenses.txt:
--------------------------------------------------------------------------------
1 | Rug.Osc.1.2.5
2 | Copyright (C) 2013 Phill Tew (peatew@gmail.com)
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
10 | --------------------------
11 | Newtonsoft.Json.12.0.3
12 |
13 | The MIT License (MIT)
14 |
15 | Copyright (c) 2007 James Newton-King
16 |
17 | Permission is hereby granted, free of charge, to any person obtaining a copy of
18 | this software and associated documentation files (the "Software"), to deal in
19 | the Software without restriction, including without limitation the rights to
20 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
21 | the Software, and to permit persons to whom the Software is furnished to do so,
22 | subject to the following conditions:
23 |
24 | The above copyright notice and this permission notice shall be included in all
25 | copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
29 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
30 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
31 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 gpsnmeajp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VMCProtocolMonitor
2 | [VMCProtocol](https://sh-akira.github.io/VirtualMotionCaptureProtocol/)の受信内容を表示するソフトウェア。
3 | ごく単純に受信内容をコンソールに流すモードと、VMCProtocolに基づいてブラウザに一覧表示するモードがあります。
4 |
5 | **[ダウンロード](https://github.com/gpsnmeajp/VMCProtocolMonitor/releases)**
6 |
7 | [VMC Protocol対応](https://sh-akira.github.io/VirtualMotionCaptureProtocol/)
8 |
9 |
10 | ## 現在利用可能な機能
11 | - Streamモード(コンソールで閲覧)
12 | - Listモード(ブラウザで閲覧)
13 |
14 | ## 設定
15 | - setting.jsonにて、待受ポートを設定します。
16 | - ListModeをtrueにするとListモードになります。ブラウザ(既定で http://127.0.0.1:8888/ )に一覧で表示します。
17 | - ListModeをfalseにするとStreamモードです。コンソールに受信したそのまま表示します。(この場合HTTPサーバーは起動しません)
18 | - VMCProtocolMonitor.exeを起動すると待受状態になります。
19 | - VMCProtocol v2.5を前提にしています。
20 | - /index.htm, /script.js, /worker.js, /style.cssの中身は変更可能です。これ以外のファイル名については読み込みを行いません。
21 | - /list.dat は受信データを表すための仮想的なファイルです。javascriptから読み込んで表示する前提です。
22 |
23 | # [お問合せ先(Discordサーバー)](https://discord.gg/nGapSR7)
24 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | See below page.
2 | https://github.com/gpsnmeajp/VMCProtocolMonitor
3 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30011.22
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMCProtocolMonitor", "VMCProtocolMonitor\VMCProtocolMonitor.csproj", "{C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {C974F34C-3202-4D9C-AA27-9504DD99E2ED}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/HTTP.cs:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2020 gpsnmeajp
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | using System;
25 | using System.Threading;
26 | using System.IO;
27 | using System.Net;
28 | using System.Collections.Generic;
29 | using System.Linq;
30 | using System.Text;
31 | using System.Threading.Tasks;
32 |
33 | namespace VMCProtocolMonitor
34 | {
35 | class HTTP : IDisposable
36 | {
37 | HttpListener listener;
38 | Thread thread = null;
39 | string adr = "";
40 | string responseBody = "{}";
41 | public void SetResponse(string res) {
42 | responseBody = res;
43 | }
44 |
45 | public HTTP(string adr)
46 | {
47 | this.adr = adr;
48 | listener = new HttpListener();
49 | listener.Prefixes.Add(adr);
50 |
51 | Console.WriteLine("### View server started on "+adr);
52 | listener.Start();
53 |
54 | //受信処理スレッド
55 | thread = new Thread(new ThreadStart(ReceiveThread));
56 | thread.Start();
57 |
58 | }
59 | private void ReceiveThread()
60 | {
61 | while (listener.IsListening) {
62 | HttpListenerContext context = listener.GetContext();
63 | HttpListenerRequest request = context.Request;
64 |
65 | //Console.WriteLine(request.Url.LocalPath);
66 |
67 | HttpListenerResponse response = context.Response;
68 | string res = "";
69 |
70 | try
71 | {
72 | switch (request.Url.LocalPath) {
73 | case "/":
74 | res = File.ReadAllText("index.htm", new UTF8Encoding(false));
75 | break;
76 | case "/list.dat":
77 | res = responseBody;
78 | break;
79 | case "/script.js":
80 | res = File.ReadAllText("script.js", new UTF8Encoding(false));
81 | break;
82 | case "/worker.js":
83 | res = File.ReadAllText("worker.js", new UTF8Encoding(false));
84 | break;
85 | case "/style.css":
86 | res = File.ReadAllText("style.css", new UTF8Encoding(false));
87 | break;
88 | default:
89 | res = "404 Not found";
90 | response.StatusCode = 404;
91 | break;
92 | }
93 | }
94 | catch (Exception e)
95 | {
96 | response.StatusCode = 500;
97 | res = "Internal Server Error";
98 | Console.WriteLine(e);
99 | }
100 |
101 | byte[] buf = new UTF8Encoding(false).GetBytes(res);
102 | response.OutputStream.Write(buf, 0, buf.Length);
103 | response.OutputStream.Close();
104 |
105 | Thread.Sleep(30);
106 | }
107 | }
108 |
109 | public void Dispose()
110 | {
111 | listener.Close();
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/Main.cs:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2020 gpsnmeajp
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | using System;
25 | using System.IO;
26 | using System.Threading;
27 | using System.Collections.Generic;
28 | using System.Linq;
29 | using System.Text;
30 | using System.Threading.Tasks;
31 | using Rug.Osc;
32 | using Newtonsoft.Json;
33 | /*
34 | * InputJson : 入力ポートと入力名
35 | * OutputJson : 出力ポートと入力名
36 | * Filter Json: 振り分け法則(入力名-フィルタ-出力名)
37 | */
38 |
39 | namespace VMCProtocolMonitor
40 | {
41 | class Main
42 | {
43 | const string version = "VMCProtocolMonitor v0.01";
44 | Setting setting;
45 | OSC osc;
46 |
47 | SortedDictionary packets = new SortedDictionary();
48 |
49 | public void Process()
50 | {
51 | Console.WriteLine("### "+ version);
52 | //---------サーバー開始------------
53 | try
54 | {
55 | StartServer();
56 |
57 | if (setting.ListMode)
58 | {
59 | ListMode();
60 | }
61 | else {
62 | StreamMode();
63 | }
64 | }
65 | catch (Exception e)
66 | {
67 | Console.WriteLine("# MainThread : " + e);
68 | }
69 |
70 | //---------サーバー停止------------
71 | try
72 | {
73 | StopServer();
74 | }
75 | catch (Exception e)
76 | {
77 | Console.WriteLine("# MainThread : " + e);
78 | }
79 |
80 | Console.WriteLine("Press ENTER key to close window");
81 | Console.ReadLine();
82 | }
83 |
84 | private void StreamMode()
85 | {
86 | Console.WriteLine("Press ENTER key to stop server");
87 | Console.ReadLine();
88 | }
89 | private void ListMode()
90 | {
91 | bool exit = false;
92 | HTTP http = new HTTP("http://127.0.0.1:"+setting.HttpPort+"/");
93 |
94 | Console.WriteLine("### Press ENTER key to stop server");
95 |
96 | while (!exit)
97 | {
98 | string responce = "";
99 |
100 | List> view = packets.ToList();
101 | for (int i = 0; i < view.Count; i++) {
102 | responce += ("# "+view[i].Value)+"\n";
103 | }
104 | http.SetResponse(responce);
105 |
106 | if (Console.KeyAvailable)
107 | {
108 | if (Console.ReadKey(true).Key == ConsoleKey.Enter)
109 | {
110 | exit = true;
111 | }
112 | }
113 |
114 | Thread.Sleep(500);
115 | }
116 | http.Dispose();
117 | }
118 |
119 | private void StartServer()
120 | {
121 | setting = JsonConvert.DeserializeObject(File.ReadAllText("setting.json", new UTF8Encoding(false)));
122 | Console.WriteLine("# Setting loaded");
123 |
124 | osc = new OSC(setting.Port, OnBundle, OnMessage);
125 | Console.WriteLine("# Listen on Port : "+setting.Port);
126 | }
127 | private void StopServer()
128 | {
129 | osc.Dispose();
130 | }
131 |
132 | private void OnMessage(OscMessage message) {
133 | if (setting.ListMode)
134 | {
135 | packets[MakeKeyOfMessage(message)] = message;
136 | }
137 | else {
138 | Console.WriteLine("## " + message);
139 | }
140 | }
141 | private void OnBundle(OscBundle bundle) {
142 | if (!setting.ListMode)
143 | {
144 | Console.WriteLine("## Bundle begin");
145 | }
146 | for (int i = 0; i < bundle.Count; i++) {
147 | switch (bundle[i])
148 | {
149 | //Messageを受信した
150 | case OscMessage msg:
151 | if (setting.ListMode)
152 | {
153 | packets[MakeKeyOfMessage(msg)] = msg;
154 | }
155 | else {
156 | Console.WriteLine("# " + msg);
157 | }
158 | break;
159 | default:
160 | //Do noting
161 | break;
162 | }
163 | }
164 | }
165 |
166 | private string MakeKeyOfMessage(OscMessage msg) {
167 | if (msg.Count >= 1)
168 | {
169 | //長さが1以上の場合は、1番目の要素も含む(VMCProtocolに基づく)
170 | //ただし1番目の要素が大きく変動するものに関しては除外する
171 | //2番目がキーになっているのにに関してはそういう扱いをする
172 | switch (msg.Address) {
173 | //変化除外
174 | case "/VMC/Ext/OK":
175 | case "/VMC/Ext/T":
176 | case "/VMC/Ext/Rcv":
177 | case "/VMC/Ext/VRM":
178 | case "/VMC/Ext/Opt":
179 | case "/VMC/Ext/Setting/Color":
180 | case "/VMC/Ext/Setting/Win":
181 | case "/VMC/Ext/Config":
182 |
183 | case "/VMC/Ext/Set/Period":
184 | case "/VMC/Ext/Set/Eye":
185 | case "/VMC/Ext/Set/Res":
186 | case "/VMC/Ext/Set/Calib/Exec":
187 | case "/VMC/Ext/Set/Config":
188 | return msg.Address;
189 |
190 | //特殊変化(2番目)
191 | case "/VMC/Ext/Con": // //VMC/Ext/Con (int){active} (string){name} (int){IsLeft} (int){IsTouch} (int){IsAxis} (float){Axis.x} (float){Axis.y} (float){Axis.z}
192 | case "/VMC/Ext/Key": // /VMC/Ext/Key (int){active} (string){name} (int){keycode}
193 | if (msg.Count >= 2)
194 | {
195 | return msg.Address + msg[1].ToString();
196 | }
197 | else
198 | {
199 | return msg.Address;
200 | }
201 | //特殊変化(3番目)
202 | case "/VMC/Ext/Midi/Note": // /VMC/Ext/Midi/Note (int){active} (int){channel} (int){note} (float){velocity}
203 |
204 | if (msg.Count >= 3)
205 | {
206 | return msg.Address + msg[2].ToString();
207 | }
208 | else
209 | {
210 | return msg.Address;
211 | }
212 |
213 | default:
214 | return msg.Address + msg[0].ToString();
215 | }
216 | }
217 | else {
218 | //長さ0の場合はアドレスのみ
219 | return msg.Address;
220 | }
221 | }
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/OSC.cs:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2020 gpsnmeajp
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | using System;
25 | using System.Threading;
26 | using System.Collections.Generic;
27 | using System.Linq;
28 | using System.Text;
29 | using System.Threading.Tasks;
30 | using Rug.Osc;
31 |
32 | namespace VMCProtocolMonitor
33 | {
34 | class OSC : IDisposable
35 | {
36 | //イベント打ち上げ用
37 | public Action OnBundle = null;
38 | public Action OnMessage = null;
39 |
40 | public long PacketCounter = 0;
41 |
42 | //受信処理用
43 | OscReceiver oscReceiver = null;
44 | Thread thread = null;
45 | public int Port;
46 |
47 | //受信待受開始
48 | public OSC(int port, Action OnBundle, Action OnMessage)
49 | {
50 | this.Port = port;
51 | this.OnBundle = OnBundle;
52 | this.OnMessage = OnMessage;
53 |
54 | //受信待受
55 | oscReceiver = new OscReceiver(this.Port);
56 | oscReceiver.Connect();
57 |
58 | //受信処理スレッド
59 | thread = new Thread(new ThreadStart(ReceiveThread));
60 | thread.Start();
61 |
62 | //例外は上位に打ち上げる
63 | }
64 |
65 | //受信待受停止
66 | public void Dispose()
67 | {
68 | //待受停止
69 | try {
70 | oscReceiver?.Close();
71 | }
72 | finally{
73 | //Thread終了を待機
74 | thread?.Join();
75 | }
76 | }
77 |
78 | //受信Thread
79 | private void ReceiveThread()
80 | {
81 | try
82 | {
83 | //ソケットが閉じていない間受信を続ける
84 | while (oscReceiver.State != OscSocketState.Closed)
85 | {
86 | //接続状態なら処理を行う
87 | if (oscReceiver.State == OscSocketState.Connected)
88 | {
89 | //受信を行う
90 | var packet = oscReceiver.Receive();
91 | ProcessPacket(packet);
92 | }
93 | else
94 | {
95 | //接続されていない場合は待つ
96 | Thread.Sleep(16);
97 | }
98 | }
99 |
100 | }
101 | catch (Exception e)
102 | {
103 | //ソケットが閉じられた例外のときは無視する
104 | if (e.Message != "The receiver socket has been disconnected")
105 | {
106 | Console.WriteLine("# ReceiveThread : " + e);
107 | }
108 | }
109 | }
110 | //パケットを処理して、bundleとMessageに振り分け
111 | private void ProcessPacket(OscPacket packet)
112 | {
113 | PacketCounter++;
114 | switch (packet)
115 | {
116 | //bundleを受信した
117 | case OscBundle bundle:
118 | try
119 | {
120 | OnBundle?.Invoke(bundle);
121 | }
122 | catch (Exception e)
123 | {
124 | Console.WriteLine("# Callback : " + e);
125 | }
126 | break;
127 | //Messageを受信した
128 | case OscMessage msg:
129 | try
130 | {
131 | OnMessage?.Invoke(msg);
132 | }
133 | catch (Exception e)
134 | {
135 | Console.WriteLine("# Callback : " + e);
136 | }
137 | break;
138 | default:
139 | //Do noting
140 | break;
141 | }
142 | }
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2020 gpsnmeajp
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Linq;
27 | using System.Text;
28 | using System.Threading.Tasks;
29 |
30 | namespace VMCProtocolMonitor
31 | {
32 | class Program
33 | {
34 | static void Main(string[] args)
35 | {
36 | new Main().Process();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // 制御されます。アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更します。
8 | [assembly: AssemblyTitle("VMCProtocolMonitor")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("VMCProtocolMonitor")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
18 | // 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
19 | // その型の ComVisible 属性を true に設定します。
20 | [assembly: ComVisible(false)]
21 |
22 | // このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
23 | [assembly: Guid("c9b3455d-9897-42e7-a5b6-3c1bfc3dfd01")]
24 |
25 | // アセンブリのバージョン情報は次の 4 つの値で構成されています:
26 | //
27 | // メジャー バージョン
28 | // マイナー バージョン
29 | // ビルド番号
30 | // リビジョン
31 | //
32 | // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/Setting.cs:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright (c) 2020 gpsnmeajp
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | using System;
25 | using System.Collections.Generic;
26 | using System.Linq;
27 | using System.Text;
28 | using System.Threading.Tasks;
29 |
30 | namespace VMCProtocolMonitor
31 | {
32 | class Setting
33 | {
34 | public int Port { get; set; }
35 | public bool ListMode { get; set; }
36 | public int HttpPort { get; set; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/VMCProtocolMonitor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C9B3455D-9897-42E7-A5B6-3C1BFC3DFD01}
8 | Exe
9 | VMCProtocolMonitor
10 | VMCProtocolMonitor
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
38 |
39 |
40 | ..\packages\Rug.Osc.1.2.5\lib\Rug.Osc.dll
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/VMCProtocolMonitor/setting.json:
--------------------------------------------------------------------------------
1 | {
2 | "Port": 39539,
3 | "ListMode": true
4 | }
--------------------------------------------------------------------------------
/index.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | VMCProtocolMonitor
7 |
8 |
9 | VMCProtocolMonitor
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var view = document.getElementById ("view");
3 |
4 | if (!window.Worker) {
5 | alert("Web Worker disabled! Editor won't work!")
6 | }var worker;
7 |
8 | try {
9 | worker = new Worker("worker.js");
10 | }catch (e) {
11 | addStat("Exception!(UI): "+e.message);
12 | }
13 |
14 | worker.onmessage = function(e) {
15 | view.innerHTML = e.data;
16 | };
17 |
18 | setInterval(function(){
19 | worker.postMessage("Doit");
20 | }, 500);
21 |
--------------------------------------------------------------------------------
/setting.json:
--------------------------------------------------------------------------------
1 | {
2 | "Port": 39539,
3 | "ListMode": true,
4 | "HttpPort": 8888
5 | }
--------------------------------------------------------------------------------
/worker.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | onmessage = function(e) {
3 | var xhr = new XMLHttpRequest();
4 | xhr.open("GET" , "/list.dat", false);//同期Request
5 | xhr.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
6 | xhr.timeout = 1000;
7 | try {
8 | xhr.send();
9 | }catch (e) {
10 | postMessage(e.message);
11 | }
12 |
13 | //---return stat---
14 | if(xhr.readyState != 4)
15 | {
16 | postMessage("load failed.");
17 | return -1;
18 | }
19 | if(xhr.status == 0){
20 | postMessage("internal Error (EMPTY RESPONSE / CONNECTION REFUSED / etc...)");
21 | return -1;
22 | }
23 | postMessage(xhr.responseText);
24 | }
--------------------------------------------------------------------------------