Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evogelsa committed Aug 16, 2020
0 parents commit 0244c0b
Show file tree
Hide file tree
Showing 11 changed files with 610 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
secret.json
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
windows:
mkdir -p bin/windows
env GOOS=windows GOARCH=amd64 go build -o bin/windows/realweather.exe
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# DCS Real Weather Updater

## About

Replaces static weather data in DSC mission file with METAR reported data from
ICAO of choice.

Not extensively tested.

## Usage

Edit config.json and replace API key with one generated from
[checkwx](https://www.checkwxapi.com/). Update ICAO with icao of airport of your
choosing. By default the program will set the mission time to system time, but
this can be adjusted by changing the time-offset in config file to an integer.
This integer will ofset time by x hours.

Put binary into own directory with config and move "mission.miz" into directory
before executing. It will produce a new missionfile called mission.miz.

It is recommended to use an external script to call this program. An example
batch file is provided inside /examples. Note that the binary will expect the
curent working directory to be inside its parent directory.
5 changes: 5 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"api-key": "",
"icao": "",
"time-offset": 0
}
5 changes: 5 additions & 0 deletions examples/example-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"api-key": "some string from checkwx",
"icao": "UGKO",
"time-offset": 4
}
26 changes: 26 additions & 0 deletions examples/replace_mission.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off

:: Assumes following directory structure:
:: - parent-dir/
:: - Missions/
:: - backups/
:: - mission.miz
:: - realweather/
:: - realweather.exe
:: - replace_mission.bat

:: Make backup of current mission file
copy "Missions\mission.miz" "Missions\backups\mission.miz"
set d=%date:~-4,4%%date:~0,2%%date:~-7,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
rename "Missions\backups\mission.miz" "%d%_%t%_mission.miz"

:: Move mission into realweather working directory and move updated mission
:: back into missions folder
move "Missions\mission.miz" "realweather\mission.miz" :: realweather expects "mission.miz"
cd realweather :: CWD must be parent directory of binary
call realweather.exe
cd ..
move "realweather\realweather.miz" "Missions\DSMC_Gorgas_001.miz"
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/evogelsa/DCS-real-weather

go 1.14
25 changes: 25 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"github.com/evogelsa/DCS-real-weather/miz"
"github.com/evogelsa/DCS-real-weather/util"
"github.com/evogelsa/DCS-real-weather/weather"
)

func main() {
// get METAR report
data := weather.GetWeather()

// unzip mission file
_, err := miz.Unzip()
util.Must(err)

// update mission file with weather data
miz.Update(data)

// repack mission file contents and form realweather.miz output
miz.Zip()

// remove unpacked contents from directory
miz.Clean()
}
Loading

0 comments on commit 0244c0b

Please sign in to comment.