Detailed Description
This is an example of how to use the WinProp API for indoor propagation. The full example is distributed with the installation.
#include <stdio.h>
#include <string>
#include <iostream>
#include "indoor_propagation.h"
#ifndef API_DATA_FOLDER
#define API_DATA_FOLDER "../../api/winprop/data/"
#endif // !API_DATA_FOLDER
int main(int argc, char** argv)
{
int Error = 0, ProjectHandle = 0;
WinProp_Scenario WinPropScenario;
WinProp_Callback WinPropCallback;
WinProp_Area WinPropArea;
WinProp_Antenna WinPropAntenna;
WinProp_Result *PowerResult = NULL, *DelayResult = NULL, *LosResult = NULL;
WinProp_RayMatrix *RayMatrix = NULL;
WinProp_Pattern WinPropPattern;
WinProp_Additional WinPropMore;
WinProp_Propagation_Results OutputResults;
double PredictionHeight = 1.5;
WinProp_Structure_Init_Scenario(&WinPropScenario);
WinProp_Structure_Init_Area(&WinPropArea);
WinProp_Structure_Init_Antenna(&WinPropAntenna);
WinProp_Structure_Init_Pattern(&WinPropPattern);
WinProp_Structure_Init_Additional(&WinPropMore);
WinProp_Structure_Init_Propagation_Results(&OutputResults);
WinPropScenario.Scenario = WINPROP_SCENARIO_INDOOR;
WinPropScenario.VectorDatabase = API_DATA_FOLDER "../data/indoor/IndoorVectordatabase.idb";
WinPropCallback.Percentage = CallbackProgress;
WinPropCallback.Message = CallbackMessage;
WinPropCallback.Error = CallbackError;
Error = WinProp_Open(&ProjectHandle, &WinPropScenario, &WinPropCallback);
if (Error == 0) {
WinPropArea.LowerLeftX = -4.5;
WinPropArea.LowerLeftY = -44.5;
WinPropArea.UpperRightX = 101.5;
WinPropArea.UpperRightY = 43.0;
WinPropArea.Resolution = 1.0;
WinPropArea.NrHeights = 1;
WinPropArea.Heights = &PredictionHeight;
WinPropPattern.Mode = PATTERN_MODE_FILE;
WinPropPattern.Filename = API_DATA_FOLDER "antennas/Antenna.apb";
WinPropAntenna.Enabled = 1;
WinPropAntenna.Id = 1;
WinPropAntenna.Longitude_X = 60.25;
WinPropAntenna.Latitude_Y = 6.25;
WinPropAntenna.Height = 2.0;
WinPropAntenna.Model = WINPROP_MODEL_DPM;
WinPropAntenna.DataType = PROP_RESULT_POWER;
WinPropAntenna.Power = 10.0;
WinPropAntenna.Frequency = 1800.0;
WinPropAntenna.Pattern = &WinPropPattern;
WinPropAntenna.Azimuth = 270.0;
WinPropAntenna.Downtilt = 1.0;
WinPropAntenna.Name = "my_antenna_name";
WinPropMore.OutputResults = &OutputResults;
OutputResults.ResultPath = API_DATA_FOLDER "output/Indoor_Output";
OutputResults.FieldStrength = 1;
OutputResults.PathLoss = 1;
WinPropMore.ResultFiltering = 1;
Error = WinProp_Predict(ProjectHandle, &WinPropAntenna, &WinPropArea, nullptr, &WinPropMore, &PowerResult, &DelayResult, &LosResult, &RayMatrix, nullptr);
}
WinProp_Close(ProjectHandle);
return 0;
}
int _STD_CALL CallbackMessage(const char * Text)
{
if (Text == nullptr)
return 0;
std::cout << "\n" << Text;
return(0);
}
int _STD_CALL CallbackError(const char * Text, int Error)
{
if (Text == nullptr)
return 0;
std::cout << "\n";
#ifdef __LINUX
std::cout << "\033[31m" << "Error (" << Error << "): ";
#else
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
std::cout << "Error (" << Error << "): ";
#endif // __LINUX
std::cout << Text;
#ifdef __LINUX
std::cout << "\033[0m";
#else
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
#endif // __LINUX
return 0;
}
int _STD_CALL CallbackProgress(int value, const char* text)
{
char Line[200];
sprintf(Line, "\n%d%% %s", value, text);
std::cout << Line;
return(0);
}
void write_ascii(WinProp_Result Resultmatrix, char* Filename) {
FILE* OutputFile = fopen(Filename,"w");
if (OutputFile)
{
for (int x = 0; x < Resultmatrix.Columns; x++)
{
for (int y = 0; y < Resultmatrix.Lines; y++)
{
double Coordinate_X = Resultmatrix.LowerLeftX + ((double)x + 0.5) * Resultmatrix.Resolution;
double Coordinate_Y = Resultmatrix.LowerLeftY + ((double)y + 0.5) * Resultmatrix.Resolution;
if (Resultmatrix.Matrix[0][x][y] > -1000)
fprintf(OutputFile, "%.2f\t%.2f\t%.2f\n", Coordinate_X, Coordinate_Y, Resultmatrix.Matrix[0][x][y]);
}
}
fclose(OutputFile);
}
else
printf("\nCould not open the File: %s for writing.\n",Filename);
}