UNPKG

create-gojs-kit

Version:

A CLI for downloading GoJS samples, extensions, and docs

324 lines (287 loc) 12.6 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"/> <meta name="description" content="A sequential function chart." /> <meta itemprop="description" content="A sequential function chart." /> <meta property="og:description" content="A sequential function chart." /> <meta name="twitter:description" content="A sequential function chart." /> <link rel="preconnect" href="https://rsms.me/"> <link rel="stylesheet" href="../assets/css/style.css"> <!-- Copyright 1998-2025 by Northwoods Software Corporation. --> <meta itemprop="name" content="Sequential Function Chart for Control Systems with Steps, Transitions, Parallel Branches, and Convergences" /> <meta property="og:title" content="Sequential Function Chart for Control Systems with Steps, Transitions, Parallel Branches, and Convergences" /> <meta name="twitter:title" content="Sequential Function Chart for Control Systems with Steps, Transitions, Parallel Branches, and Convergences" /> <meta property="og:image" content="https://gojs.net/latest/assets/images/screenshots/sequentialfunction.png" /> <meta itemprop="image" content="https://gojs.net/latest/assets/images/screenshots/sequentialfunction.png" /> <meta name="twitter:image" content="https://gojs.net/latest/assets/images/screenshots/sequentialfunction.png" /> <meta property="og:url" content="https://gojs.net/latest/samples/sequentialFunction.html" /> <meta property="twitter:url" content="https://gojs.net/latest/samples/sequentialFunction.html" /> <meta name="twitter:card" content="summary_large_image" /> <meta property="og:type" content="website" /> <meta property="twitter:domain" content="gojs.net" /> <title> Sequential Function Chart for Control Systems with Steps, Transitions, Parallel Branches, and Convergences | GoJS Diagramming Library </title> </head> <body> <!-- This top nav is not part of the sample code --> <nav id="navTop" class=" w-full h-[var(--topnav-h)] z-30 bg-white border-b border-b-gray-200"> <div class="max-w-screen-xl mx-auto flex flex-wrap items-start justify-between px-4"> <a class="text-white bg-nwoods-primary font-bold !leading-[calc(var(--topnav-h)_-_1px)] my-0 px-2 text-4xl lg:text-5xl logo" href="../"> GoJS </a> <div class="relative"> <button id="topnavButton" class="h-[calc(var(--topnav-h)_-_1px)] px-2 m-0 text-gray-900 bg-inherit shadow-none md:hidden hover:!bg-inherit hover:!text-nwoods-accent hover:!shadow-none" aria-label="Navigation"> <svg class="h-7 w-7 block" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"> <path d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" stroke-linecap="round" stroke-linejoin="round"/> </svg> </button> <div id="topnavList" class="hidden md:block"> <div class="absolute right-0 z-30 flex flex-col items-end rounded border border-gray-200 p-4 pl-12 shadow bg-white text-gray-900 font-semibold md:flex-row md:space-x-4 md:items-start md:border-0 md:p-0 md:shadow-none md:bg-inherit"> <a href="../learn/">Learn</a> <a href="../samples/">Samples</a> <a href="../intro/">Intro</a> <a href="../api/">API</a> <a href="../download.html">Download</a> <a href="https://forum.nwoods.com/c/gojs/11" target="_blank" rel="noopener">Forum</a> <a id="tc" href="https://nwoods.com/contact.html" target="_blank" rel="noopener" onclick="getOutboundLink('https://nwoods.com/contact.html', 'contact');">Contact</a> <a id="tb" href="https://nwoods.com/sales/index.html" target="_blank" rel="noopener" onclick="getOutboundLink('https://nwoods.com/sales/index.html', 'buy');">Buy</a> </div> </div> </div> </div> </nav> <script> window.addEventListener("DOMContentLoaded", function () { // topnav var topButton = document.getElementById("topnavButton"); var topnavList = document.getElementById("topnavList"); if (topButton && topnavList) { topButton.addEventListener("click", function (e) { topnavList .classList .toggle("hidden"); e.stopPropagation(); }); document.addEventListener("click", function (e) { // if the clicked element isn't the list, close the list if (!topnavList.classList.contains("hidden") && !e.target.closest("#topnavList")) { topButton.click(); } }); // set active <a> element var url = window .location .href .toLowerCase(); var aTags = topnavList.getElementsByTagName('a'); for (var i = 0; i < aTags.length; i++) { var lowerhref = aTags[i] .href .toLowerCase(); if (lowerhref.endsWith('.html')) lowerhref = lowerhref.slice(0, -5); if (url.startsWith(lowerhref)) { aTags[i] .classList .add('active'); break; } } } }); </script> <div class="flex flex-col prose"> <div class="w-full max-w-screen-xl mx-auto"> <!-- * * * * * * * * * * * * * --> <!-- Start of GoJS sample code --> <script src="https://cdn.jsdelivr.net/npm/gojs@3.1.0"></script> <div id="allSampleContent" class="p-4 w-full"> <script id="code"> function init() { myDiagram = new go.Diagram('myDiagramDiv', { layout: new go.LayeredDigraphLayout({ direction: 90, layerSpacing: 10, setsPortSpots: false }), 'undoManager.isEnabled': true // enable undo & redo }); // when the document is modified, add a "*" to the title and enable the "Save" button myDiagram.addDiagramListener('Modified', e => { const button = document.getElementById('SaveButton'); if (button) button.disabled = !myDiagram.isModified; const idx = document.title.indexOf('*'); if (myDiagram.isModified) { if (idx < 0) document.title += '*'; } else { if (idx >= 0) document.title = document.title.slice(0, idx); } }); // define the step Node template myDiagram.nodeTemplateMap.add('step', new go.Node('Spot', { locationSpot: go.Spot.Center }) .bindTwoWay('location', 'loc', go.Point.parse, go.Point.stringify) .add( new go.Shape('Rectangle', { fill: 'whitesmoke', stroke: 'gray', strokeWidth: 2, desiredSize: new go.Size(160, 60), portId: '', // so that links connect to the Shape, not to the whole Node fromSpot: go.Spot.BottomSide, toSpot: go.Spot.TopSide, alignment: go.Spot.Center }), new go.TextBlock({ font: 'bold 16px sans-serif', alignment: go.Spot.Center, wrap: go.Wrap.Fit, editable: true }) .bindTwoWay('text') ) ); // define the transition Node template. myDiagram.nodeTemplateMap.add('transition', new go.Node('Horizontal', { locationSpot: go.Spot.Center, locationObjectName: 'BAR' }) .bindTwoWay('location', 'loc', go.Point.parse, go.Point.stringify) .add( new go.Shape('Rectangle', { name: 'BAR', fill: 'black', stroke: null, desiredSize: new go.Size(60, 8), portId: '', fromSpot: go.Spot.BottomSide, toSpot: go.Spot.TopSide }), new go.TextBlock({ editable: true, margin: 3 }) .bindTwoWay('text') ) ); // define the parallel Node template. myDiagram.nodeTemplateMap.add('parallel', new go.Node({ locationSpot: go.Spot.Center }) .bindTwoWay('location', 'loc', go.Point.parse, go.Point.stringify) .add( new go.Shape('Rectangle', { fill: 'whitesmoke', stroke: 'black', fromSpot: go.Spot.Bottom, toSpot: go.Spot.Top, desiredSize: new go.Size(200, 6), portId: '', fromSpot: go.Spot.BottomSide, toSpot: go.Spot.TopSide }) ) ); // define the Link template myDiagram.linkTemplate = new go.Link({ routing: go.Routing.Orthogonal }) .add( new go.Shape({ stroke: 'black', strokeWidth: 2 }) ); // create the graph by reading the JSON data saved in "mySavedModel" textarea element load(); } // Show the diagram's model in JSON format function save() { document.getElementById('mySavedModel').value = myDiagram.model.toJson(); myDiagram.isModified = false; } function load() { myDiagram.model = go.Model.fromJson(document.getElementById('mySavedModel').value); } window.addEventListener('DOMContentLoaded', init); </script> <div id="sample"> <div id="myDiagramDiv" style="border: solid 1px black; width: 100%; height: 600px"></div> <p> <em>Sequential function charts</em> are used for programmable logic controllers (PLCs) and other control systems. </p> <p> You can edit text in-place by clicking on the text of a selected node. The diagram uses 3 categories of node, each added to the <a>Diagram.nodeTemplateMap</a>: <ul> <li><b>step</b></li> <li><b>transition</b></li> <li><b>parallel</b></li> </ul> </p> <p> See also the <a href="grafcet.html">grafcet diagram sample</a>. </p> <div> <div> <button id="SaveButton" onclick="save()">Save</button> <button onclick="load()">Load</button> Diagram Model saved in JSON format: </div> <textarea id="mySavedModel" style="width:100%;height:400px"> { "class": "go.GraphLinksModel", "nodeDataArray": [ {"key":"S1", "category":"step", "text":"Step 1"}, {"key":"TR1", "category":"transition", "text":"Transition 1"}, {"key":"S2", "category":"step", "text":"Step 2"}, {"key":"TR2", "category":"transition", "text":"Transition 2"}, {"key":"BAR1", "category":"parallel" }, {"key":"S3", "category":"step", "text":"Step 3"}, {"key":"S4", "category":"step", "text":"Step 4"}, {"key":"BAR2", "category":"parallel" }, {"key":"TR3", "category":"transition", "text":"Transition 3"}, {"key":"S5", "category":"step", "text":"Step 5"} ], "linkDataArray": [ {"from":"S1", "to":"TR1"}, {"from":"TR1", "to":"S2"}, {"from":"S2", "to":"TR2"}, {"from":"TR2", "to":"BAR1"}, {"from":"BAR1", "to":"S3"}, {"from":"BAR1", "to":"S4"}, {"from":"S3", "to":"BAR2"}, {"from":"S4", "to":"BAR2"}, {"from":"BAR2", "to":"TR3"}, {"from":"TR3", "to":"S5"} ]} </textarea> </div> </div> </div> <!-- * * * * * * * * * * * * * --> <!-- End of GoJS sample code --> </div> <div id="allTagDescriptions" class="p-4 w-full max-w-screen-xl mx-auto"> <hr/> <h3 class="text-xl">GoJS Features in this sample</h3> <!-- blacklist tags that do not correspond to a specific GoJS feature --> <h4>Layered Digraph Layout</h4> <p> This predefined layout is used for placing Nodes of a general directed graph in layers (rows or columns). This is more general than <a href="../api/symbols/TreeLayout.html">TreeLayout</a>, as it does not require that the graph be tree-structured. More information can be found in the <a href="../intro/layouts.html#LayeredDigraphLayout">GoJS Intro</a>. </p> <p> <a href="../samples/index.html#layered-digraph">Related samples</a> </p> <hr> <!-- blacklist tags that do not correspond to a specific GoJS feature --> </div> </div> </body> <!-- This script is part of the gojs.net website, and is not needed to run the sample --> <script src="../assets/js/goSamples.js"></script> </html>