File: main_example.c

package info (click to toggle)
poti 5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 372 kB
  • sloc: ansic: 1,189; perl: 1,140; makefile: 24
file content (73 lines) | stat: -rw-r--r-- 2,735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
    This file is part of Poti

    Poti is free software: you can redistribute it and/or modify
    it under the terms of the GNU Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Poti is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Public License for more details.

    You should have received a copy of the GNU Public License
    along with Poti. If not, see <http://www.gnu.org/licenses/>.
*/
#include <poti.h>

int main (int argc, char **argv)
{
  //A call to poti_init() is equivalent to:
  poti_init_custom (NULL,  //empty file name so stdout is chosen
		    false, //so, allow extended events
		    false, //so, output a modern header (with new field names)
		    false,  //with comments (lines starting with #)
		    true,  //events have aliases
		    true); //relative timestamps

  //first, dump the pajeheader
  poti_header ();

  //Defining my types
  poti_DefineContainerType ("ROOT", "0", "ROOT");
  poti_DefineContainerType("THREAD", "ROOT", "THREAD");
  poti_DefineStateType("STATE", "THREAD", "STATE");
  poti_DefineLinkType("LINK", "ROOT", "THREAD", "THREAD", "LINK");

  //define values and color for the STATE type
  poti_DefineEntityValue("r", "STATE", "running", "0.0 1.0 0.0");
  poti_DefineEntityValue("i", "STATE", "idle", "0.3 0.3 0.3");

  //define values and color for the LINK type
  poti_DefineEntityValue("c", "LINK", "communication", "1 0 0");

  //Create my root container and containers for two threads
  poti_CreateContainer (0.01, "root", "ROOT", "0", "root");
  poti_CreateContainer (0.12, "thread-0", "THREAD", "root", "thread-0");
  poti_CreateContainer (0.23, "thread-1", "THREAD", "root", "thread-1");
  
  //Start a link from thread-0
  poti_StartLink (0.24, "root", "LINK", "thread-0", "c", "myKey-001");

  //Push and Pop two states for each thread
  poti_PushState (0.34, "thread-0", "STATE", "r");
  poti_PushState (0.45, "thread-1", "STATE", "r");
  poti_PopState  (0.56, "thread-0", "STATE");
  poti_PushState (0.67, "thread-0", "STATE", "i");
  poti_PopState  (0.78, "thread-1", "STATE");
  poti_PushState (0.89, "thread-1", "STATE", "i");
  poti_PopState  (0.90, "thread-0", "STATE");
  poti_PopState  (1.01, "thread-1", "STATE");

  //End the link at thread-1
  poti_EndLink (1.02, "root", "LINK", "thread-1", "c", "myKey-001");

  //Closing containers
  poti_DestroyContainer (1.12, "THREAD", "thread-0");
  poti_DestroyContainer (1.23, "THREAD", "thread-1");
  poti_DestroyContainer (1.34, "ROOT", "root");

  poti_close();
  return 0;
}