Petriscript
PetriScript is a modeling language for Petri nets, designed by Alexandre Hamez and Xavier Renault.[1] The CPN-AMI platform provides many tools to work on Petri nets, such as verifying and model-checking tools.[2]
Originally, simple Petri nets were created through graphic design, but research conducted internally at LIP6 revealed that it was needed to automate such tasks.[3] PetriScript was designed to provide some facilities in modeling places-transition and coloured Petri nets within the CPN-AMI platform. Petriscript's main purpose is to automate modeling operations on Petri nets by merging, creating, and connecting nodes. It supports almost everything needed, such as macros, loops control, lists, and string and arithmetic expressions, and blocks intervention of the user as much as possible. Its syntax is Ada-like.
The following script produces a FIFO with three sections:
define(FIFO_SIZE,3)
define(FIFO_BASE_X,100)
define(FIFO_BASE_Y,100)
define(FIFO_STEP,120)
int $wave := 0;
for $wave in 1..FIFO_SIZE loop
create place "Slot_" & '$wave' (x FIFO_BASE_X + FIFO_STEP * $wave,
y FIFO_BASE_Y);
create place "Empty_" & '$wave' (x FIFO_BASE_X + FIFO_STEP * $wave,
y FIFO_BASE_Y + 100, marking "1");
end loop;
for $wave in 1..FIFO_SIZE+1 loop
create transition "t" & '$wave -1' & "_to_" & '$wave' (x FIFO_BASE_X + FIFO_STEP * $wave - FIFO_STEP / 2,
y FIFO_BASE_Y + 50);
if $wave < FIFO_SIZE+1 then
connect "1" transition "t" &'$wave -1' & "_to_" & '$wave' to place "Slot_" & '$wave';
connect "1" place "Empty_" & '$wave' to transition "t" &'$wave -1' & "_to_" & '$wave';
end if;
if $wave > 1 then
connect "1" transition "t" &'$wave -1' & "_to_" & '$wave' to place "Empty_" & '$wave - 1';
connect "1" place "Slot_" & '$wave - 1' to transition "t" &'$wave -1' & "_to_" & '$wave';
end if;
end loop;
set transition "t0_to_1" to (name "FIFO_Start");
set transition "t" & 'FIFO_SIZE' & "_to_" & 'FIFO_SIZE + 1' to (name "FIFO_End");
Which produces the following graph:
Here is another example that shows the power of PetriScript:
define(X,250)
define(Y,350)
define(radius,50)
define(R,150)
define(SECTIONS,15)
define(INNER_ANGLE,360/SECTIONS)
define(OUTER_ANGLE,360/(2*SECTIONS))
int $i := 0;
int $j := 0;
for $i in 1.. SECTIONS loop
create place "F" & '$i' ( x X, y Y, r radius, t $i * INNER_ANGLE);
create place "Section_" & '$i' ( x X, y Y, r R, t $i * INNER_ANGLE);
create transition "t" & '$i' & "_to_" & '$i mod SECTIONS + 1' ( x X, y Y, r R, t $i * INNER_ANGLE + OUTER_ANGLE);
end loop;
for $i in 1.. SECTIONS loop
connect place "Section_" & '$i' to transition "t"&'$i' & "_to_" & '$i mod SECTIONS + 1';
connect transition "t" & '$i' & "_to_" & '$i mod SECTIONS + 1' to place "Section_" & '$i mod SECTIONS + 1';
if $i /= 1 then
connect place "F" & '$i' to transition "t" & '$i-1' & "_to_" & '$i';
else
connect place "F1" to transition "t" & 'SECTIONS' & "_to_" & '1';
end if;
connect transition "t" &'$i mod SECTIONS + 1' & "_to_" & '($i+1) mod SECTIONS + 1' to place "F" & '$i';
end loop;
for $i in 1.. SECTIONS loop
if $i mod 3 = 0 then
set place "Section_" & '$i' to marking "1";
else
set place "F" & '$i' to marking "1";
end if;
end loop;
Which produces the following graph:
References
- ^ Alexandre Hamez; Xavier Renault. "PetriScript Reference Manual 1.0" (PDF). LIP6. Archived from the original (PDF) on 24 October 2016.
- ^ Principles of Information Systems: Computer science
- ^ Business Database Systems: Computer science, Database management
External links
Full documentation is available here.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.