Projekt

Obecné

Profil

Akce

Project architecture » Historie » Revize 20

« Předchozí | Revize 20/56 (rozdíl) | Další »
Eliška Mourycová, 2021-04-28 15:33


Project architecture

The application consists of two parts

  • Server
  • Client application

Server architecture

In the following text will be specified the architecture of and the communication between parts of the server application.

In the simple visualisation below are displayed classes that are relevant for more than one main package of the server and requests that take place between the main packages.
Main packages of the server are the following:
  • DataLoader
  • Parser
  • Model
  • Connection
  • WeatherPredictionParser
Main requests that take place within this system are:
  • Connection asks for prediction for an input from user / requests retraining of the model
  • Model asks Parser for information acquired from data
  • Parser asks DataLoader for path to folder containing data
  • Model asks WeatherPredictionParser for information about current weather prediction for today/tommorrow/day after tommorrow

Configuration

The path to data folder itself is specified from user as a command line argument upon launching the application. See configuration file.

When launching the server application a configuration file must be passed as a command line argument.

Configuration file

A configuration file must be passed as an argument to the server application when launching it. The file must contain the following lines:

  • site
  • naming_convention
  • data_root_dir
  • port

These lines must be followed by lines containing the desired values.
Default setting of the config file is as follows:

site

The site configuration specifies the website where the UWB open data can be downloaded.
It is by default set to http://openstore.zcu.cz/

naming_convention

The naming convention specifies how the archives available for download are named.
It is by default set to OD_ZCU_{type}_{month}_{year}_{format}.zip
Variables in this string must keep their name, cannot be excluded and others cannot be added. They must be enclosed in {} brackets. {} characters are treated as special characters and cannot be used as a part of the name.

data_root_dir

The data root directory specifies where the downloaded data will be stored. In this root directory subdirectories are created for individual data types.
It is by default set to .\data\auto

port

The port specifies the port number at which the part of the server listens for clients' connections.
It is by default set to 10000

Config file -> WeatherPredictionParser - specific url

DataLoader architecture

The DataLoader package takes care of downloading data from the specified website, saving them to a specified directory and providing them to the Parser.

Date class

The Date class represents a date given by a month and a year. It contains overloaded operators for comparison, these operators are >, <, >=, <=, ==, != . The date is equal if both month and year match. The date is greater than other date if it is after the other date and vice versa.
This class also provides a method for increasing a month by one. This method returns a new date with the month increased by one, possibly the year increased by one and the month set to 1 if the original month was 12.

This class is used by the DataDownloader class to be passed as an argument to various methods (see the server architecture diagram).

DataDownloader class

todo: rename to DataLoader

This class takes care of data download, storing and providing it to the Parser.
The constructor of this class takes 3 arguments

  public DataDownloader(string rootDataDir, string website, string namingConvention)

The values for these arguments are found in the configuration file - todo describe config>>>>>>>>

It provides public fields

  public string RootDataDirectory { get; }
  public Dictionary<DataType, string> DataSubDirectories { get; }
  public bool OverwriteExisting { get; set; }

Data download

Data is downloaded using the method

  public List<string> DownloadData(DataType type, DataFormat format, Date startDate, Date endDate)

Data type and format need to be specified (see enums in server architecture for supported types and formats). Also date range needs to be specified using the startDate and endDate arguments. This method then attempts to download all files falling within the range of this date span. It returns a list of full paths to all successfully saved data files.

Data retrieving

Saved data is retrieved using the method

  public List<string> GetData(string subDirectory, Date startDate, Date endDate)

The first argument specifies which subdirectory should be searched. Argumnets startDate and endDate specify the time range.
This method returns a list of full paths to all data files corresponding to the specified date range. If not enough files were found (meaning some months for the specified range are missing because they were not downloaded) and a file with month 0 exists in the directory for the year in question, then this file is returned as well.

User architecture

The User package contains a class with a method accepting user's (admin's) commands. This method runs in a separate thread from the rest of the server program. It waits for commands to be input from the command line.

Connection architecture

The Connection package takes care of receiving connection requests from clients.
The server is built with an asynchronous socket, so execution of the server application is not suspended while it waits for a connection from a client.
See https://docs.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-server-socket-example for details of used classes.

TBD - protocol and concrete behavior

Model architecture

Interface model-parser

Model can request parsing new data files. This request is done by calling the method Parse() from the class DataParser. Model specifies the time period in which it is interested (dd:mm:yyyy-dd:mm:yyyy), whether it wants to aggregate data from one day into one information piece or into how long intervals (in hours) it wants to divide the days. The information is after parsing stored into attributes WeatherList and AttendanceList of class DataParser.

WeatherList contains weather information obtained from data files, and AttendanceList contains the information about the amount of activity (jis activations and webAuth data) that took place.

For example if the request is done with parameters wholeDay set as false and intervalLength set as 3, days will be divided with a 3h interval. For each day are created entries for the following times:

  • 7-10h
  • 10-13h
  • 13-16h
  • 16-19h

Parser architecture

Parser part of the server is responsible for reading and parsing data from separate files and aggregating data in a way that was requested by model. It expects input in format specified in Data formats and outputs a relatively universal set of information.

However both output and input are dependant on specific tags used in data. If the only subject of change were these tags, then the only class that needs changing would be TagInfo. If the input data file format was changed then the class CsvDataLoader would need to be changed. If there would be different data input than jis and webauth activity then package InputInfo and Parsers would need to change. Output classes are written to be general (as general weather informationa and activity information), however if there were big changes in input or output specification (for instance new added weather input - fog) it would be better to rewrite (or accordingly modify) this whole module. As long as the interface of DataParser is respected. There is a risk that some changes might interfere with Model too because the model is to a degree dependant on given information derived from, as it extracts symptoms from this information, and we cannot predict which extra symptoms could be added.

Interesting classes (some of which were already mentioned above) to note are:

CsvLoader

Class responsible for loading input data files into memory. Can be swapped for a class processing different types of files as long as it provides the same methods.

DataParser

Class responsible for parsing the input data into information. Can be swapped for a class processing different input files as long as it provides the same methods.

TagInfo

Tags specified in this class correspond to the ones used in Data sources.

WeatherPredictionParser architecture

This part of the server application is responsible for downloading new information about current weather predictions. It is created to work with the following data source http://wttr.in/?format=j1

Specific place can be specified through a config file mentioned in a chapter above.

- TODO detailed picture of architecture ? (probably same as in "overview")

Interface Parser-DataLoader

Parser requests path to folder with data files. Further it can request from DataLoader to filter through data file names and return only those that are from a specified time period (mm:yyyy-mm:yyyy).

Loader architecture

Has to be able to handle request signaling dowload of new data, and requests for path to folder with data.

Client application architecture

Communication server-client

Aktualizováno uživatelem Eliška Mourycová před více než 3 roky(ů) · 20 revizí