SFC - can I do this?

Hello!

I have to do graphic editor and translator from SFC to another language.
SCF - (Sequential Function Chart) is a graphic method of organizing the program in PLC programing.
More information about it:
http://www.software.rockwell.com/corporate/reference/Iec1131/sfc.cfm
http://itcofe.web.cern.ch/itco/Projects-Services/JCOP/ProjectTeam/Minutes/1998/18-02-98/plcprogr/sld005.htm

Now the quastion is - Can I do this using the GoDiagram?
If it’s posible then how can I make such components and links?
There’s no problem with steps, but i don’t know how make transitions, jumps and (Selection or simultaneous) Branches.
Can I make my own component using for example bmp file?

Yes, that looks not too hard to implement. Are there are other example diagrams to look at?

You might also be interested in the Flowgrammer sample and Petri nets example in Demo1: http://www.nwoods.com/forum/forum_posts.asp?TID=1818

There’s other example of SFC diagram:
http://www.kbszory.masternet.pl/diagr1.png

Single horizontal line means OR.
Double horizontal line menas AND.
Short single horizontal line is tranzition with some label (condition)
Arrows menas jumps to step

Can I do this in free edition of GoDiagram?

That depends on the implementation strategy and how much (re-)work you want to do by yourself.

I can’t still find the way to do BarNode in the free GoDiagram edition.
I’m trying to change example FlowCharter.
What should I do make this object?

Well, the following definitions in GoDiagram Win:

[code] [Serializable]
public class Transition : GoBasicNode {
public Transition() {
this.LabelSpot = MiddleRight;
this.Text = "Trans";
this.Port.Style = GoPortStyle.None;
}
protected override GoShape CreateShape(GoPort p) {
GoStroke s = new GoStroke();
s.Selectable = false;
s.Resizable = false;
s.Reshapable = false;
s.AddPoint(0, 0);
s.AddPoint(25, 0);
return s;
}
}
[Serializable]
public class Step : GoTextNode {
public Step() {
this.AutoResizes = false;
this.Brush = Brushes.White;
this.Background.Size = new SizeF(100, 50);
this.Label.Alignment = Middle;
this.Text = "Step";
}
}
[/code]
combined with executing:
[code] public void MakeSFC(GoView view) {
view.StartTransaction();
GoDocument doc = view.Document;
doc.Clear();
Step s1 = new Step();
s1.Text = "Step 1";
s1.Location = new PointF(200, 50);
doc.Add(s1);
Transition tr1 = new Transition();
tr1.Text = "Trans1";
tr1.Location = new PointF(200, 100);
doc.Add(tr1);
LinkSFC(doc, s1, tr1);
Step s2 = new Step();
s2.Text = "Step 2";
s2.Location = new PointF(200, 150);
doc.Add(s2);
LinkSFC(doc, tr1, s2);
Transition tr2 = new Transition();
tr2.Text = "Trans2";
tr2.Location = new PointF(200, 200);
doc.Add(tr2);
LinkSFC(doc, s2, tr2);
BarNode bar1 = new BarNode();
bar1.Brush = null;
bar1.Pen = Pens.Black;
bar1.Bounds = new RectangleF(125, 225, 150, 5);
doc.Add(bar1);
LinkSFC(doc, tr2, bar1);
Step s3 = new Step();
s3.Text = "Step 3";
s3.Location = new PointF(125, 275);
doc.Add(s3);
LinkSFC(doc, bar1, s3);
Step s4 = new Step();
s4.Text = "Step 4";
s4.Location = new PointF(275, 275);
doc.Add(s4);
LinkSFC(doc, bar1, s4);
BarNode bar2 = new BarNode();
bar2.Brush = null;
bar2.Pen = Pens.Black;
bar2.Bounds = new RectangleF(125, 325, 150, 5);
doc.Add(bar2);
LinkSFC(doc, s3, bar2);
LinkSFC(doc, s4, bar2);
view.FinishTransaction("created Sequential Function Chart");
}
public GoLink LinkSFC(GoDocument doc, GoNode a, GoNode b) {
GoLink l = new GoLink();
l.Orthogonal = true;
if (a is GoBasicNode) l.FromPort = ((GoBasicNode)a).Port;
else if (a is GoTextNode) l.FromPort = ((GoTextNode)a).BottomPort;
if (b is GoBasicNode) l.ToPort = ((GoBasicNode)b).Port;
else if (b is GoTextNode) l.ToPort = ((GoTextNode)b).TopPort;
doc.Add(l);
return l;
}
[/code]
produces:

How can I create jump symbol like this:

I want to have one of this examples.
Jump symbol must have:
- arrow symbol
- “in port” at the top
- label

If you don’t want to have them implemented by the arrowhead of the link, you can implement them in the same manner as the Transition node, except that the Shape would be a GoPolygon instead of a GoStroke.
If you want to have links always go into a GoBasicNode from the “top”, you can set GoBasicNode.Port.ToSpot = GoObject.MiddleTop.

I’m very grateful for your help.
There’s one more problem to
resolve.
BarNodes elements connect with another elements by means of
orthogonal (right angle) links but when I want to connect two BarNodes, then links are
often connected on strange angle.
Example:

What should I do, to repair it?

Are you sure those links have Orthogonal set to true?

When I changed orthogonal True in GraphView like this:

public override IGoLink CreateLink(IGoPort from, IGoPort to) {
IGoLink il = base.CreateLink(from, to);
if (il != null) {
GoLabeledLink l = il.GoObject as GoLabeledLink;
l.Orthogonal = true;
l.Style = GoStrokeStyle.Line;
l.ToArrow = false;

  }
  return il;
}</i>
Links are still strange:


Do you mean strange because they are not straight lines?

That's because each BarPort is choosing a point closest to the link's other node's center point. Basically, the problem is that there are an "infinite" number of places where a link could reasonably be connected between two parallel BarPorts.
You could help by specifying exactly where you want the link to be by splicing a Trans node into such a link. The Trans node need not have a Label, and its Shape could have zero size.

Maybe this picture are better to present my problem.

Bad connections:

Good connections:

Trans Nodes aren’t BarNodes, they are GoBasicNode with rectangle shape.
Only Nodes without label are BarNodes.

I think, that the problem is becouse link doesn’t known where are ports in Bar nodes.
Trans Nodes has port on the middle top of them.
How can I make that links like good this one in good connection?

That’s why I suggested you not have a direct link between BarNodes, but use a Trans node with no Label and a zero-sized shape as the intermediate node, so that you can position the vertical link where you want to.

How can I put this Trans node automatically during link creation?

Your override of CreateLink can check whether both ports are BarPorts, and if so, it can create a dummy Trans node where you want, connected by two Orthogonal GoLinks, one from the From port to the dummy node, and another from the dummy node to the To port.