-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mazak: initial main program for the proxy
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using MazakMachineInterface; | ||
|
||
namespace BlackMaple.FMSInsight.Mazak.Proxy; | ||
|
||
public class ProxyService : System.ServiceProcess.ServiceBase | ||
{ | ||
private ICurrentLoadActions _load; | ||
private IMazakDB _db; | ||
private IHttpServer _server; | ||
|
||
public static void Main() | ||
{ | ||
System.ServiceProcess.ServiceBase.Run(new ProxyService()); | ||
} | ||
|
||
protected override void OnStart(string[] args) | ||
{ | ||
var cfg = new MazakConfig() | ||
{ | ||
DBType = MazakDbType.MazakWeb, | ||
SQLConnectionString = "Data Source=.;Initial Catalog=SeedTacticsMazak;Integrated Security=True", | ||
LogCSVPath = @"C:\ProgramData\SeedTactics\Mazak\Logs", | ||
LoadCSVPath = @"C:\ProgramData\SeedTactics\Mazak\Load", | ||
}; | ||
_load = new LoadOperationsFromFile(cfg); | ||
_db = new OpenDatabaseKitDB(cfg, _load); | ||
_server = new HttpServer("http://*:5000/"); | ||
|
||
_server.AddLoadingHandler("/all-data", _db.LoadAllData); | ||
_server.AddPostHandler<string, MazakAllDataAndLogs>("/all-data-and-logs", _db.LoadAllDataAndLogs); | ||
_server.AddLoadingHandler("/programs", _db.LoadPrograms); | ||
_server.AddLoadingHandler("/tools", _db.LoadTools); | ||
_server.AddPostHandler<MazakWriteData, bool>( | ||
"/save", | ||
w => | ||
{ | ||
_db.Save(w); | ||
return true; | ||
} | ||
); | ||
|
||
_server.Start(); | ||
} | ||
|
||
protected override void OnStop() | ||
{ | ||
_server?.Dispose(); | ||
_load = null; | ||
_db = null; | ||
_server = null; | ||
} | ||
} |
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