Difference between revisions of "Development:Prana Breath API/Collections:Trainings"

From Olekdia Wiki
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<code>trainings</code>, or <code>trngs</code> - Collection that gives you an access to all trainings in the app.<br/>
+
<code>trainings</code>, or <code>trngs</code> - Collection that gives control over all [[Training_type|trainings]] in the app.<br/>
  
 
__TOC__
 
__TOC__
Line 6: Line 6:
 
== Prefix ==
 
== Prefix ==
 
* <code>pranabreath://</code> - Case-insensitive.  
 
* <code>pranabreath://</code> - Case-insensitive.  
* <code><nowiki>https://olekdia.com/pranabreath/</nowiki></code> - Case-sensitive.  
+
* <code><nowiki>https://pranabreath.olekdia.com/</nowiki></code> - Case-sensitive.
* <code><nowiki>https://pranabreath.page.link/?link=https://olekdia.com/pranabreath/</nowiki></code> - Case-sensitive.  
+
* <code><nowiki>https://pranabreath.info/</nowiki></code> - Case-sensitive.  
 +
* <code><nowiki>https://pranabreath.page.link/?link=https://pranabreath.olekdia.com/</nowiki></code> - Case-sensitive.  
  
 
== Syntax ==
 
== Syntax ==
Line 13: Line 14:
 
* <code>pranabreath://Trainings/item?[Parameter]=[Value]</code>
 
* <code>pranabreath://Trainings/item?[Parameter]=[Value]</code>
 
* <code>pranabreath://trainings/item?cmd=[Command]&[Parameter1]=[Value1]&[Parameter2]=[Value2]</code>
 
* <code>pranabreath://trainings/item?cmd=[Command]&[Parameter1]=[Value1]&[Parameter2]=[Value2]</code>
* <code><nowiki>https://olekdia.com/pranabreath/trainings?cmd=[Command]&[Parameter]=[Value]</nowiki></code> - Case-sensitive.
+
* <code><nowiki>https://pranabreath.olekdia.com/trainings?cmd=[Command]&[Parameter]=[Value]</nowiki></code> - Case-sensitive.
  
 
== Commands ==
 
== Commands ==
{| class="wikitable long-code" cellpadding="0" cellspacing="0" style="width: 100%;"
+
{| class="wikitable" cellpadding="0" cellspacing="0" style="width: 100%;"
 
|-
 
|-
 
! Command
 
! Command
Line 51: Line 52:
 
* <code>pranabreath://trainings?cmd=import&public_id=25</code> - Import training with <code>public_id</code> equals 25 which is [[Ha breathing]] training.
 
* <code>pranabreath://trainings?cmd=import&public_id=25</code> - Import training with <code>public_id</code> equals 25 which is [[Ha breathing]] training.
 
* <code>pranabreath://trainings?cmd=import&json_data={"ENTRY":"TRAINING","name":"my_training","dur_time":480,}</code> - Import the training which is a value of <code>json_data</code> parameter. The string that represents training should be encoded.
 
* <code>pranabreath://trainings?cmd=import&json_data={"ENTRY":"TRAINING","name":"my_training","dur_time":480,}</code> - Import the training which is a value of <code>json_data</code> parameter. The string that represents training should be encoded.
* <code>https://olekdia.com/pranabreath/trainings?cmd=import&json_data=%7B%22ENTRY%22%3A%22TRAINING%22%2C%22name%22%3A%22my_training%22%2C%22dur_time%22%3A480%2C%7D</code> - Same as above, but training is represented by an encoded string. It is mandatory to use with a web link.
+
* <code>https://pranabreath.olekdia.com/trainings?cmd=import&json_data=%7B%22ENTRY%22%3A%22TRAINING%22%2C%22name%22%3A%22my_training%22%2C%22dur_time%22%3A480%2C%7D</code> - Same as above, but training is represented by an encoded string. It is mandatory to use with a web link.
 
|-
 
|-
 
|  
 
|  
Line 82: Line 83:
  
 
== Parameters ==
 
== Parameters ==
{| class="wikitable long-code" cellpadding="0" cellspacing="0" style="width: 100%;"
+
{| class="wikitable" cellpadding="0" cellspacing="0" style="width: 100%;"
 
|-
 
|-
 
! Parameter
 
! Parameter
Line 91: Line 92:
 
| Name of the training.  
 
| Name of the training.  
 
* <code>pranabreath://trainings/Power?name=Energy</code> - Rename "Power" training to "Energy".
 
* <code>pranabreath://trainings/Power?name=Energy</code> - Rename "Power" training to "Energy".
* <code>https://olekdia.com/pranabreath/Trainings/5?name=Balance</code> - Rename training with ID equals 5, set name as "Balance".
+
* <code>https://pranabreath.olekdia.com/Trainings/5?name=Balance</code> - Rename training with ID equals 5, set name as "Balance".
 
|-
 
|-
 
|  
 
|  
 
==='''public_id'''===
 
==='''public_id'''===
| Indicates public id of the training. All [[Training_type|trainings in this list]] have their own ''public_id''. It is a read-only value.
+
| Indicates public id of the training. All [[Training_type|trainings in this list]] have their own ''public_id''. All ''public_id'' are [[Trng|listed here]]. It is a read-only value.
 
* <code>pranabreath://trngs?cmd=import&public_id=25</code> - Import training with <code>public_id</code> equals 25, which is [[Ha breathing]] training.
 
* <code>pranabreath://trngs?cmd=import&public_id=25</code> - Import training with <code>public_id</code> equals 25, which is [[Ha breathing]] training.
 
|-
 
|-
|  
+
|
 +
 
 
==='''trng_type'''===
 
==='''trng_type'''===
 
| Is a [[Training_kind|kind]] of the training. Value range is [0 - [[Training_kind#Breathing_session|breathing session]], 1 - [[Training_kind#Meditation|meditation]]].
 
| Is a [[Training_kind|kind]] of the training. Value range is [0 - [[Training_kind#Breathing_session|breathing session]], 1 - [[Training_kind#Meditation|meditation]]].
Line 117: Line 119:
 
or '''duration'''
 
or '''duration'''
 
| [[Training duration]], in milliseconds (if this value is set, training duration mode is be measured in amount of time). Value range is [60000, 59940000]
 
| [[Training duration]], in milliseconds (if this value is set, training duration mode is be measured in amount of time). Value range is [60000, 59940000]
* <code>https://olekdia.com/pranabreath/Trainings/1?dur_time=480000</code> - Set [[Training duration|training duration]] to 480000 millis (8 minutes) for the training with id equals 1.
+
* <code>https://pranabreath.olekdia.com/trainings/1?dur_time=480000</code> - Set [[Training duration|training duration]] to 480000 millis (8 minutes) for the training with id equals 1.
 
|-
 
|-
 
|  
 
|  
Line 128: Line 130:
 
==='''dur_prep_time'''===
 
==='''dur_prep_time'''===
 
| [[Preparing time]] duration, in milliseconds. Value range is [0, 60000]
 
| [[Preparing time]] duration, in milliseconds. Value range is [0, 60000]
* <code>https://olekdia.com/pranabreath/Trainings/Harmony?dur_prep_time=5000</code> - Set preparing time to 5 seconds for Harmony training.
+
* <code>https://pranabreath.olekdia.com/trainings/Harmony?dur_prep_time=5000</code> - Set preparing time to 5 seconds for Harmony training.
 
|-
 
|-
 
|  
 
|  

Latest revision as of 16:05, 1 April 2019

trainings, or trngs - Collection that gives control over all trainings in the app.

Prefix

  • pranabreath:// - Case-insensitive.
  • https://pranabreath.olekdia.com/ - Case-sensitive.
  • https://pranabreath.info/ - Case-sensitive.
  • https://pranabreath.page.link/?link=https://pranabreath.olekdia.com/ - Case-sensitive.

Syntax

  • pranabreath://trainings/item?cmd=[Command] - Case-insensitive.
  • pranabreath://Trainings/item?[Parameter]=[Value]
  • pranabreath://trainings/item?cmd=[Command]&[Parameter1]=[Value1]&[Parameter2]=[Value2]
  • https://pranabreath.olekdia.com/trainings?cmd=[Command]&[Parameter]=[Value] - Case-sensitive.

Commands

Command Description

list

Returns training list. Currently it is used only in console for retrieving a training list.
  • pranabreath://trainings?cmd=list
pos id public_id name
0   1  1         Clear mind
1   2  2         Relax
2   3  3         Calming
3   4  4         Power
4   5  5         Harmony
5   6  6         Anti-stress
6   7  7         Anti-appetite
7   8  8         Cigarette replace
8   9  11        Bhastrika
  • pranabreath://trainings - It is a default command if collection is defined without an item, so if we omit the command it will return the same result.

select

Select the specified training. Other than their specific effect, commands import, create and start do select as well.
  • pranabreath://trainings/Harmony?cmd=select - Select Harmony training.
  • pranabreath://trainings/Harmony - Select Harmony. Select is a default command if ?cmd= is omitted.

import

Import the specified training into the app.

create

Create the training with certain parameters. If training with such name already exists - new training will not be created. Instead all parameters will be applied to existing training.
  • pranabreath://trainings?cmd=create&name=Serenity&trng_type=1 - Create meditation named "Serenity".
  • pranabreath://trainings?cmd=create&name=4_7_8_Breathing&dur_prep_time=5000&trng_cycles={"mValues":[{"mInhaleUnit":4,"mRetainUnit":7,"mExhaleUnit":8,"mMethodsBitSet":129,"mSecPerUnit":1000}],"mKeys":[0,]} - Create training named "4_7_8_Breathing", with 5 seconds preparing time, and 4:7:8:0 ratio.

start

Starts the selected training. If there is no such training - nothing happens. But if the training with such name is featured in the training list on our wiki, it will be automatically imported and started.
  • pranabreath://trainings/Clear_mind?cmd=start - Select and start Clear mind training. Also it brings the app to foreground with Training tab selected.
  • pranabreath://trainings/Some_custom_name?cmd=start&dur_time=240000 - If there is no "Some_custom_name" in the app - nothing happens. If it exists, it starts with training duration of 4 minutes.
  • pranabreath://trainings/2?cmd=start - Select and start training with id equals 2.
  • pranabreath://trainings/Bhastrika?cmd=start - Select and start "Bhastrika" training. If there is no such training, Bhastrika is imported and started.
  • pranabreath://trainings?cmd=start&json_data={"ENTRY":"TRAINING","name":"custom_trng","dur_time":420,} - Import and start the training that is a value of json_data parameter.

delete

Delete the selected training. If there is no selected training - nothing happens.
  • pranabreath://trngs/14?cmd=delete - Delete the training with id equals 14.
  • pranabreath://trngs/Relax?cmd=delete - Delete Relax training.

info

Show the information about training on this wiki. It is applicable only for the default trainings and for the trainings importable from this wiki.
  • pranabreath://trainings/Sitkari?cmd=info - Go to the wiki page of Sitkari training.
  • pranabreath://trainings?cmd=info&public_id=25 - Go to the wiki page that has public_id equals 25, that is Ha breathing.

Parameters

Parameter Description

name

Name of the training.

public_id

Indicates public id of the training. All trainings in this list have their own public_id. All public_id are listed here. It is a read-only value.
  • pranabreath://trngs?cmd=import&public_id=25 - Import training with public_id equals 25, which is Ha breathing training.

trng_type

Is a kind of the training. Value range is [0 - breathing session, 1 - meditation].
  • pranabreath://trainings?cmd=create&name=Serenity&trng_type=1 - Create meditation named "Serenity".

pos

Position of the training in the training list.
  • pranabreath://trainings/Clear_mind?pos=9999 - Move Clear mind training to the very bottom of the list.

curr_level

Selected complexity level of a training (if applicable). Value range is [1, 5]
  • pranabreath://trngs/1?curr_level=3 - Set complexity level to "Advanced" for Clear mind training.

dur_time

or duration

Training duration, in milliseconds (if this value is set, training duration mode is be measured in amount of time). Value range is [60000, 59940000]

dur_num_cycles

or num_iterations

Training duration, in amount of cycles (if this value is set, training duration mode is be measured in amount of cycles). Value range is [1, 999]
  • pranabreath://trainings/Relax?dur_num_cycles=18 - Set training duration to 18 cycles for Relax training.

dur_prep_time

Preparing time duration, in milliseconds. Value range is [0, 60000]

dynamic

or trng_cycles

The object that represents breathing or repose cycles of the training.
  • pranabreath://trainings/15?dynamic={"mValues":[{"mInhaleUnit":1,"mExhaleUnit":1,"mSecPerUnit":6500}{"mInhaleUnit":1,"mExhaleUnit":1,"mSecPerUnit":7000}{"mInhaleUnit":1,"mExhaleUnit":1,"mSecPerUnit":7300}],"mKeys":[0,1,2,]} - Set 3 cycles with the [[Ratio_of_breath_cycle|ratio] 1:0:1:0. First cycle has 6.5 seconds per ratio unit, second - 7 seconds, and third - 7.3 seconds.

dynamic_enabled

Turns dynamic mode on. Value range is [true, false].
  • pranabreath://trainings/Harmony?dynamic_enabled=true - Enable dynamic mode for Harmony training.

time_per_unit

Time per ratio unit, measured in milliseconds. Value range is [100, 99000].

If unsigned, this value is applied for every cycle across the trainings. If it has a sign - the value is decreased or increased every next cycle. Use %2B instead of + and %2D instead of - for the URL safety.

  • pranabreath://trainings/Relax&time_per_unit=6300 - Set 6,3 seconds per ratio unit for Relax training.
  • pranabreath://trainings/Relax&time_per_unit=%2B500 - Increase seconds per ratio unit for all cycles by 0.5 seconds for Relax training. It keeps the cycle ratio in dynamic mode the same, but increases overall training complexity.

custom_chants

The custom chants of the training.
  • pranabreath://trainings?cmd=create&name=Chanting_breathing&custom_chants=["Qm9vb20%3D","VmFhYW0%3D","UmFhYW0%3D"]&dynamic={"mValues":[{"mInhaleUnit":1,"mExhaleUnit":1,"mSustainUnit":2,"mChantsBitSet":1073742800,"mSecPerUnit":3000}],"mKeys":[0,]} - Create the training with custom chants. Chants are specified as an array, and also every chant is Base64 encoded for the URL safety. In this example we set "Raaam" chant for the inhaling and "Vaaam" chant for the exhaling phases.

note

The training note.
  • pranabreath://trainings/Relax?note=VGhpcyB0cmFpbmluZyBpcyByZWFsbHkgaGVscGZ1bCBhZnRlciBsb25nIGNvbmNlbnRyYXRpb24%3D - Set the training note for Relax training. It totally replaces previous note if it exists. The note should be Base64 encoded for the URL safety.

json_data

Data of training (.trng) file for importing.
  • pranabreath://trainings?cmd=import&json_data={"ENTRY":"TRAINING","name":"my_training"}" - Import the training named "my_training".