Skip to content

Commit d6f8be9

Browse files
Matěj Račinskýbarcharcraz
authored andcommitted
Inifile and fixes (#21)
* Bugfixes, typos fixes and coding style. Added column "created" to each table in PostgreSQL, which defaults to now(), so does not BC break. * Added reading configuration from file and added logging to file.
1 parent 1312292 commit d6f8be9

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

managed/GTAVision.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Database]
2+
ConnectionString=Server=127.0.0.1;Port=5432;Database=postgres;User Id=postgres;Password=postgres;
3+
[Snapshots]
4+
OutputDir=D:\GTAV_extraction_output\
5+
LogFile=D:\GTAV_extraction_output\log.txt

managed/GTAVisionExport/VisionExport.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class VisionExport : Script
4747
#endif
4848
//private readonly string dataPath =
4949
// Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Data");
50-
private readonly string dataPath = @"Z:\archives\";
50+
private readonly string dataPath;
51+
private readonly string logFilePath;
5152
private readonly Weather[] wantedWeather = new Weather[] {Weather.Clear, Weather.Clouds, Weather.Overcast, Weather.Raining, Weather.Christmas};
5253
private Player player;
5354
private string outputPath;
@@ -68,19 +69,23 @@ class VisionExport : Script
6869
private StereoCamera cams;
6970
public VisionExport()
7071
{
72+
// loading ini file
73+
var parser = new FileIniDataParser();
74+
var location = AppDomain.CurrentDomain.BaseDirectory;
75+
var data = parser.ReadFile(Path.Combine(location, "GTAVision.ini"));
76+
77+
//UINotify(ConfigurationManager.AppSettings["database_connection"]);
78+
dataPath = data["Snapshots"]["OutputDir"];
79+
logFilePath = data["Snapshots"]["LogFile"];
80+
81+
System.IO.File.WriteAllText(logFilePath, "VisionExport constructor called.\n");
7182
if (!Directory.Exists(dataPath)) Directory.CreateDirectory(dataPath);
7283
PostgresExport.InitSQLTypes();
7384
player = Game.Player;
7485
server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
7586
server.Bind(new IPEndPoint(IPAddress.Loopback, 5555));
7687
server.Listen(5);
7788
//server = new UdpClient(5555);
78-
var parser = new FileIniDataParser();
79-
var location = AppDomain.CurrentDomain.BaseDirectory;
80-
var data = parser.ReadFile(Path.Combine(location, "GTAVision.ini"));
81-
var access_key = data["aws"]["access_key"];
82-
var secret_key = data["aws"]["secret_key"];
83-
//client = new AmazonS3Client(new BasicAWSCredentials(access_key, secret_key), RegionEndpoint.USEast1);
8489
//outputPath = @"D:\Datasets\GTA\";
8590
//outputPath = Path.Combine(outputPath, "testData.yaml");
8691
//outStream = File.CreateText(outputPath);
@@ -99,7 +104,10 @@ public VisionExport()
99104

100105
private void handlePipeInput()
101106
{
102-
//UI.Notify(server.Available.ToString());
107+
System.IO.File.AppendAllText(logFilePath, "VisionExport handlePipeInput called.\n");
108+
UI.Notify("handlePipeInput called");
109+
UI.Notify("server connected:" + server.Connected.ToString());
110+
UI.Notify(connection == null ? "connection is null" : "connection:" + connection.ToString());
103111
if (connection == null) return;
104112

105113
byte[] inBuffer = new byte[1024];
@@ -490,6 +498,7 @@ public void TraverseWeather()
490498

491499
public void OnKeyDown(object o, KeyEventArgs k)
492500
{
501+
System.IO.File.AppendAllText(logFilePath, "VisionExport OnKeyDown called.\n");
493502
if (k.KeyCode == Keys.PageUp)
494503
{
495504
postgresTask?.Wait();

0 commit comments

Comments
 (0)