Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkeller34 committed Oct 24, 2016
1 parent 514403a commit 6b103be
Show file tree
Hide file tree
Showing 18 changed files with 412 additions and 70 deletions.
6 changes: 6 additions & 0 deletions docs/build/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Many if not all of the functions detailed in this API are really just convenience functions wrapped around methods in the [`ODBC.jl`](https://github.com/JuliaDB/ODBC.jl) package, with some syntax specific to how we have set up our databases.


Often a `dsn` argument is requested. You can provide `ICDataServer.dsn`.

131 changes: 131 additions & 0 deletions docs/build/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

Several configuration files should be generated and put into the `deps` directory of the ICDataServer package. These are not tracked by git as they may contain sensitive information and in any case are specific to the particular installation. These are used by [`ICDataServer.setuptables`](config.md#ICDataServer.setuptables) to add default information.

<a id='ICDataServer.setuptables' href='#ICDataServer.setuptables'>#</a>
**`ICDataServer.setuptables`** &mdash; *Function*.



```
setuptables()
```

Initialize a database with the tables needed to run ICDataServer:

* `users`
* `servers`
* `instrumentkinds`
* `instruments`
* `jobs`
* `notes`

The creation of the tables can proceed without additional input, but in some cases it may make sense for the tables to be automatically filled with data.

If new instrument kinds are added to `deps/instrumentkinds.json`, they will be added to `instrumentkinds` table. If kinds are encountered in the database that are not in the file, they remain in the database and are not deleted.

If new users are added to `deps/users.json`, they will be "upserted" into the `users` table (users are created if necessary; if an existing user name is attempted to be inserted into the table, then that user has their info updated from the json file). Existing users not found in users.json remain in the table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/setup.jl#L1-L25' class='documenter-source'>source</a><br>


<a id='deps/config.json-1'></a>

### deps/config.json


This JSON file consists of up to four keys and largely exists to provide connection information between the database and InstrumentControl clients. Typical example:


```
{
"jobsock":"tcp://*:50001",
"dsn":"icdataserver",
}
```


Additional fields not shown in the example may include:


* "username": A username to connect to the database, if not provided when the DSN was configured.
* "password": A password to connect to the database, if not provided when the DSN was configured.


<a id='deps/instrumentkinds.json-1'></a>

### deps/instrumentkinds.json


This JSON file declares the various kinds of instruments. Its purpose is to standardize such declarations in the database. Typical example:


```
{
"kind": [
"awg",
"dcsource",
"rfsource",
"vna"
]
}
```


<a id='deps/servers.json-1'></a>

### deps/servers.json


Declaration of servers. Typical example:


```
{
"servers": [
{
"alias":"local_data",
"address":"127.0.0.1",
"port":"50002"
},
{
"alias":"local_hw",
"address":"127.0.0.1",
"port":"50003"
}
]
}
```


<a id='deps/users.json-1'></a>

### deps/users.json


Declaration of users, including contact information which may be used by the software to send alerts and notifications. Typical example:


```
{
"users": [
{
"username":"default",
"first":"No",
"last":"Name"
}, {
"username":"anotheruser",
"first":"Really",
"middle":"No",
"last":"Name",
"email":"[email protected]",
"phone":"15555551212",
"office":"Watson 5th floor"
}
]
}
```


The only required fields for each dictionary are `username`, `first`, `last`.

5 changes: 0 additions & 5 deletions docs/build/design.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

<a id='Design-1'></a>

## Design


ICDataServer.jl

45 changes: 41 additions & 4 deletions docs/build/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,57 @@ Automatic logging of measurement data and metadata.
## Installation


* Install the most recent version of [PostgreSQL](https://www.postgresql.org/download/)
* Install the 64-bit ODBC driver for PostgreSQL (on Windows, it is an optional installation prompted automatically).
* `Pkg.clone("https://github.com/painterqubits/ICDataServer.jl.git")`
Estimated burden: twenty minutes.


* Install the most recent version of [PostgreSQL](https://www.postgresql.org/download/). When setting up, a password for the default user (`postgres`) will be requested. Choose something secure.
* Following the installation, Stack Builder will open. This lets you add components to the PostgreSQL installation. Install from Database Drivers (64-bit when there is an option):

* ODBC driver (only one of the three that is currently utilized)
* JDBC driver
* Npgsql


* Now we need to make a database. Open the pgAdmin application that was installed with PostgreSQL. In the Browser tab, open Servers, then open PostgreSQL 9.6 (or whatever version was installed). This will prompt a login using the password you provided during PostgreSQL installation. After login, right-click Databases and create a database. I suggest giving it the name `icdataserver` and leaving everything else as default. Close pgAdmin.
* You need to configure a data source name (DSN) so that ICDataServer can connect to the database. Open ODBC Data Source Administrator (64-bit) which seems to be installed by default in Windows 10. Under the User DSN tab, add a new DSN with the PostgreSQL ODBC driver (Unicode if available). You'll want to enter the following details:

* Data Source: `icdataserver` (this is the DSN name)
* Database: `icdataserver` (name of the database you created in pgAdmin)
* Server: `localhost`
* Port: `5432` (or whatever you chose during PostgreSQL installation)
* Username and password as installed. Ideally a different user would be created.


* Install ICDataServer: `Pkg.clone("https://github.com/painterqubits/ICDataServer.jl.git")`


<a id='Quick-start-1'></a>

## Quick start


You need to provide some configuration files that contain the default entries for the data server. This includes things like the users, servers and their locations, and instrument details. This is detailed in the Configuration docs.


On the first run of ICDataServer, you'll need to setup tables in the database to keep track of all the information you'll be submitting to it. Press enter/return when prompted for a path to the setup files, or you can provide another path.


```
julia> using ICDataServer
julia> ICDataServer.setuptables()
julia> IC = ICDataServer; dsn = IC.dsn;
julia> IC.setuptables(dsn)
Path to directory with setup files? [defaults to ICDataServer/deps]:
C:\Users\Discord\.julia\v0.5\ICDataServer\deps
```


Now the data server can be started. It should be running before you start using `InstrumentControl`.


```
julia> IC.serve() # or @async IC.serve() to have it run in the background.
```

8 changes: 4 additions & 4 deletions docs/build/instruments.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ newinstrument(dsn, alias; make="", model="", serialnum="", kind="",
Create a new instrument named `alias` in the `instruments` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/instruments.jl#L1-L8' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/instruments.jl#L1-L8' class='documenter-source'>source</a><br>

<a id='ICDataServer.updateinstrument' href='#ICDataServer.updateinstrument'>#</a>
**`ICDataServer.updateinstrument`** &mdash; *Function*.
Expand All @@ -30,7 +30,7 @@ updateinstrument(dsn, alias; kwargs...)
Update any of the fields for an instrument named `alias`. Possible keyword arguments listed in documentation for [`ICDataServer.newinstrument`](instruments.md#ICDataServer.newinstrument).


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/instruments.jl#L18-L25' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/instruments.jl#L18-L25' class='documenter-source'>source</a><br>

<a id='ICDataServer.deleteinstrument' href='#ICDataServer.deleteinstrument'>#</a>
**`ICDataServer.deleteinstrument`** &mdash; *Function*.
Expand All @@ -44,7 +44,7 @@ deleteinstrument(dsn, alias)
Delete instrument named `alias` from the `instruments` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/instruments.jl#L32-L38' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/instruments.jl#L32-L38' class='documenter-source'>source</a><br>

<a id='ICDataServer.listinstruments' href='#ICDataServer.listinstruments'>#</a>
**`ICDataServer.listinstruments`** &mdash; *Function*.
Expand All @@ -58,7 +58,7 @@ listinstruments(dsn)
List instruments in the `instruments` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/instruments.jl#L44-L50' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/instruments.jl#L44-L50' class='documenter-source'>source</a><br>


<a id='Constraints-on-the-instruments-table-1'></a>
Expand Down
13 changes: 4 additions & 9 deletions docs/build/jobs.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@

<a id='Jobs-1'></a>

## Jobs

<a id='ICDataServer.newjob' href='#ICDataServer.newjob'>#</a>
**`ICDataServer.newjob`** &mdash; *Function*.



```
newjob(dsn, dataserver; cryostat="", uname="", device="",
nmeas=1, jobstart="", jobstop="", jobstatus=0)
newjob(dsn; cryostat="", username="", device="",
nmeas=1, jobstart="", jobstop="", jobstatus=0, dataserver="")
```

Create a new job in the `jobs` table. This function will return a `DataFrame` containing the columns `job_id` and `jobsubmit` with the inserted job id and job submission time.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/jobs.jl#L1-L10' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/jobs.jl#L7-L16' class='documenter-source'>source</a><br>

<a id='ICDataServer.updatejob' href='#ICDataServer.updatejob'>#</a>
**`ICDataServer.updatejob`** &mdash; *Function*.
Expand All @@ -30,5 +25,5 @@ updatejob(dsn, job_id; kwargs...)
Update an existing job in the `jobs` table based on its `job_id`. Specify the fields to update with keyword arguments specified in [`ICDataServer.newjob`](jobs.md#ICDataServer.newjob).


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/jobs.jl#L24-L32' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/jobs.jl#L31-L39' class='documenter-source'>source</a><br>

15 changes: 5 additions & 10 deletions docs/build/servers.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

<a id='Servers-1'></a>

## Servers

<a id='ICDataServer.newserver' href='#ICDataServer.newserver'>#</a>
**`ICDataServer.newserver`** &mdash; *Function*.

Expand All @@ -15,7 +10,7 @@ newserver(dsn, name, addr, port::Integer=-1)
Create a new server in the `servers` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/servers.jl#L1-L7' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/servers.jl#L1-L7' class='documenter-source'>source</a><br>

<a id='ICDataServer.updateserver' href='#ICDataServer.updateserver'>#</a>
**`ICDataServer.updateserver`** &mdash; *Function*.
Expand All @@ -26,10 +21,10 @@ Create a new server in the `servers` table.
updateserver(dsn, name; kwargs...)
```

Update a server in the `servers` table using keyword arguments (`name`, `addr`, `port`).
Update a server in the `servers` table using keyword arguments (`name`, `address`, `port`).


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/servers.jl#L20-L27' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/servers.jl#L20-L27' class='documenter-source'>source</a><br>

<a id='ICDataServer.deleteserver' href='#ICDataServer.deleteserver'>#</a>
**`ICDataServer.deleteserver`** &mdash; *Function*.
Expand All @@ -43,7 +38,7 @@ deleteserver(dsn, name)
Remove a server from the `servers` table by passing its `name`.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/servers.jl#L36-L42' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/servers.jl#L36-L42' class='documenter-source'>source</a><br>

<a id='ICDataServer.listservers' href='#ICDataServer.listservers'>#</a>
**`ICDataServer.listservers`** &mdash; *Function*.
Expand All @@ -57,5 +52,5 @@ listservers(dsn, name)
List all servers in the `servers` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/9a39f602079c0f0ff1289692f15e7d5ecbb4976d/src/servers.jl#L47-L53' class='documenter-source'>source</a><br>
<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/servers.jl#L47-L53' class='documenter-source'>source</a><br>

55 changes: 49 additions & 6 deletions docs/build/users.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
<a id='ICDataServer.newuser' href='#ICDataServer.newuser'>#</a>
**`ICDataServer.newuser`** &mdash; *Function*.

<a id='Users-1'></a>

## Users

```
newuser(dsn, username, name; email="", phone="", office="")
```

This function creates a new user in the `users` table of the database. E-mail, phone, office are useful for contacting users about their measurements.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/users.jl#L1-L8' class='documenter-source'>source</a><br>

<a id='ICDataServer.updateuser' href='#ICDataServer.updateuser'>#</a>
**`ICDataServer.updateuser`** &mdash; *Function*.



```
newuser
updateuser
deleteuser
listusers
updateuser(dsn, username; kwargs...)
```

Update an existing user in the `users` table, identified by `username`. Specify the fields to update with keyword arguments specified in [`ICDataServer.newuser`](users.md#ICDataServer.newuser).


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/users.jl#L30-L38' class='documenter-source'>source</a><br>

<a id='ICDataServer.deleteuser' href='#ICDataServer.deleteuser'>#</a>
**`ICDataServer.deleteuser`** &mdash; *Function*.



```
deleteuser(dsn, username)
```

Delete a user from the `users` table by providing the username.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/users.jl#L47-L53' class='documenter-source'>source</a><br>

<a id='ICDataServer.listusers' href='#ICDataServer.listusers'>#</a>
**`ICDataServer.listusers`** &mdash; *Function*.



```
listusers(dsn)
```

List all users in the `users` table.


<a target='_blank' href='https://github.com/PainterQubits/ICDataServer.jl/tree/514403a46b775984394168023f072cf132e1384b/src/users.jl#L58-L64' class='documenter-source'>source</a><br>

2 changes: 2 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ docs_dir: 'build'
pages:
- Home: index.md
- Design: design.md
- Configuration: config.md
- API:
- 'General notes': api.md
- 'Jobs': jobs.md
- 'Users': users.md
- 'Servers': servers.md
Expand Down
Loading

0 comments on commit 6b103be

Please sign in to comment.