├── TestCases ├── CopyFileToConsole │ ├── Resources │ │ ├── TextFile1.txt │ │ ├── fake_latin.txt │ │ └── fake_cyrillic.txt │ ├── App.config │ ├── CopyFileToConsole.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── FBPTest │ ├── mfile │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ └── Resources.Designer.cs │ ├── tune.txt │ ├── dfile │ ├── Program.cs │ ├── infqueue.fil │ └── Form1.cs ├── MergeAndSort │ ├── Properties │ │ ├── Settings.settings │ │ └── Settings.Designer.cs │ └── MergeAndSort.cs ├── Concord │ ├── Properties │ │ ├── Settings.settings │ │ ├── AssemblyInfo.cs │ │ ├── Settings.Designer.cs │ │ └── Resources.Designer.cs │ ├── resources │ │ ├── fake_latin.txt │ │ ├── fake_japanese.txt │ │ └── fake_cyrillic.txt │ ├── Concord.csproj.user │ ├── Program.cs │ ├── app.config │ ├── Form1.cs │ └── Concordance.cs ├── TestLoadBalancer │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── TestLoadBalancer.cs │ └── TestLoadBalancer.csproj └── TestLoadBalanceWithSubstreams │ ├── Properties │ └── AssemblyInfo.cs │ ├── TestLoadBalanceWithSubstreams.cs │ └── TestLoadBalanceWithSubstreams.csproj ├── docs ├── ConcordVS.png └── ConcordOutput.png ├── FBPLib ├── bin │ └── Debug │ │ └── FBPLib.dll ├── FBPLib.csproj.user ├── Lib │ ├── ComponentException.cs │ ├── Copyright.cs │ ├── MustRunAttribute.cs │ ├── SelfStartingAttribute.cs │ ├── ComponentDescriptionAttribute.cs │ ├── OutArray.cs │ ├── PriorityAttribute.cs │ ├── InPortAttribute.cs │ ├── OutPortAttribute.cs │ ├── Port.cs │ ├── Chain.cs │ ├── ConnArray.cs │ ├── TimeoutHandler.cs │ ├── NullConnection.cs │ ├── SubOut.cs │ ├── FlowError.cs │ ├── SubOutSS.cs │ ├── IInputPort.cs │ ├── PacketBuffer.cs │ └── SubIn.cs ├── Properties │ ├── Settings.settings │ ├── AssemblyInfo.cs │ └── Settings.Designer.cs ├── Settings.cs └── app.config ├── FBPVerbs ├── bin │ └── Debug │ │ └── FBPVerbs.dll ├── FBPVerbs.csproj.user ├── Properties │ └── AssemblyInfo.cs └── FBPComponents │ ├── Discard.cs │ ├── GenerateSlowly.cs │ ├── Concatenate.cs │ ├── Inject.cs │ ├── Copy.cs │ ├── Passthru.cs │ ├── GenSubStreams.cs │ ├── CleanBlob.cs │ ├── ProcessSlowly.cs │ ├── RunExe.cs │ ├── DirList.cs │ ├── Tune.cs │ ├── Output.cs │ ├── ProcessWRandDelays.cs │ ├── Splitter1.cs │ ├── LoadBalance.cs │ ├── DisplayWords.cs │ ├── Text2IntArray.cs │ ├── GenerateTestData.cs │ ├── Generate.cs │ ├── WriteToConsole.cs │ ├── Match.cs │ ├── ReplString.cs │ ├── FormatConcord.cs │ ├── GenSS.cs │ ├── ReadStreamBlob.cs │ ├── Sort.cs │ └── TextToWords.cs ├── renovate.json ├── .gitignore ├── TestNetworks ├── Networks │ ├── SubnetD.cs │ ├── SubnetX.cs │ ├── MergeAndSort.cs │ ├── Copy1.cs │ ├── CopyFileToCons.cs │ ├── TestRunExe.cs │ ├── TestNestedSubstreams.cs │ ├── TestDeadlockDetection.cs │ ├── TestTune.cs │ ├── TestNullOutputPort.cs │ ├── TestArrayPorts.cs │ ├── DropOldest.cs │ ├── TSS.cs │ ├── ReceiveFromSocket.cs │ ├── TestLoadBalanceWRandDelay.cs │ ├── TestLoadBalanceWithSubstreams.cs │ ├── Update.cs │ ├── Deadlock.cs │ ├── InfiniteQueue.cs │ ├── TestInfQueue.cs │ ├── TestLoadBalancer.cs │ ├── TestMixedInput.cs │ ├── TestPassthrus.cs │ ├── TestSockets.cs │ ├── VolumeTest.cs │ └── NoDeadlock.cs ├── TestNetworks.csproj.user └── Properties │ └── AssemblyInfo.cs ├── commands.md └── UnitTests ├── Properties └── AssemblyInfo.cs ├── StoreValues.cs ├── GenerateAndCopyTests.cs └── ReadTextTests.cs /TestCases/CopyFileToConsole/Resources/TextFile1.txt: -------------------------------------------------------------------------------- 1 | mfile... -------------------------------------------------------------------------------- /docs/ConcordVS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpaulm/csharpfbp/HEAD/docs/ConcordVS.png -------------------------------------------------------------------------------- /docs/ConcordOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpaulm/csharpfbp/HEAD/docs/ConcordOutput.png -------------------------------------------------------------------------------- /FBPLib/bin/Debug/FBPLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpaulm/csharpfbp/HEAD/FBPLib/bin/Debug/FBPLib.dll -------------------------------------------------------------------------------- /FBPVerbs/bin/Debug/FBPVerbs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpaulm/csharpfbp/HEAD/FBPVerbs/bin/Debug/FBPVerbs.dll -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "automerge": true, 6 | "major": { 7 | "automerge": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /TestCases/FBPTest/mfile: -------------------------------------------------------------------------------- 1 | 111AA11111 M 2 | 111AA22222 M 3 | 111BB44444 M 4 | 222AA11111 M 5 | 222AA22222 M 6 | 222BB22222 M 7 | 222BB33333 M 8 | 222BB44444 M 9 | 222CC11111 M -------------------------------------------------------------------------------- /TestCases/CopyFileToConsole/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /FBPLib/FBPLib.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /FBPVerbs/FBPVerbs.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /TestCases/MergeAndSort/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TestCases/FBPTest/tune.txt: -------------------------------------------------------------------------------- 1 | 330, 375, // Quarter E 2 | 330, 375, // Quarter E 3 | 330, 750, // Half E 4 | 330, 375, // Quarter E 5 | 330, 375, // Quarter E 6 | 330, 750, // Half E 7 | 330, 375, // Quarter E 8 | 392, 375, // Quarter G 9 | 262, 562, // 3/8 C 10 | 294, 188, // 1/8 D 11 | 330, 750, // 1/2 E -------------------------------------------------------------------------------- /TestCases/FBPTest/dfile: -------------------------------------------------------------------------------- 1 | 111AA11111 D 2 | 111AA11111 D 3 | 111AA11111 D 4 | 111AA22222 D 5 | 111AA22222 D 6 | 111BB44444 D 7 | 111BB44444 D 8 | 111BB55555 D 9 | 222AA22222 D 10 | 222AA22222 D 11 | 222BB22222 D 12 | 222BB22222 D 13 | 222BB44444 D 14 | 222CC11111 D 15 | 222CC11111 D 16 | 222DD11111 D 17 | 222DD22222 D -------------------------------------------------------------------------------- /FBPLib/Lib/ComponentException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FBPLib 7 | { 8 | public class ComponentException:System.ApplicationException 9 | { 10 | public ComponentException(string s) 11 | :base(s) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 2 | hs_err_pid* 3 | 4 | bin 5 | obj 6 | 7 | # Gradle 8 | .gradle 9 | 10 | # Maven packages/etc 11 | target 12 | build 13 | 14 | #VC# stuff 15 | *.suo 16 | *.exe 17 | *.sdf 18 | 19 | *.pdb 20 | *.cache 21 | *.force 22 | 23 | # IDEA project 24 | .idea/ 25 | *.iml 26 | 27 | # System's crap 28 | Thumbs.db 29 | .DS_Store 30 | -------------------------------------------------------------------------------- /TestCases/Concord/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | -------------------------------------------------------------------------------- /TestCases/Concord/resources/fake_latin.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. -------------------------------------------------------------------------------- /TestCases/CopyFileToConsole/Resources/fake_latin.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. -------------------------------------------------------------------------------- /TestCases/Concord/Concord.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | en-US 11 | false 12 | 13 | -------------------------------------------------------------------------------- /TestNetworks/Networks/SubnetD.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Components; 5 | using FBPLib; 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | [InPort("IN")] 10 | class SubnetD : SubNet 11 | { 12 | public override void Define() 13 | { 14 | _deadlockTest = true; 15 | Component("IN", typeof(SubIn)); 16 | Component("discard", typeof(Discard)); 17 | Connect("IN.OUT", "discard.IN"); 18 | Initialize("IN", "IN.NAME"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace FBPTest 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// The main entry point for the application. 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Form1()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TestNetworks/TestNetworks.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShowAllFiles 5 | 6 | 7 | 8 | 9 | 10 | 11 | en-US 12 | false 13 | 14 | -------------------------------------------------------------------------------- /TestCases/Concord/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace Concord 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// The main entry point for the application. 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Form1()); 18 | } 19 | } 20 | // force TSVN update! 21 | } -------------------------------------------------------------------------------- /FBPLib/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | False 10 | 11 | 12 | -------------------------------------------------------------------------------- /commands.md: -------------------------------------------------------------------------------- 1 | To compile FBPLib, position current directory to `GitHub\csharpfbp\FBPLib`: 2 | 3 | `csc -t:library -out:bin/Debug/FBPLib.dll -recurse:*.cs` 4 | 5 | To compile FBPVerbs, position current directory to `GitHub\csharpfbp\FBPVerbs`: 6 | 7 | `csc -t:library -r:c:\users\paul\documents\Github\csharpfbp\FBPLib/bin/Debug/FBPLib.dll -out:bin/Debug/FBPVerbs.dll Properties/*.cs FBPComponents/*.cs` 8 | 9 | To compile Concord, position current directory to `GitHub\csharpfbp`: 10 | 11 | `csc -t:exe -r:FBPLib\bin\Debug/FBPLib.dll -r:FBPVerbs\bin\Debug/FBPVerbs.dll -out:TestCases\Concord/bin/Debug/Concord.exe TestCases\Concord\Properties\*.cs TestCases\Concord\*.cs` 12 | -------------------------------------------------------------------------------- /FBPLib/Lib/Copyright.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | class Copyright 8 | { 9 | internal static string _copyright = 10 | "Copyright 2007, ... , 2011, J. Paul Morrison. At your option, you may copy, " + 11 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 12 | "based on the Everything Development Company's Artistic License. A document describing " + 13 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 14 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /FBPLib/Lib/MustRunAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | [AttributeUsage(AttributeTargets.Class)] 8 | public class MustRun : Attribute 9 | { 10 | /* * 11 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | internal bool value = true; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /FBPLib/Lib/SelfStartingAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | [AttributeUsage(AttributeTargets.Class)] 8 | public class SelfStarting : Attribute 9 | { 10 | /* * 11 | * Copyright 2007, ..., 2011, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | internal bool value = true; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TestNetworks/Networks/SubnetX.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Components; 5 | using FBPLib; 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | [OutPort("OUT")] 10 | [InPort("IN")] 11 | class SubnetX : SubNet 12 | { 13 | public override void Define() 14 | { 15 | Component("SUBIN", typeof(SubInSS)); 16 | Component("SUBOUT", typeof(SubOutSS)); 17 | Component("Pass", typeof(Passthru)); 18 | 19 | Initialize("IN", Component("SUBIN"), Port("NAME")); 20 | Connect(Component("SUBIN"), Port("OUT"), Component("Pass"), Port("IN")); 21 | Connect(Component("Pass"), Port("OUT"), Component("SUBOUT"), Port("IN")); 22 | Initialize("OUT", Component("SUBOUT"), Port("NAME")); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TestCases/Concord/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | True 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FBPLib/Lib/ComponentDescriptionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] 8 | public class ComponentDescription : Attribute 9 | { 10 | /* * 11 | * Copyright 2007, ... , 2011, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | public ComponentDescription(string value) { this.value = value; } 18 | public string value; 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /FBPLib/Lib/OutArray.cs: -------------------------------------------------------------------------------- 1 | namespace FBPLib 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | 7 | /// This class is used as a temporary facility to indicate that an array output port 8 | /// has been specified. 9 | /// * 10 | /// 11 | 12 | public class OutArray: OutputPort 13 | { 14 | /* * 15 | * Copyright 2007,..., 2011, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | internal bool _fixedSize; 22 | //internal bool _optional; 23 | 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /FBPLib/Lib/PriorityAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 5 | 6 | namespace FBPLib 7 | { 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)] 9 | public class PriorityAttribute : Attribute 10 | { 11 | /* * 12 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 13 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 14 | * based on the Everything Development Company's Artistic License. A document describing 15 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 16 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 17 | * */ 18 | public PriorityAttribute(ThreadPriority tp) { this.value = tp; } 19 | internal ThreadPriority value = ThreadPriority.Normal; 20 | 21 | 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /TestNetworks/Networks/MergeAndSort.cs: -------------------------------------------------------------------------------- 1 | namespace { // change this if you want 2 | public class MergeandSort : Network { 3 | string description = "Merge and Sort Network"; 4 | public override void Define() { 5 | Component("Write_text__to_pane", typeof(com.jpaulmorrison.fbp.core.components.misc.WriteToConsole)); 6 | Component("Sort", typeof(com.jpaulmorrison.fbp.core.components.routing.Sort)); 7 | Component("Generate____1st_group", typeof(com.jpaulmorrison.fbp.core.components.misc.GenerateTestData)); 8 | Component("Generate___2nd_group", typeof(com.jpaulmorrison.fbp.core.components.misc.GenerateTestData)); 9 | Connect(Component("Sort"), Port("OUT"), Component("Write_text__to_pane"), Port("IN")); 10 | Connect(Component("Generate___2nd_group"), Port("OUT"), Component("Sort"), Port("IN")); 11 | Connect(Component("Generate____1st_group"), Port("OUT"), Component("Sort"), Port("IN")); 12 | Initialize("100", Component("Generate___2nd_group"), Port("COUNT")); 13 | Initialize("100", Component("Generate____1st_group"), Port("COUNT")); 14 | 15 | } 16 | internal static void main(String[] argv) { 17 | new MergeandSort().Go(); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /TestNetworks/Networks/Copy1.cs: -------------------------------------------------------------------------------- 1 | namespace { // change this if you want 2 | public class MergeandSort : Network { 3 | string description = "Merge and Sort Network"; 4 | public override void Define() { 5 | Component("Write_text__to_pane", typeof(com.jpaulmorrison.fbp.core.components.misc.WriteToConsole)); 6 | Component("Sort", typeof(com.jpaulmorrison.fbp.core.components.routing.Sort)); 7 | Component("Generate____1st_group", typeof(com.jpaulmorrison.fbp.core.components.misc.GenerateTestData)); 8 | Component("Generate___2nd_group", typeof(com.jpaulmorrison.fbp.core.components.misc.GenerateTestData)); 9 | Connect(Component("Sort"), Port("OUT"), Component("Write_text__to_pane"), Port("IN")); 10 | Connect(Component("Generate___2nd_group"), Port("OUT"), Component("Sort"), Port("IN")); 11 | Connect(Component("Generate____1st_group"), Port("OUT"), Component("Sort"), Port("IN")); 12 | Initialize("100", Component("Generate___2nd_group"), Port("COUNT")); 13 | Initialize("100", Component("Generate____1st_group"), Port("COUNT")); 14 | 15 | } 16 | internal static void main(String[] argv) { 17 | new MergeandSort().Go(); 18 | } 19 | } 20 | int i = 0; 21 | } 22 | -------------------------------------------------------------------------------- /TestNetworks/Networks/CopyFileToCons.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FBPLib; 3 | using Components; 4 | 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | public class CopyFileToCons : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() /* throws Throwable */ { 20 | Connect(Component("Read", typeof(ReadText)), 21 | Port("OUT"), 22 | Component("Write", typeof(WriteToConsole)), 23 | Port("IN")); 24 | Object d = (Object)@"..\..\mfile"; 25 | Initialize(d, 26 | Component("Read"), 27 | Port("SOURCE")); 28 | 29 | } 30 | internal static void main(String[] argv) { 31 | new CopyFileToCons().Go(); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /TestCases/MergeAndSort/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MergeAndSort.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /FBPLib/Lib/InPortAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] 8 | public class InPort : Attribute 9 | { 10 | /* * 11 | * Copyright 2007, ..., 2011, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | public InPort(string value) // value is positional parameter; rest are keyword 18 | { 19 | this.value = value; 20 | } 21 | 22 | public string value; 23 | public string[] valueList; 24 | public string description; 25 | public Type type = typeof(Object); 26 | public bool arrayPort; 27 | public bool fixedSize; 28 | public int setDimension; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.225 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FBPTest.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FBPLib/Lib/OutPortAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | [AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct,AllowMultiple=true)] 8 | public class OutPort : Attribute 9 | { 10 | /* * 11 | * Copyright 2007, ..., 2011, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | 18 | public OutPort(string value) // value is positional parameter; rest are keyword 19 | { 20 | this.value = value; 21 | } 22 | 23 | public string value; 24 | public string[] valueList; 25 | public bool arrayPort; 26 | public bool fixedSize; 27 | public int setDimension; 28 | public bool optional; 29 | public Type type = typeof(Object); 30 | } 31 | } -------------------------------------------------------------------------------- /TestNetworks/Networks/TestRunExe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | /** This network is intended to test RunExe component */ 10 | 11 | public class TestRunExe : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // Component("MONITOR", Monitor)); 23 | // tracing = true; 24 | 25 | 26 | Component("RE", typeof(RunExe)); 27 | 28 | } 29 | internal static void main(String[] argv) 30 | { 31 | new TestRunExe().Go(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestNestedSubstreams.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | public class TestNestedSubstreams : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() /* throws Throwable */ { 20 | // Component("MONITOR", Monitor)); 21 | // tracing = true; 22 | 23 | Component("generate", typeof(GenSubStreams)); 24 | Component("subnet", typeof(SubnetX)); 25 | Component("output", typeof(Output)); 26 | Connect("generate.OUT", "subnet.IN"); 27 | Connect("subnet.OUT", "output.IN"); 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestDeadlockDetection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | /* This should not crash if running properly */ 10 | 11 | public class TestDeadlockDetection : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // Component("MONITOR", Monitor)); 23 | // tracing = true; 24 | 25 | Component("generate", typeof(GenerateSlowly)); 26 | _deadlockTest = true; 27 | 28 | Component("sub", typeof(SubnetD)); 29 | Connect("generate.OUT", "sub.IN"); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FBPLib/Lib/Port.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace FBPLib 7 | { 8 | public class Port 9 | { 10 | /* 11 | * This class ensures that Network connect statements use "real" port names, 12 | * rather than arbitrary character strings 13 | */ 14 | 15 | public string _name; 16 | 17 | public int _index; // -1 if array port 18 | 19 | public string _displayName = null; 20 | 21 | public Port(string n, int i) 22 | { 23 | _name = n; 24 | _index = i; 25 | if (_index == -1) 26 | { 27 | Regex re = new Regex(@"^(\w+)\[(\d+)\]$"); // test for square bracket 28 | Match m = re.Match(_name); 29 | if (m.Success) 30 | { 31 | _name = m.Groups[1].Value; 32 | _index = Int32.Parse(m.Groups[2].Value); 33 | } 34 | } 35 | if (_index != -1) // index may have changed! 36 | _displayName = String.Format("{0}[{1}]", _name, _index); 37 | else 38 | _displayName = String.Format("{0}", _name); 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /FBPLib/Lib/Chain.cs: -------------------------------------------------------------------------------- 1 | namespace FBPLib 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// This is a package-private class which is just used to hold 7 | /// chains attached to Packets. There are no methods here, 8 | /// since all the work is being done in class Packet. 9 | /// This could have been an inner class of Packet. 10 | /// 11 | 12 | sealed class Chain 13 | { 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | //internal Packet Head; 22 | internal List Members = new List(); 23 | internal string Name; 24 | 25 | internal Chain(string name) 26 | { 27 | Name = name; 28 | //Head = head; 29 | Members = new List(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestTune.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | using Components; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | public class TestTune : Network 11 | { 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() 20 | { 21 | Component("Read", typeof(ReadText)); 22 | Component("Tune", typeof(Tune)); 23 | Component("Text2IntArray", typeof(Text2IntArray)); 24 | Connect("Read.OUT", "Text2IntArray.IN"); 25 | Connect("Text2IntArray.OUT", "Tune.IN"); 26 | 27 | Object d = (Object)@"..\..\tune.txt"; 28 | Initialize(d, 29 | Component("Read"), 30 | Port("SOURCE")); 31 | 32 | 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /FBPLib/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace FBP.Properties { 2 | 3 | 4 | // This class allows you to handle specific events on the settings class: 5 | // The SettingChanging event is raised before a setting's value is changed. 6 | // The PropertyChanged event is raised after a setting's value is changed. 7 | // The SettingsLoaded event is raised after the setting values are loaded. 8 | // The SettingsSaving event is raised before the setting values are saved. 9 | internal sealed partial class Settings { 10 | 11 | public Settings() { 12 | // // To add event handlers for saving and changing settings, uncomment the lines below: 13 | // 14 | // this.SettingChanging += this.SettingChangingEventHandler; 15 | // 16 | // this.SettingsSaving += this.SettingsSavingEventHandler; 17 | // 18 | } 19 | 20 | private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { 21 | // Add code to handle the SettingChangingEvent event here. 22 | } 23 | 24 | private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { 25 | // Add code to handle the SettingsSaving event here. 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestNullOutputPort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | public class TestNullOutputPort : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() /* throws Throwable */ { 20 | // Component("MONITOR", Monitor)); 21 | // tracing = true; 22 | 23 | Component("generate", typeof(GenerateTestData)); 24 | Component("replicate", typeof(ReplString)); 25 | Component("discard", typeof(Discard)); 26 | Connect("generate.OUT", "replicate.IN"); 27 | Connect("replicate.OUT[1]", "discard.IN"); 28 | Initialize("100", "generate.COUNT"); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestArrayPorts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | public class TestArrayPorts : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() /* throws Throwable */ { 20 | // Component("MONITOR", Monitor)); 21 | // tracing = true; 22 | 23 | Component("generate", typeof(GenerateTestData)); 24 | Component("replicate", typeof(ReplString)); 25 | Component("discard", typeof(Discard)); 26 | Connect("generate.OUT", "replicate.IN"); 27 | Connect("replicate.OUT[0]", "discard.IN"); 28 | Initialize("100", "generate.COUNT"); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TestCases/CopyFileToConsole/CopyFileToConsole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FBPLib; 3 | using Components; 4 | 5 | 6 | namespace CopyFileToConsole 7 | { 8 | 9 | public class CopyFileToConsole : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() /* throws Throwable */ 20 | { 21 | Connect(Component("Read", typeof(ReadText)), 22 | Port("OUT"), 23 | Component("Write", typeof(WriteToConsole)), 24 | Port("IN")); 25 | Object d = (Object)@"..\..\Resources\fake_latin.txt"; 26 | Initialize(d, 27 | Component("Read"), 28 | Port("SOURCE")); 29 | 30 | } 31 | internal static void Main(String[] argv) 32 | { 33 | new CopyFileToConsole().Go(); 34 | Console.Read(); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /UnitTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UnitTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UnitTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c783bce6-af1d-4599-9e65-05ede981bbb1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FBPLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FBPLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FBPLib")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3f3b40db-23d5-4d75-a74b-3fb40cc65eaa")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FBPVerbs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FBPVerbs")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FBPVerbs")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2c046121-b6d8-4551-affa-2c615f86a420")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FBPLib/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 | 12 | True 13 | 14 | 15 | False 16 | 17 | 18 | 19 | 20 | False 21 | 22 | 23 | True 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FBPTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FBPTest")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a66e6a68-252a-4b4c-975c-af6d63604d7d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestCases/Concord/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Concord")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Concord")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("29e828ab-6a47-44f8-989e-ea56f2287929")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalancer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestLoadBalancer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestLoadBalancer")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("38ef3a89-243d-4464-92d9-193d8aba37d6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestNetworks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestNetworks")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("TestNetworks")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ffe626e3-fef1-4b81-9802-ab6edbf41538")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestCases/CopyFileToConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CopyFileToConsole")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CopyFileToConsole")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("430a084e-e149-47d5-a426-25f42645343e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalanceWithSubstreams/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestLoadBalancer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestLoadBalancer")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("38ef3a89-243d-4464-92d9-193d8aba37d6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestCases/Concord/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.IO; 9 | using Components; 10 | using FBPLib; 11 | 12 | namespace Concord 13 | { 14 | public partial class Form1 : Form 15 | { 16 | Network net = new Concordance(); 17 | 18 | public Form1() 19 | { 20 | InitializeComponent(); 21 | } 22 | private void btnExit_Click(object sender, EventArgs e) 23 | { 24 | Application.Exit(); 25 | } 26 | 27 | private void btnGo_Click(object sender, EventArgs e) 28 | { 29 | 30 | tbOut.Clear(); 31 | tbOut2.Clear(); 32 | tbOut3.Clear(); 33 | 34 | try 35 | { 36 | net.parms = new TextBox[] { tbOut, tbOut2, tbOut3 }; 37 | net.Go(); 38 | // timer1.Enabled = true; 39 | } 40 | catch (Exception ex) 41 | { 42 | MessageBox.Show(ex.ToString(), "Exception"); 43 | } 44 | } 45 | 46 | 47 | 48 | private void btnStop_Click(object sender, EventArgs e) 49 | { 50 | //net.Stop(); 51 | Application.Exit(); 52 | } 53 | 54 | private void textBox1_TextChanged(object sender, EventArgs e) 55 | { 56 | 57 | } 58 | 59 | private void label4_Click(object sender, EventArgs e) 60 | { 61 | 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Discard.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** 10 | * Component to discard all incoming packets 11 | */ 12 | 13 | [InPort("IN")] 14 | [ComponentDescription("Discard incoming packets")] 15 | 16 | public class Discard : Component 17 | { 18 | 19 | internal static string _copyright = 20 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 21 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 22 | "based on the Everything Development Company's Artistic License. A document describing " + 23 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 24 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 25 | 26 | 27 | IInputPort _inport; 28 | 29 | 30 | // make it a non-looper 31 | public override void Execute() /* throws Throwable */ { 32 | Packet p = _inport.Receive(); 33 | 34 | Drop(p); 35 | 36 | 37 | } 38 | /* 39 | public override Object[] Introspect() 40 | { 41 | return new Object[] { 42 | "discards its input", 43 | "IN", "input", null, 44 | "packets to pass through"}; 45 | } 46 | */ 47 | public override void OpenPorts() 48 | { 49 | _inport = OpenInput("IN"); 50 | //_inport.SetType(Type.GetType("System.Object")); 51 | 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /TestCases/Concord/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Concord.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 29 | public bool Tracing { 30 | get { 31 | return ((bool)(this["Tracing"])); 32 | } 33 | set { 34 | this["Tracing"] = value; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TestCases/FBPTest/infqueue.fil: -------------------------------------------------------------------------------- 1 | 000100abcd 2 | 000099abcd 3 | 000098abcd 4 | 000097abcd 5 | 000096abcd 6 | 000095abcd 7 | 000094abcd 8 | 000093abcd 9 | 000092abcd 10 | 000091abcd 11 | 000090abcd 12 | 000089abcd 13 | 000088abcd 14 | 000087abcd 15 | 000086abcd 16 | 000085abcd 17 | 000084abcd 18 | 000083abcd 19 | 000082abcd 20 | 000081abcd 21 | 000080abcd 22 | 000079abcd 23 | 000078abcd 24 | 000077abcd 25 | 000076abcd 26 | 000075abcd 27 | 000074abcd 28 | 000073abcd 29 | 000072abcd 30 | 000071abcd 31 | 000070abcd 32 | 000069abcd 33 | 000068abcd 34 | 000067abcd 35 | 000066abcd 36 | 000065abcd 37 | 000064abcd 38 | 000063abcd 39 | 000062abcd 40 | 000061abcd 41 | 000060abcd 42 | 000059abcd 43 | 000058abcd 44 | 000057abcd 45 | 000056abcd 46 | 000055abcd 47 | 000054abcd 48 | 000053abcd 49 | 000052abcd 50 | 000051abcd 51 | 000050abcd 52 | 000049abcd 53 | 000048abcd 54 | 000047abcd 55 | 000046abcd 56 | 000045abcd 57 | 000044abcd 58 | 000043abcd 59 | 000042abcd 60 | 000041abcd 61 | 000040abcd 62 | 000039abcd 63 | 000038abcd 64 | 000037abcd 65 | 000036abcd 66 | 000035abcd 67 | 000034abcd 68 | 000033abcd 69 | 000032abcd 70 | 000031abcd 71 | 000030abcd 72 | 000029abcd 73 | 000028abcd 74 | 000027abcd 75 | 000026abcd 76 | 000025abcd 77 | 000024abcd 78 | 000023abcd 79 | 000022abcd 80 | 000021abcd 81 | 000020abcd 82 | 000019abcd 83 | 000018abcd 84 | 000017abcd 85 | 000016abcd 86 | 000015abcd 87 | 000014abcd 88 | 000013abcd 89 | 000012abcd 90 | 000011abcd 91 | 000010abcd 92 | 000009abcd 93 | 000008abcd 94 | 000007abcd 95 | 000006abcd 96 | 000005abcd 97 | 000004abcd 98 | 000003abcd 99 | 000002abcd 100 | 000001abcd 101 | -------------------------------------------------------------------------------- /TestNetworks/Networks/DropOldest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | using Components; 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | /** This network is intended to test dropOldest connection attribute */ 10 | 11 | 12 | public class DropOldest : Network 13 | { 14 | 15 | /* * 16 | * Copyright 2007, 2014, J. Paul Morrison. At your option, you may copy, 17 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 18 | * based on the Everything Development Company's Artistic License. A document describing 19 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 20 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 21 | * */ 22 | 23 | public override void Define() /* throws Throwable */ { 24 | Connection c = Connect(Component("Generate", typeof(GenerateTestData)), 25 | Port("OUT"), 26 | Component("ProcessSlowly", typeof(ProcessSlowly)), 27 | Port("IN")); 28 | c.SetDropOldest(); 29 | 30 | Connect(Component("ProcessSlowly"), 31 | Port("OUT"), 32 | Component("Display", typeof(Output)), 33 | Port("IN")); 34 | 35 | 36 | Initialize("10000", 37 | Component("Generate"), 38 | Port("COUNT")); 39 | 40 | 41 | } 42 | internal static void main(String[] argv) 43 | { 44 | new DropOldest().Go(); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/GenerateSlowly.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | using System.Threading; 6 | 7 | 8 | namespace Components 9 | { 10 | [OutPort("OUT")] 11 | [ComponentDescription("Generate 100 packets slowly")] 12 | public class GenerateSlowly:Component 13 | { 14 | internal static string _copyright = 15 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 16 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 17 | "based on the Everything Development Company's Artistic License. A document describing " + 18 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 19 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 20 | 21 | OutputPort _outport; 22 | public override void Execute() /* throws Throwable */ { 23 | 24 | for (int i = 0; i < 100; i++) 25 | { 26 | 27 | Packet p = Create(i); 28 | Thread.Sleep(100); 29 | _outport.Send(p); 30 | 31 | 32 | } 33 | 34 | } 35 | public override void OpenPorts() 36 | { 37 | 38 | _outport = OpenOutput("OUT"); 39 | // _outport.SetType(Type.GetType("System.String")); 40 | 41 | 42 | } 43 | /* 44 | public override System.Object[] Introspect() 45 | { 46 | 47 | return new Object[] { 48 | "generates a set of Packets" , 49 | "OUT", "output", Type.GetType("System.String"), 50 | "lines generated"}; 51 | } 52 | */ 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /UnitTests/StoreValues.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FBPLib; 3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using System.Collections.Generic; 6 | 7 | namespace UnitTests 8 | { 9 | /** 10 | * Component to compare the input of the component with an expected value. 11 | */ 12 | 13 | [InPort("IN")] 14 | [OutPort("OUT", optional = true)] 15 | [ComponentDescription("Store values of all packets received")] 16 | public class StoreValues : Component 17 | { 18 | internal static string _copyright = 19 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 20 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 21 | "based on the Everything Development Company's Artistic License. A document describing " + 22 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 23 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 24 | 25 | 26 | IInputPort _inport; 27 | List _values = new List(); 28 | 29 | public IReadOnlyList Values => _values; 30 | 31 | public override void OpenPorts() 32 | { 33 | _inport = OpenInput("IN"); 34 | } 35 | 36 | public override void Execute() 37 | { 38 | Packet p; 39 | while ((p = _inport.Receive()) != null) 40 | { 41 | if (p.Type != Packet.Types.Open && p.Type != Packet.Types.Close) 42 | { 43 | _values.Add(p.Content); 44 | } 45 | 46 | Drop(p); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Concatenate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to concatenate two or more streams of packets 10 | */ 11 | [InPort("IN", arrayPort = true)] 12 | [OutPort("OUT")] 13 | [ComponentDescription("Concatenates input streams")] 14 | public class Concatenate : Component 15 | { 16 | internal static string _copyright = 17 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 18 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 19 | "based on the Everything Development Company's Artistic License. A document describing " + 20 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 21 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 22 | 23 | 24 | 25 | IInputPort[] _inportArray; 26 | OutputPort _outport; 27 | 28 | public override void Execute() /* throws Throwable */{ 29 | 30 | int no = _inportArray.Length; 31 | 32 | Packet p; 33 | for (int i = 0; i < no; i++) 34 | { 35 | while ((p = _inportArray[i].Receive()) != null) 36 | { 37 | _outport.Send(p); 38 | } 39 | 40 | } 41 | } 42 | 43 | public override void OpenPorts() 44 | { 45 | 46 | _inportArray = OpenInputArray("IN"); 47 | // inport.setType(Type.GetType("Object")); 48 | 49 | _outport = OpenOutput("OUT"); 50 | 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TSS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Components; 5 | using FBPLib; 6 | using System.IO; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | public class TSS : Network 11 | { 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() 20 | { 21 | // string filename = @"..\..\..\infqueue.fil"; 22 | 23 | Component("Generate", typeof(GenSS)); 24 | Component("Subnet", typeof(SubnetX)); 25 | Component("Display", typeof(WriteToConsole)); 26 | Component("Display2", typeof(WriteToConsole)); 27 | //Component("Discard", typeof(Discard)); 28 | 29 | Connect("Generate.OUT", "Subnet.IN"); 30 | Connect("Subnet.OUT", "Display2.IN"); 31 | Connect("Subnet.*SUBEND", "Display.IN"); 32 | 33 | Initialize("100", 34 | Component("Generate"), 35 | Port("COUNT")); 36 | 37 | //Stream st = Console.OpenStandardOutput(); 38 | //Initialize(st, 39 | // Component("Display"), 40 | // Port("DESTINATION")); 41 | //Initialize(st, 42 | // Component("Display2"), 43 | // Port("DESTINATION")); 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Inject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to send an IIP to an output port 10 | */ 11 | [InPort("IN")] 12 | [OutPort("OUT")] 13 | [ComponentDescription("Send one IIP to output port")] 14 | public class Inject : Component 15 | { 16 | 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | 25 | 26 | IInputPort _inport; 27 | OutputPort _outport; 28 | 29 | public override void Execute() /* throws Throwable */{ 30 | 31 | Packet p = _inport.Receive(); 32 | _outport.Send(p); 33 | _inport.Close(); 34 | 35 | } 36 | /* 37 | public override Object[] Introspect() 38 | { 39 | return new Object[] { 40 | "concatenates input streams at array port IN and sends them to port OUT", 41 | "IN", "input", Type.GetType("Object"), 42 | "input stream", 43 | "OUT", "output", Type.GetType("Object"), 44 | "output stream"}; 45 | } 46 | */ 47 | public override void OpenPorts() 48 | { 49 | 50 | _inport = OpenInput("IN"); 51 | // inport.setType(Type.GetType("Object")); 52 | 53 | _outport = OpenOutput("OUT"); 54 | 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /TestNetworks/Networks/ReceiveFromSocket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | using Components; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | public class ReceiveFromSocket : Network 11 | { 12 | /* * 13 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() { 20 | 21 | // Component("Generate", typeof(Generate)); 22 | // Component("WS", typeof(WriteToSocket)); 23 | Component("RS", typeof(ReadFromSocket)); 24 | Component("Display", typeof(WriteToConsole)); 25 | 26 | // Connect("Generate.OUT", "WS.IN"); 27 | Connect("RS.OUT", "Display.IN"); 28 | 29 | // Initialize("100", 30 | // Component("Generate"), 31 | // Port("COUNT")); 32 | 33 | //Stream st = Console.OpenStandardOutput(); 34 | //Initialize(st, 35 | // Component("Display"), 36 | // Port("DESTINATION")); 37 | 38 | 39 | // Initialize("4444", 40 | // Component("WS"), 41 | // Port("PORT")); 42 | Initialize("4444", 43 | Component("RS"), 44 | Port("PORT")); 45 | 46 | 47 | 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestLoadBalanceWRandDelay.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | /** This network is intended to test the effect of random delays and multiple threads on performance */ 10 | 11 | public class TestLoadBalanceWRandDelay : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // Component("MONITOR", Monitor)); 23 | // tracing = true; 24 | 25 | int multiplex_factor = 10; 26 | Component("generate", typeof(GenerateTestData)); 27 | Component("display", typeof(WriteToConsole)); 28 | Component("lbal", typeof(LoadBalance)); 29 | Connect("generate.OUT", "lbal.IN"); 30 | Initialize("100", Component("generate"), Port("COUNT")); 31 | for (int i = 0; i < multiplex_factor; i++) { 32 | Connect(Component("lbal"), Port("OUT", i), Component("prd-" + i, typeof(ProcessWRandDelays)), Port("IN")); 33 | Connect(Component("prd-" + i), Port("OUT"), "display.IN"); 34 | } 35 | 36 | } 37 | internal static void main(String[] argv) 38 | { 39 | new TestLoadBalanceWRandDelay().Go(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Copy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to pass through all incoming packets - mostly used for 10 | * debugging. 11 | */ 12 | 13 | [InPort("IN")] 14 | [OutPort("OUT")] 15 | [ComponentDescription("Copies its input to its output")] 16 | 17 | public class Copy : Component 18 | { 19 | 20 | internal static string _copyright = 21 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 22 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 23 | "based on the Everything Development Company's Artistic License. A document describing " + 24 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 25 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 26 | 27 | 28 | IInputPort _inport; 29 | OutputPort _outport; 30 | 31 | // make it a non-looper 32 | public override void Execute() /* throws Throwable */ { 33 | Packet p; 34 | for (p = _inport.Receive(); p != null; p = _inport.Receive()) 35 | _outport.Send(p); 36 | } 37 | /* 38 | public override Object[] Introspect() 39 | { 40 | return new Object[] { 41 | "passes its input to its output", 42 | "IN", "input", null, 43 | "packets to pass through", 44 | "OUT", "output", null, 45 | "destination for packets"}; 46 | } 47 | */ 48 | public override void OpenPorts() 49 | { 50 | _inport = OpenInput("IN"); 51 | //_inport.SetType(Type.GetType("System.Object")); 52 | _outport = OpenOutput("OUT"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestLoadBalanceWithSubstreams.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2007-2016, J. Paul Morrison. 2 | // At your option, you may copy, distribute, or make derivative works under the terms of the 3 | // Clarified Artistic License, based on the Everything Development Company's Artistic License. 4 | // A document describing this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 5 | // THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 6 | // Modified by Tom Fox 2016-August 7 | 8 | using System; 9 | using System.IO; 10 | using FBPLib; 11 | using Components; 12 | 13 | namespace TestNetworks.Networks 14 | { 15 | // This network is intended to test the LoadBalance component 16 | public class TestLoadBalanceWithSubstreams : Network 17 | { 18 | public override void Define() 19 | { 20 | // Component("MONITOR", Monitor)); 21 | // tracing = true; 22 | 23 | int multiplex_factor = 6; 24 | Component("generate", typeof(GenSS)); 25 | Component("display", typeof (WriteText)); 26 | Component("lbal", typeof(LoadBalance)); 27 | Component("SSMerge", typeof(SubstreamSensitiveMerge)); 28 | Connect("generate.OUT", "lbal.IN", 4); 29 | 30 | Initialize("100", Component("generate"), Port("COUNT")); 31 | 32 | for (int i = 0; i < multiplex_factor; i++) 33 | { 34 | Connect(Component("lbal"), Port("OUT", i), Component("passthru" + i, typeof(ProcessSlowly)), Port("IN"), 1); 35 | Connect(Component("passthru" + i), Port("OUT"), Component("SSMerge"), Port("IN", i), 1); 36 | } 37 | Connect("SSMerge.OUT", "display.IN", 4); 38 | 39 | Stream st = Console.OpenStandardOutput(); 40 | Initialize(st, 41 | Component("display"), 42 | Port("DESTINATION")); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Passthru.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to pass through all incoming packets - mostly used for 10 | * debugging. 11 | */ 12 | 13 | [InPort("IN", description="input stream")] 14 | [OutPort("OUT", type=typeof(Object))] 15 | [ComponentDescription("Passes its input to its output")] 16 | 17 | public class Passthru : Component 18 | { 19 | 20 | internal static string _copyright = 21 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 22 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 23 | "based on the Everything Development Company's Artistic License. A document describing " + 24 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 25 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 26 | 27 | 28 | IInputPort _inport; 29 | OutputPort _outport; 30 | 31 | // make it a non-looper 32 | public override void Execute() /* throws Throwable */ { 33 | Packet p = _inport.Receive(); 34 | 35 | _outport.Send(p); 36 | 37 | 38 | } 39 | /* 40 | public override Object[] Introspect() 41 | { 42 | return new Object[] { 43 | "passes its input to its output", 44 | "IN", "input", null, 45 | "packets to pass through", 46 | "OUT", "output", null, 47 | "destination for packets"}; 48 | } 49 | */ 50 | public override void OpenPorts() 51 | { 52 | _inport = OpenInput("IN"); 53 | // _inport.SetType(Type.GetType("System.Object")); 54 | _outport = OpenOutput("OUT"); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /TestNetworks/Networks/Update.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | using Components; 6 | using System.IO; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | /** This is really the front end of an Update app - instead of routing the merged stream 11 | * to a processing component, we just display it. 12 | * 13 | * @author HP_Administrator 14 | * 15 | */ 16 | public class Update : Network 17 | { 18 | /* * 19 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 20 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 21 | * based on the Everything Development Company's Artistic License. A document describing 22 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 23 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 24 | * */ 25 | public override void Define() /*throws Throwable*/ { 26 | Component("@Read@ Master (1)", typeof(ReadText)); 27 | Component("@Read@ Details (2)", typeof(ReadText)); 28 | Component("@@Collate (3)", typeof(Collate)); 29 | Component("@@Display (4)", typeof(WriteToConsole)); 30 | Connect("@Read@ Master (1).OUT", "@@Collate (3).IN[0]"); 31 | Connect("@Read@ Details (2).OUT", "@@Collate (3).IN[1]"); 32 | Connect("@@Collate (3).OUT", "@@Display (4).IN"); 33 | Initialize(@"..\..\mfile", "@Read@ Master (1).SOURCE"); 34 | Initialize(@"..\..\dfile", "@Read@ Details (2).SOURCE"); 35 | //Stream st = Console.OpenStandardOutput(); 36 | //Initialize(st, "@@Display (4).DESTINATION"); 37 | 38 | Initialize("3,2,5", "@@Collate (3).CTLFIELDS"); 39 | 40 | } 41 | 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/GenSubStreams.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | using System.Threading; 6 | 7 | 8 | namespace Components 9 | { 10 | [OutPort("OUT")] 11 | [ComponentDescription("Generate 4 brackets & 2 data packets")] 12 | public class GenSubStreams : Component 13 | { 14 | internal static string _copyright = 15 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 16 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 17 | "based on the Everything Development Company's Artistic License. A document describing " + 18 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 19 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 20 | 21 | OutputPort outputPort; 22 | public override void Execute() /* throws Throwable */ { 23 | 24 | outputPort.Send(Create(Packet.Types.Open, "OPEN(1)")); 25 | outputPort.Send(Create("A")); 26 | outputPort.Send(Create(Packet.Types.Open, "OPEN(2)")); 27 | outputPort.Send(Create("B")); 28 | outputPort.Send(Create(Packet.Types.Close, "CLOSE(2)")); 29 | outputPort.Send(Create(Packet.Types.Close, "CLOSE(1)")); 30 | // outputPort.close(); 31 | } 32 | public override void OpenPorts() 33 | { 34 | 35 | outputPort = OpenOutput("OUT"); 36 | // _outport.SetType(Type.GetType("System.String")); 37 | 38 | 39 | } 40 | /* 41 | public override System.Object[] Introspect() 42 | { 43 | 44 | return new Object[] { 45 | "generates a set of Packets" , 46 | "OUT", "output", Type.GetType("System.String"), 47 | "lines generated"}; 48 | } 49 | */ 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /TestNetworks/Networks/Deadlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | /** This network forces a deadlock condition */ 10 | 11 | public class Deadlock : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | 22 | 23 | public override void Define() /* throws Throwable */ { 24 | Connect(Component("Read", typeof(ReadText)), 25 | Port("OUT"), 26 | Component("Display", typeof(WriteToConsole)), 27 | Port("IN")); 28 | Object d = (Object)@"..\..\mfile"; 29 | Initialize(d, 30 | Component("Read"), 31 | Port("SOURCE")); 32 | Connect(Component("Display"), 33 | Port("OUT"), 34 | Component("ReplString", typeof(ReplString)), 35 | Port("IN")); 36 | 37 | Connect(Component("ReplString"), 38 | Port("OUT", 0), 39 | Component("Concatenate", typeof(Concatenate)), 40 | Port("IN", 0)); 41 | 42 | Connect(Component("Concatenate"), 43 | Port("OUT"), 44 | Component("Discard", typeof(Discard)), 45 | Port("IN")); 46 | 47 | Connect(Component("ReplString"), 48 | Port("OUT", 1), 49 | Component("Concatenate"), 50 | Port("IN", 1)); 51 | 52 | Connect(Component("ReplString"), 53 | Port("OUT", 2), 54 | Component("Concatenate"), 55 | Port("IN", 2)); 56 | } 57 | internal static void main(String[] argv) { 58 | new Deadlock().Go(); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/CleanBlob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | using FBPLib; 6 | 7 | 8 | namespace Components 9 | { 10 | [InPort("IN")] 11 | [OutPort("OUT")] 12 | [ComponentDescription("Clean up blobs")] 13 | public class CleanBlob : Component 14 | { 15 | 16 | internal static string _copyright = 17 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 18 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 19 | "based on the Everything Development Company's Artistic License. A document describing " + 20 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 21 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 22 | 23 | 24 | IInputPort _inport; 25 | OutputPort _outport; 26 | Regex _rgx = new Regex(@"\P{L}"); //any character NOT a Unicode letter 27 | Regex _rgx2 = new Regex(@"\s+"); //at least one blank 28 | 29 | 30 | // make it a non-looper 31 | public override void Execute() /* throws Throwable */ { 32 | 33 | Packet p = _inport.Receive(); 34 | string text = p.Content as string; 35 | text = _rgx.Replace(text, " "); // special characters -> spaces 36 | text = _rgx2.Replace(text, " "); // collapse multiple spaces 37 | text = text.Trim(); // remove leading and trailing spaces 38 | p.Content = text; 39 | _outport.Send(p); 40 | 41 | 42 | } 43 | 44 | public override void OpenPorts() 45 | { 46 | _inport = OpenInput("IN"); 47 | //_inport.SetType(Type.GetType("System.Object")); 48 | _outport = OpenOutput("OUT"); 49 | } 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /TestNetworks/Networks/InfiniteQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | using Components; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | [OutPort("OUT")] 11 | [InPort("IN")] 12 | [InPort("READFILE")] 13 | [InPort("WRITEFILE")] 14 | 15 | public class InfiniteQueue : SubNet 16 | { 17 | /* * 18 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 19 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 20 | * based on the Everything Development Company's Artistic License. A document describing 21 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 22 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 23 | * */ 24 | 25 | public override void Define() 26 | { 27 | 28 | Component("SubIn", typeof(SubIn)); 29 | Component("SubInD", typeof(SubIn)); 30 | Component("SubInS", typeof(SubIn)); 31 | Component("Write", typeof(WriteText)); 32 | Component("SubOut", typeof(SubOut)); 33 | Component("Read", typeof(ReadText)); 34 | 35 | Connect("SubIn.OUT", "Write.IN"); 36 | Connect("Read.OUT", "SubOut.IN"); 37 | Connect("Write.*", "Read.*"); 38 | Connect("SubInD.OUT", "Write.DESTINATION"); 39 | Connect("SubInS.OUT", "Read.SOURCE"); 40 | 41 | //Initialize(Filename, "Write.DESTINATION"); 42 | //Initialize(Filename, "Read.SOURCE"); 43 | 44 | Initialize("IN", "SubIn.NAME"); 45 | Initialize("OUT", "SubOut.NAME"); 46 | Initialize("WRITEFILE", "SubInD.NAME"); 47 | Initialize("READFILE", "SubInS.NAME"); 48 | 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /FBPLib/Lib/ConnArray.cs: -------------------------------------------------------------------------------- 1 | namespace FBPLib 2 | { 3 | 4 | using System; 5 | using System.Collections; 6 | using System.Threading; 7 | 8 | 9 | /// This class represents a Connection Array 10 | /// 11 | 12 | public class ConnArray : IInputPort 13 | { 14 | /* * 15 | * Copyright 2007, ..., 2011, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | internal bool _fixedSize; 22 | 23 | internal string _name; 24 | Component _receiver; 25 | 26 | public int Count() 27 | { 28 | return 0; 29 | } 30 | public void Close() 31 | { 32 | return; 33 | } 34 | public int Capacity() 35 | { 36 | return 0; 37 | } 38 | 39 | public string Name 40 | { 41 | get 42 | { 43 | return _name; 44 | } 45 | set 46 | { 47 | _name = value; 48 | } 49 | } 50 | public Packet Receive() 51 | { 52 | return null; 53 | } 54 | public void SetReceiver(Component newReceiver) 55 | { 56 | _receiver = newReceiver; 57 | 58 | } 59 | public Component Receiver 60 | { 61 | get 62 | { 63 | return _receiver; 64 | } 65 | set 66 | { 67 | _receiver = value; 68 | } 69 | 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /TestNetworks/Networks/TestInfQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | using Components; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | public class TestInfQueue : Network 11 | { 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() 20 | { 21 | const string fileName = @"C:\temp\infqueue.fil"; 22 | if (!File.Exists(fileName)) 23 | { 24 | //throw new FileNotFoundException("\nFailed to find output file: " + infqFilePath); 25 | File.Create(fileName); 26 | } 27 | 28 | Component("Generate", typeof(GenerateTestData)); 29 | Component("InfiniteQueue", typeof(InfiniteQueue)); 30 | Component("Display", typeof(WriteToConsole)); 31 | 32 | Connect("Generate.OUT", "InfiniteQueue.IN"); 33 | Connect("InfiniteQueue.OUT", "Display.IN"); 34 | 35 | Initialize("100", 36 | Component("Generate"), 37 | Port("COUNT")); 38 | 39 | //Stream st = Console.OpenStandardOutput(); 40 | //Initialize(st, 41 | // Component("Display"), 42 | // Port("DESTINATION")); 43 | 44 | Initialize(fileName, "InfiniteQueue.READFILE"); 45 | Initialize(fileName, "InfiniteQueue.WRITEFILE"); 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestLoadBalancer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | /** This network is intended to test LoadBalance component */ 10 | 11 | public class TestLoadBalancer : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // Component("MONITOR", Monitor)); 23 | // tracing = true; 24 | 25 | int multiplex_factor = 10; 26 | Component("generate", typeof(GenerateTestData)); 27 | Component("display", typeof(WriteToConsole)); 28 | Component("lbal", typeof(LoadBalance)); 29 | Connect("generate.OUT", "lbal.IN"); 30 | Initialize("100", Component("generate"), Port("COUNT")); 31 | for (int i = 0; i < multiplex_factor; i++) { 32 | Connect(Component("lbal"), Port("OUT", i), Component("passthru" + i, typeof(Passthru)), Port("IN")); 33 | Connect(Component("passthru" + i), Port("OUT"), "display.IN"); 34 | } 35 | //Stream st = Console.OpenStandardOutput(); 36 | //Initialize(st, 37 | // Component("display"), 38 | // Port("DESTINATION")); 39 | } 40 | internal static void main(String[] argv) 41 | { 42 | new TestLoadBalancer().Go(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/ProcessSlowly.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to pass through all incoming packets - mostly used for 10 | * debugging. 11 | */ 12 | 13 | [InPort("IN", description = "input stream")] 14 | [OutPort("OUT", type = typeof(Object))] 15 | [ComponentDescription("Passes its input to its output... slowly")] 16 | 17 | public class ProcessSlowly : Component 18 | { 19 | 20 | internal static string _copyright = 21 | "Copyright 2007, 2008, 2014, J. Paul Morrison. At your option, you may copy, " + 22 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 23 | "based on the Everything Development Company's Artistic License. A document describing " + 24 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 25 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 26 | 27 | 28 | IInputPort _inport; 29 | OutputPort _outport; 30 | 31 | // make it a non-looper 32 | public override void Execute() /* throws Throwable */ { 33 | Packet p = _inport.Receive(); 34 | 35 | _outport.Send(p); 36 | System.Threading.Thread.Sleep(100); 37 | } 38 | 39 | /* 40 | public override Object[] Introspect() 41 | { 42 | return new Object[] { 43 | "passes its input to its output", 44 | "IN", "input", null, 45 | "packets to pass through", 46 | "OUT", "output", null, 47 | "destination for packets"}; 48 | } 49 | */ 50 | public override void OpenPorts() 51 | { 52 | _inport = OpenInput("IN"); 53 | // _inport.SetType(Type.GetType("System.Object")); 54 | _outport = OpenOutput("OUT"); 55 | } 56 | } 57 | } 58 | ; 59 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/RunExe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using FBPLib; 4 | 5 | 6 | namespace Components 7 | { 8 | /** Component to run an EXE 9 | */ 10 | 11 | [ComponentDescription("Run an .exe file")] 12 | public class RunExe : Component 13 | { 14 | 15 | internal static string _copyright = 16 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 17 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 18 | "based on the Everything Development Company's Artistic License. A document describing " + 19 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 20 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 21 | 22 | 23 | 24 | 25 | 26 | public override void Execute() { 27 | 28 | // Thanks to Lars Behrmann - http://bytes.com/groups/net-c/279036-running-exe 29 | 30 | //ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); 31 | ProcessStartInfo startInfo = new ProcessStartInfo("DRAWFLOW.EXE"); 32 | startInfo.WindowStyle = ProcessWindowStyle.Minimized; 33 | startInfo.WorkingDirectory = @"C:\Documents and Settings\HP_Administrator\My Documents\Business\C++DrawFBP"; 34 | 35 | //Process.Start(startInfo); 36 | //startInfo.Arguments = "www.jpaulmorrison.com"; 37 | Process.Start(startInfo); 38 | 39 | } 40 | /* 41 | public override Object[] Introspect() 42 | { 43 | return new Object[] { 44 | "concatenates input streams at array port IN and sends them to port OUT", 45 | "IN", "input", Type.GetType("Object"), 46 | "input stream", 47 | "OUT", "output", Type.GetType("Object"), 48 | "output stream"}; 49 | } 50 | */ 51 | public override void OpenPorts() 52 | { 53 | 54 | 55 | 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestMixedInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | public class TestMixedInput : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | 20 | 21 | public override void Define() /* throws Throwable */ { 22 | /* component("MONITOR", Monitor.class); */ 23 | // Component("Inject", typeof(Inject)); 24 | Connect(Component("Read", typeof(ReadText)), 25 | Port("OUT"), 26 | Component("Splitter1", typeof(Splitter1)), 27 | Port("IN")); 28 | Object d = (Object) "Data\\myXML3.txt"; 29 | Initialize(d, 30 | Component("Read"), 31 | Port("SOURCE")); 32 | 33 | Connect(Component("Splitter1"), 34 | Port("OUT", 0), 35 | Component("Concatenate", typeof(Concatenate)), 36 | Port("IN", 0)); 37 | 38 | Connect(Component("Concatenate"), 39 | Port("OUT"), 40 | Component("Write", typeof(WriteToConsole)), 41 | Port("IN")); 42 | 43 | Connect(Component("Splitter1"), 44 | Port("OUT", 1), 45 | Component("Concatenate"), 46 | Port("IN", 2)); 47 | 48 | Object s = (Object) "ABCDEF"; 49 | Initialize(s, 50 | Component("Concatenate"), 51 | Port("IN", 1)); 52 | 53 | //Stream st = Console.OpenStandardOutput(); 54 | //Initialize(st, 55 | // Component("Write"), 56 | // Port("DESTINATION")); 57 | 58 | 59 | } 60 | internal static void main(String[] argv) { 61 | new TestMixedInput().Go(); 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /UnitTests/GenerateAndCopyTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using FBPLib; 4 | using Components; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace UnitTests 9 | { 10 | [TestClass] 11 | public class CanGenerateAndCopy : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | 22 | public StoreValues StoreValues; 23 | 24 | public override void Define() /* throws Throwable */ 25 | { 26 | // component("MONITOR", Monitor.class); 27 | var assertions = 28 | Enumerable.Range(0, 100) 29 | .Select(x => new Func(y => String.Format("{0:d6}abcd", 100 - x) == y)) 30 | .ToArray(); 31 | 32 | Connect(Component("Generate", typeof(GenerateTestData)), 33 | Port("OUT"), 34 | Component("StoreValues", typeof(StoreValues)), 35 | Port("IN")); 36 | 37 | StoreValues = Component("StoreValues") as StoreValues; 38 | 39 | Initialize("100", 40 | Component("Generate"), 41 | Port("COUNT")); 42 | } 43 | 44 | [TestMethod] 45 | public async Task CanGenerateAndCopyTest() 46 | { 47 | var network = new CanGenerateAndCopy(); 48 | await network.Go(); 49 | var values = network.StoreValues.Values; 50 | Assert.AreEqual(100, values.Count); 51 | Assert.AreEqual("000100abcd", values[0]); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/DirList.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using FBPLib; 3 | 4 | 5 | namespace Components 6 | { 7 | [InPort("IN")] 8 | [OutPort("OUT")] 9 | [OutPort("OUTF")] 10 | [OutPort("OUTD")] 11 | [ComponentDescription("Read directory path from IN, write it to OUT, files to OUTF, directories to OUTD")] 12 | 13 | public class DirList : Component 14 | { 15 | 16 | // Thanks to David Bennett 17 | 18 | internal static string _copyright = 19 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 20 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 21 | "based on the Everything Development Company's Artistic License. A document describing " + 22 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 23 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 24 | 25 | IInputPort _inp; 26 | OutputPort _outp; 27 | OutputPort _outpf; 28 | OutputPort _outpd; 29 | 30 | public override void OpenPorts() 31 | { 32 | _inp = OpenInput("IN"); 33 | _outp = OpenOutput("OUT"); 34 | _outpd = OpenOutput("OUTD"); 35 | _outpf = OpenOutput("OUTF"); 36 | } 37 | 38 | public override void Execute() 39 | { 40 | Packet p = _inp.Receive(); 41 | string name = p.Content.ToString(); 42 | _outp.Send(p); 43 | _inp.Close(); 44 | 45 | DirectoryInfo di = new DirectoryInfo(name); 46 | DirectoryInfo[] dirs = di.GetDirectories(); 47 | //if (dirs.Length == 0) 48 | // FlowError.Complain("Missing directory"); 49 | foreach (DirectoryInfo d in dirs) 50 | _outpd.Send(Create(d.FullName)); 51 | FileInfo[] files = di.GetFiles(); 52 | foreach (FileInfo f in files) 53 | _outpf.Send(Create(f.FullName)); 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Tune.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using FBPLib; 4 | using System.Threading; 5 | 6 | namespace Components 7 | { 8 | 9 | [InPort("IN")] 10 | [ComponentDescription("Play tune")] 11 | [Priority(ThreadPriority.Highest)] // as of C#FBP-2.2 12 | public class Tune : Component 13 | { 14 | internal static string _copyright = 15 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 16 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 17 | "based on the Everything Development Company's Artistic License. A document describing " + 18 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 19 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 20 | 21 | 22 | IInputPort _inport; 23 | 24 | // make it a non-looper 25 | public override void Execute() /* throws Throwable */ { 26 | // 27 | // Note: _thread (used by SetPriority) is null before Execute() 28 | // 29 | // SetPriority(ThreadPriority.Highest); -> moved up to attribute 30 | Thread.Sleep(750); // 3/4 sec 31 | Packet p; 32 | while ((p = _inport.Receive()) != null) 33 | { 34 | int[] intArray = p.Content as int[]; 35 | 36 | Console.Beep(intArray[0], intArray[1] - 50); 37 | Thread.Sleep(50); // 1/20 sec 38 | Drop(p); 39 | } 40 | 41 | } 42 | /* 43 | public override Object[] Introspect() 44 | { 45 | return new Object[] { 46 | "discards its input", 47 | "IN", "input", null, 48 | "tune"}; 49 | } 50 | */ 51 | public override void OpenPorts() 52 | { 53 | _inport = OpenInput("IN"); 54 | //inport.SetType(Type.GetType("System.Object")); 55 | 56 | } 57 | 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Output.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | 5 | namespace Components 6 | { 7 | 8 | [MustRun] 9 | [InPort("IN")] 10 | [ComponentDescription("Display Open or Close brackets, or data packets")] 11 | 12 | public class Output : Component 13 | { 14 | internal static string _copyright = 15 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 16 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 17 | "based on the Everything Development Company's Artistic License. A document describing " + 18 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 19 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 20 | 21 | 22 | IInputPort _inport; 23 | 24 | public override void OpenPorts() 25 | { 26 | _inport = OpenInput("IN"); 27 | } 28 | 29 | public override void Execute() 30 | { 31 | Packet p; 32 | int level = 1; 33 | while ((p = _inport.Receive()) != null) 34 | { 35 | switch (p.Type) 36 | { 37 | case Packet.Types.Open: 38 | Console.Out.WriteLine("OPEN(" + level + ")"); 39 | level++; 40 | break; 41 | case Packet.Types.Close: 42 | level--; 43 | Console.Out.WriteLine("CLOSE(" + level + ")"); 44 | break; 45 | default: 46 | Console.Out.WriteLine(p.Content); 47 | break; 48 | } 49 | Drop(p); 50 | } 51 | } 52 | /* 53 | public override System.Object[] Introspect() 54 | { 55 | 56 | return new Object[] { 57 | "displays brackets"}; 58 | } 59 | */ 60 | } 61 | 62 | } 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /UnitTests/ReadTextTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using FBPLib; 4 | using System.Linq; 5 | using Components; 6 | using System.Threading.Tasks; 7 | 8 | namespace UnitTests 9 | { 10 | [TestClass] 11 | public class CanReadText : Network 12 | { 13 | /* * 14 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 15 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 16 | * based on the Everything Development Company's Artistic License. A document describing 17 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 18 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 19 | * */ 20 | 21 | public StoreValues StoreValues; 22 | 23 | public override void Define() /* throws Throwable */ 24 | { 25 | // component("MONITOR", Monitor.class); 26 | var assertions = 27 | Enumerable.Range(0, 100) 28 | .Select(x => new Func(y => String.Format("{0:d6}abcd", 100 - x) == y)) 29 | .ToArray(); 30 | 31 | Connect(Component("Read", typeof(ReadText)), 32 | Port("OUT"), 33 | Component("StoreValues", typeof(StoreValues)), 34 | Port("IN")); 35 | 36 | StoreValues = Component("StoreValues") as StoreValues; 37 | 38 | Object d = (Object)@"fake_latin.txt"; 39 | Initialize(d, 40 | Component("Read"), 41 | Port("SOURCE")); 42 | } 43 | 44 | [TestMethod] 45 | public async Task CanReadTextTest() 46 | { 47 | var network = new CanReadText(); 48 | await network.Go(); 49 | var values = network.StoreValues.Values.Cast().ToArray(); 50 | Assert.AreEqual(1, values.Length); 51 | Assert.IsTrue(values[0].StartsWith("Lorem ipsum")); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalancer/TestLoadBalancer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Components; 7 | using FBPLib; 8 | 9 | namespace TestNetworks 10 | { 11 | /** This network is intended to test LoadBalance component */ 12 | 13 | public class TestLoadBalancer : Network 14 | { 15 | 16 | /* * 17 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 18 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 19 | * based on the Everything Development Company's Artistic License. A document describing 20 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 21 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 22 | * */ 23 | public override void Define() /* throws Throwable */ { 24 | // Component("MONITOR", Monitor)); 25 | // tracing = true; 26 | 27 | int multiplex_factor = 10; 28 | Component("generate", typeof(GenerateTestData)); 29 | Component("display", typeof(WriteToConsole)); 30 | Component("lbal", typeof(LoadBalance)); 31 | Connect("generate.OUT", "lbal.IN"); 32 | Initialize("100", Component("generate"), Port("COUNT")); 33 | for (int i = 0; i < multiplex_factor; i++) 34 | { 35 | Connect(Component("lbal"), Port("OUT", i), Component("passthru" + i, typeof(Passthru)), Port("IN")); 36 | Connect(Component("passthru" + i), Port("OUT"), "display.IN"); 37 | } 38 | //Stream st = Console.OpenStandardOutput(); 39 | // Initialize(st, 40 | // Component("display"), 41 | // Port("DESTINATION")); 42 | } 43 | [STAThread] 44 | static void Main() 45 | { 46 | new TestLoadBalancer().Go(); 47 | Console.Read(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FBPLib/Lib/TimeoutHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | public class TimeoutHandler 8 | { 9 | /* * 10 | * Copyright 2007, ..., 2011, J. Paul Morrison. At your option, you may copy, 11 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 12 | * based on the Everything Development Company's Artistic License. A document describing 13 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 14 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 15 | * */ 16 | bool disposed = false; 17 | internal int _dur; // duration of TimeoutHandler 18 | internal Component _comp; 19 | 20 | 21 | public TimeoutHandler(double dur, Component comp) 22 | { 23 | lock (comp._network._timeouts) 24 | { 25 | comp.Timeout = this; 26 | comp._network._timeouts.Add(comp, this); 27 | double ms = dur * 1000.0 + 500.0; 28 | _dur = (int)ms; //convert to msecs 29 | 30 | comp.Status = Component.States.LongWait; 31 | _comp = comp; 32 | } 33 | } 34 | public void Dispose() 35 | { 36 | // Check to see if Dispose has already been called. 37 | if (!disposed) 38 | { 39 | lock (_comp._network._timeouts) 40 | { 41 | _comp.Status = Component.States.Active; 42 | _comp._network._timeouts.Remove(_comp); 43 | _comp.Timeout = null; 44 | } 45 | 46 | disposed = true; 47 | } 48 | } 49 | 50 | 51 | internal void Decrement(int freq) 52 | { 53 | _dur -= freq; // reduce by frequency, in msecs 54 | if (_dur < 0) 55 | FlowError.Complain("Component " + _comp.Name + " timed out"); 56 | } 57 | } 58 | 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /FBPLib/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.225 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FBPLib.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 29 | public bool Tracing { 30 | get { 31 | return ((bool)(this["Tracing"])); 32 | } 33 | set { 34 | this["Tracing"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 41 | public bool DeadlockTestEnabled { 42 | get { 43 | return ((bool)(this["DeadlockTestEnabled"])); 44 | } 45 | set { 46 | this["DeadlockTestEnabled"] = value; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/ProcessWRandDelays.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | 7 | namespace Components 8 | { 9 | /** Component to pass its input to its output with random delays - mostly used for 10 | * debugging. 11 | */ 12 | 13 | [InPort("IN", description = "input stream")] 14 | [OutPort("OUT", type = typeof(Object))] 15 | [ComponentDescription("Passes its input to its output with random delays")] 16 | 17 | public class ProcessWRandDelays : Component 18 | { 19 | 20 | internal static string _copyright = 21 | "Copyright 2007, 2008, 2014, J. Paul Morrison. At your option, you may copy, " + 22 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 23 | "based on the Everything Development Company's Artistic License. A document describing " + 24 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 25 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 26 | 27 | 28 | IInputPort _inport; 29 | OutputPort _outport; 30 | 31 | // make it a non-looper 32 | public override void Execute() /* throws Throwable */ { 33 | Packet p = _inport.Receive(); 34 | Random rnd = new Random(); 35 | LongWaitStart(1); 36 | int no = rnd.Next(0, 200); 37 | System.Threading.Thread.Sleep(no); 38 | LongWaitEnd(); 39 | _outport.Send(p); 40 | } 41 | 42 | /* 43 | public override Object[] Introspect() 44 | { 45 | return new Object[] { 46 | "passes its input to its output", 47 | "IN", "input", null, 48 | "packets to pass through", 49 | "OUT", "output", null, 50 | "destination for packets"}; 51 | } 52 | */ 53 | public override void OpenPorts() 54 | { 55 | _inport = OpenInput("IN"); 56 | // _inport.SetType(Type.GetType("System.Object")); 57 | _outport = OpenOutput("OUT"); 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestPassthrus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | 9 | /** This network is intended to test going in and out of dormant state */ 10 | 11 | public class TestPassthrus : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // Component("MONITOR", Monitor)); 23 | // tracing = true; 24 | 25 | Component("Generate", typeof(GenerateTestData)); 26 | Component("P1", typeof(ProcessWRandDelays)); 27 | Component("P2", typeof(Passthru)); 28 | Component("P3", typeof(ProcessWRandDelays)); 29 | Component("P4", typeof(Passthru)); 30 | Component("C1", typeof(Copy)); 31 | Component("C2", typeof(Copy)); 32 | Component("C3", typeof(Copy)); 33 | Component("C4", typeof(Copy)); 34 | Component("Discard", typeof(Discard)); 35 | Initialize("1000", "Generate.COUNT"); 36 | Connect("Generate.OUT", "P1.IN"); 37 | Connect("P1.OUT", "C1.IN"); 38 | Connect("C1.OUT", "P2.IN"); 39 | Connect("P2.OUT", "C2.IN"); 40 | Connect("C2.OUT", "P3.IN"); 41 | Connect("P3.OUT", "C3.IN"); 42 | Connect("C3.OUT", "P4.IN"); 43 | Connect("P4.OUT", "C4.IN"); 44 | Connect("C4.OUT", "Discard.IN"); 45 | 46 | } 47 | internal static void main(String[] argv) 48 | { 49 | new TestPassthrus().Go(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Splitter1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | namespace Components 7 | { 8 | [InPort("IN")] 9 | [OutPort("OUT", arrayPort = true)] 10 | [ComponentDescription("Read IN, divide into sections of 30 packets to OUT array")] 11 | public class Splitter1 : Component 12 | { 13 | internal static string _copyright = 14 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 15 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 16 | "based on the Everything Development Company's Artistic License. A document describing " + 17 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 18 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 19 | 20 | IInputPort _inp; 21 | OutputPort[] _outps; 22 | /* 23 | public override object[] Introspect() 24 | { 25 | return new object[] { 26 | "Read IN, divide into sections of 30 packets to OUT array" 27 | 28 | }; 29 | } 30 | */ 31 | public override void OpenPorts() 32 | { 33 | _inp = OpenInput("IN"); 34 | _outps = OpenOutputArray("OUT"); 35 | } 36 | 37 | // copy 30 packets at a time to consecutive output ports 38 | // close each port as it is finished 39 | // send all excess output to the last port 40 | public override void Execute() 41 | { 42 | int i = 0; 43 | int count = 0; 44 | for (Packet p = _inp.Receive(); p != null; p = _inp.Receive()) 45 | { 46 | // Console.Out.WriteLine("{0} {1}", count, i); 47 | _outps[i].Send(p); 48 | 49 | if (++count == 30 && i != _outps.Length - 1) 50 | { 51 | _outps[i].Close(); 52 | i++; 53 | count = 0; 54 | } 55 | 56 | } 57 | 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/LoadBalance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using FBPLib; 4 | 5 | 6 | namespace Components 7 | { 8 | 9 | 10 | /** Component to assign incoming packets to the output port that has the 11 | * smallest backlog of packets waiting to be processed. 12 | */ 13 | 14 | [InPort("IN")] 15 | [OutPort("OUT", arrayPort=true)] 16 | [ComponentDescription("Obtains packets and distributes them to the port of an array port which has the smallest backlog")] 17 | public class LoadBalance : Component { 18 | 19 | internal static string _copyright = 20 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 21 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 22 | "based on the Everything Development Company's Artistic License. A document describing " + 23 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 24 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 25 | 26 | 27 | IInputPort inport; 28 | OutputPort[] outportArray; 29 | 30 | public override void Execute() { 31 | 32 | int no = outportArray.Length; 33 | Int32 backlog; 34 | int sel = -1; 35 | 36 | Packet p; 37 | while ((p = inport.Receive()) != null) { 38 | backlog = Int32.MaxValue; 39 | for (int i = 0; i < no; i++) { 40 | int j = outportArray[i].DownstreamCount(); 41 | if (j < backlog) { 42 | backlog = j; 43 | sel = i; 44 | } 45 | } 46 | outportArray[sel].Send(p); 47 | 48 | } 49 | 50 | } 51 | /* 52 | public override Object[] Introspect() 53 | { 54 | return new Object[] { 55 | "obtains packets at port IN and distributes them to array port OUT" + 56 | " depending on which output port has the smallest backlog" , 57 | "IN", "input", null, 58 | "input stream", 59 | "OUT", "output", null, 60 | "multiple output streams"}; 61 | } 62 | */ 63 | public override void OpenPorts() 64 | { 65 | 66 | inport = OpenInput("IN"); 67 | //inport.setType(Object.class); 68 | 69 | outportArray = OpenOutputArray("OUT"); 70 | 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /FBPLib/Lib/NullConnection.cs: -------------------------------------------------------------------------------- 1 | namespace FBPLib 2 | { 3 | using System; 4 | 5 | 6 | 7 | 8 | /// This is used in a Network definition when a port is not connected 9 | /// 10 | 11 | sealed class NullConnection : IInputPort 12 | { 13 | /* * 14 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 15 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 16 | * based on the Everything Development Company's Artistic License. A document describing 17 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 18 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 19 | * */ 20 | public void SetType(System.Type type) { } 21 | 22 | // bool partial = false; 23 | internal string _name; 24 | internal Component _receiver; // The receiver to deliver to. 25 | public string Name 26 | { 27 | get 28 | { 29 | return _name; 30 | } 31 | set 32 | { 33 | _name = value; 34 | } 35 | } 36 | public Component Receiver 37 | { 38 | get 39 | { 40 | return _receiver; 41 | } 42 | set { _receiver = value; } 43 | 44 | } 45 | public void SetReceiver(Component receiver) 46 | { 47 | Receiver = receiver; 48 | } 49 | internal NullConnection() 50 | { 51 | } 52 | /// Return capacity of 0 53 | /// 54 | 55 | public int Capacity() 56 | { 57 | return 0; 58 | } 59 | public void Close() 60 | { 61 | } 62 | public int Count() 63 | { 64 | return 0; 65 | } 66 | public string GetName() 67 | { 68 | return Name; 69 | } 70 | internal bool IsClosed() 71 | { 72 | return true; 73 | } 74 | public Packet Receive() 75 | { 76 | return null; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/DisplayWords.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | 7 | 8 | namespace Components 9 | { 10 | [InPort("IN")] 11 | [OutPort("OUT")] 12 | [OutPort("OUTD")] 13 | [ComponentDescription("Build records from incoming word packets")] 14 | public class DisplayWords : Component 15 | { 16 | internal static string _copyright = 17 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 18 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 19 | "based on the Everything Development Company's Artistic License. A document describing " + 20 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 21 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 22 | 23 | IInputPort _inp; 24 | OutputPort _outp; 25 | OutputPort _outdp; 26 | int _reclen = 30; 27 | /* 28 | public override object[] Introspect() 29 | { 30 | return new object[] { 31 | "Read a word from IN, write a concordance line to OUT.", 32 | "Uses attributes: Text and Offset", 33 | "Non-looper. 1->1" 34 | }; 35 | } 36 | */ 37 | public override void OpenPorts() 38 | { 39 | _inp = OpenInput("IN"); 40 | _outp = OpenOutput("OUT"); 41 | _outdp = OpenOutput("OUTD"); 42 | } 43 | 44 | 45 | public override void Execute() 46 | { 47 | Packet p; 48 | string record = ""; 49 | while ((p = _inp.Receive()) != null) 50 | { 51 | string word = p.Content.ToString(); 52 | 53 | if (record.Length >= _reclen) 54 | { 55 | _outdp.Send(Create(record)); 56 | record = ""; 57 | } 58 | record += word + " "; 59 | _outp.Send(p); 60 | } 61 | if (record.Length > 0) 62 | _outdp.Send(Create(record)); 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Text2IntArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | namespace Components 7 | { 8 | /** Convert comma-separated text to an array of ints 9 | **/ 10 | [InPort("IN")] 11 | [OutPort("OUT")] 12 | [ComponentDescription("Convert comma-separated text to an array of 'int's")] 13 | public class Text2IntArray : Component 14 | { 15 | internal static string _copyright = 16 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 17 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 18 | "based on the Everything Development Company's Artistic License. A document describing " + 19 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 20 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 21 | 22 | 23 | IInputPort _inport; 24 | OutputPort _outport; 25 | 26 | public override void Execute() /* throws Throwable */ { 27 | 28 | 29 | Packet p; 30 | while ((p = _inport.Receive()) != null) 31 | { 32 | string text = p.Content as string; 33 | 34 | string[] parts = text.Split(','); 35 | string note = parts[0].Trim(); 36 | string duration = parts[1].Trim(); 37 | int[] intArray = {Int32.Parse(note),Int32.Parse(duration)}; 38 | Drop(p); 39 | _outport.Send(Create(intArray)); 40 | 41 | } 42 | 43 | } 44 | /* 45 | public override Object[] Introspect() 46 | { 47 | return new Object[] { 48 | "Convert comma-separated text to an array of ints", 49 | "IN", "input", Type.GetType("System.Object"), 50 | "input stream", 51 | "OUT", "output", Type.GetType("System.Int32[]"), 52 | "array of ints"}; 53 | } 54 | */ 55 | public override void OpenPorts() 56 | { 57 | 58 | _inport = OpenInput("IN"); 59 | // _inport.SetType(Type.GetType("System.Object")); 60 | 61 | _outport = OpenOutput("OUT"); 62 | 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalanceWithSubstreams/TestLoadBalanceWithSubstreams.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Components; 7 | using FBPLib; 8 | 9 | namespace TestNetworks 10 | { 11 | /** This network is intended to test LoadBalance component */ 12 | 13 | public class TestLoadBalanceWithSubstreams : Network 14 | { 15 | 16 | /* * 17 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 18 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 19 | * based on the Everything Development Company's Artistic License. A document describing 20 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 21 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 22 | * */ 23 | public override void Define() /* throws Throwable */ { 24 | // Component("MONITOR", Monitor)); 25 | // tracing = true; 26 | 27 | int multiplex_factor = 6; 28 | Component("generate", typeof(GenSS)); 29 | Component("display", typeof(WriteText)); 30 | Component("lbal", typeof(LoadBalance)); 31 | Component("SSMerge", typeof(SubstreamSensitiveMerge)); 32 | Connect("generate.OUT", "lbal.IN", 4); 33 | Initialize("100", Component("generate"), Port("COUNT")); 34 | for (int i = 0; i < multiplex_factor; i++) 35 | { 36 | Connect(Component("lbal"), Port("OUT", i), Component("passthru" + i, typeof(ProcessSlowly)), Port("IN"), 1); 37 | Connect(Component("passthru" + i), Port("OUT"), Component("SSMerge"),Port("IN", i), 1); 38 | } 39 | Connect("SSMerge.OUT", "display.IN", 4); 40 | Stream st = Console.OpenStandardOutput(); 41 | Initialize(st, 42 | Component("display"), 43 | Port("DESTINATION")); 44 | } 45 | [STAThread] 46 | public static void Main() 47 | { 48 | new TestLoadBalanceWithSubstreams().Go(); 49 | Console.Read(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /FBPLib/Lib/SubOut.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | 8 | /** Look after output from subnet - added for subnet support 9 | */ 10 | [InPort("NAME")] 11 | [InPort("IN")] 12 | public class SubOut : Component 13 | { 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | IInputPort _inport, _nameport; 22 | OutputPort _outport; 23 | 24 | 25 | public override void Execute() 26 | { 27 | Packet np = _nameport.Receive(); 28 | if (np == null) 29 | { 30 | return; 31 | } 32 | _nameport.Close(); 33 | string pname = np.Content as string; 34 | Drop(np); 35 | 36 | _outport = (_mother._outputPorts)[pname] as OutputPort; 37 | _mother.Trace(Name + ": Accessing output port: " + _outport.Name); 38 | _outport.SetSender(this); 39 | Packet p; 40 | while ((p = _inport.Receive()) != null) 41 | { 42 | _outport.Send(p); 43 | 44 | } 45 | 46 | // outport.close(); 47 | _mother.Trace(Name + ": Releasing output port: " + _outport.Name); 48 | _outport = null; 49 | } 50 | // public override Object[] Introspect() 51 | // { 52 | // return new Object[] { 53 | // "handles one output stream for subnet", 54 | // "NAME", "input", Type.GetType("System.String"), 55 | // "name of higher level output port", 56 | // "IN", "input", Type.GetType("System.Object"), 57 | // "input (from subnet) to external port"}; 58 | // } 59 | public override void OpenPorts() 60 | { 61 | 62 | _nameport = OpenInput("NAME"); 63 | _inport = OpenInput("IN"); 64 | } 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /TestNetworks/Networks/TestSockets.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | using Components; 7 | 8 | namespace TestNetworks.Networks 9 | { 10 | public class TestSockets : Network 11 | { 12 | /* * 13 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | public override void Define() { 20 | 21 | Component("Generate", typeof(GenerateTestData)); 22 | Component("WS", typeof(WriteToSocket)); 23 | Component("RS", typeof(ReadFromSocket)); 24 | Component("WS2", typeof(WriteToSocket)); 25 | Component("RS2", typeof(ReadFromSocket)); 26 | Component("Disp", typeof(Discard)); 27 | Component("Passthru", typeof(Passthru)); 28 | 29 | Connect("Generate.OUT", "WS.IN"); 30 | // connect WS to RS via socket! 31 | Connect("RS.OUT", "Passthru.IN"); 32 | Connect("Passthru.OUT", "WS2.IN"); 33 | // connect WS to RS via socket! 34 | Connect("RS2.OUT", "Disp.IN"); 35 | 36 | Initialize("10000", 37 | Component("Generate"), 38 | Port("COUNT")); 39 | 40 | //Stream st = Console.OpenStandardOutput(); 41 | //Initialize(st, 42 | // Component("Display"), 43 | // Port("DESTINATION")); 44 | 45 | Initialize("4444", 46 | Component("WS"), 47 | Port("PORT")); 48 | Initialize("4444", 49 | Component("RS"), 50 | Port("PORT")); 51 | 52 | Initialize("4445", 53 | Component("WS2"), 54 | Port("PORT")); 55 | Initialize("4445", 56 | Component("RS2"), 57 | Port("PORT")); 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /TestNetworks/Networks/VolumeTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | using Components; 6 | 7 | namespace TestNetworks.Networks 8 | { 9 | /** This network is intended for timing runs */ 10 | 11 | 12 | public class VolumeTest : Network 13 | { 14 | 15 | /* * 16 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 17 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 18 | * based on the Everything Development Company's Artistic License. A document describing 19 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 20 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 21 | * */ 22 | 23 | public override void Define() /* throws Throwable */ { 24 | Connect(Component("Generate", typeof(GenerateTestData)), 25 | Port("OUT"), 26 | Component("ReplString ", typeof(ReplString)), 27 | Port("IN")); 28 | Connect(Component("ReplString "), 29 | Port("OUT", 0), 30 | Component("ReplString 2", typeof(ReplString)), 31 | Port("IN")); 32 | Connect(Component("ReplString 2"), 33 | Port("OUT", 0), 34 | Component("ReplString 3", typeof(ReplString)), 35 | Port("IN")); 36 | Connect(Component("ReplString 3"), 37 | Port("OUT", 0), 38 | Component("ReplString 4", typeof(ReplString)), 39 | Port("IN")); 40 | Connect(Component("ReplString 4"), 41 | Port("OUT", 0), 42 | Component("ReplString 5", typeof(ReplString)), 43 | Port("IN")); 44 | Connect(Component("ReplString 5"), 45 | Port("OUT", 0), 46 | Component("ReplString 6", typeof(ReplString)), 47 | Port("IN")); 48 | Connect(Component("ReplString 6"), 49 | Port("OUT", 0), 50 | Component("ReplString 7", typeof(ReplString)), 51 | Port("IN")); 52 | Connect(Component("ReplString 7"), 53 | Port("OUT", 0), 54 | Component("ReplString 8", typeof(ReplString)), 55 | Port("IN")); 56 | 57 | Connect(Component("ReplString 8"), 58 | Port("OUT", 0), 59 | Component("Discard", typeof(Discard)), 60 | Port("IN")); 61 | 62 | Initialize("10000", 63 | Component("Generate"), 64 | Port("COUNT")); 65 | 66 | 67 | } 68 | internal static void main(String[] argv) { 69 | new VolumeTest().Go(); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /FBPLib/Lib/FlowError.cs: -------------------------------------------------------------------------------- 1 | namespace FBPLib 2 | { 3 | using System; 4 | 5 | 6 | /// Instances of this class are thrown whenever a programming error 7 | /// in a flow Network is detected. Nobody is expected to catch these, 8 | /// because they are considered indications of design errors, even though 9 | /// detected only at run-time. 10 | /// * 11 | /// 12 | 13 | public class FlowError : System.ApplicationException 14 | { 15 | /* * 16 | * Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, 17 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 18 | * based on the Everything Development Company's Artistic License. A document describing 19 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 20 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 21 | * */ 22 | /// Constructs a new FlowError with a useful (but non-localized) 23 | /// message as its text. FlowErrors without texts are not allowed, as 24 | /// these are considered bad practice. 25 | /// 26 | /// a description of the error 27 | /// * 28 | /// 29 | internal FlowError(string text) 30 | : base(text) 31 | { 32 | } 33 | /// A convenience method which constructs a new FlowError and 34 | /// throws it at once, typically never returning. 35 | /// 36 | /// a description of the error 37 | /// * 38 | /// 39 | public static void Complain(string text) 40 | { 41 | Console.Out.WriteLine(text); 42 | throw new FlowError(text); 43 | } 44 | public static void Assert(bool check, string message) 45 | { 46 | if (!check) 47 | Complain(message); 48 | } 49 | 50 | public static void Assert(bool check, string format, params object[] args) 51 | { 52 | if (!check) 53 | Complain(String.Format(format, args)); 54 | } 55 | public static void AssertNotNull(object arg, string argname) 56 | { 57 | if (arg == null) 58 | Complain(argname + " is null"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/GenerateTestData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FBPLib; 3 | 4 | namespace Components 5 | { 6 | 7 | /** Component to generate a stream of 'n' packets, where 'n' is 8 | * specified in an InitializationConnection. 9 | */ 10 | [InPort("COUNT", description="Number of packets", type=typeof(System.String))] 11 | [OutPort("OUT")] 12 | [ComponentDescription("Generate stream of packets based on count")] 13 | 14 | public class GenerateTestData : Component 15 | { 16 | 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | OutputPort _outport; 25 | IInputPort _count; 26 | 27 | 28 | public override void Execute() /* throws Throwable */ { 29 | Packet ctp = _count.Receive(); 30 | 31 | string param = ctp.Content.ToString(); 32 | Int32 ct = Int32.Parse(param); 33 | Drop(ctp); 34 | _count.Close(); 35 | 36 | for (int i = ct; i > 0; i--) 37 | { 38 | string s = String.Format("{0:d6}", i) + "abcd"; 39 | 40 | Packet p = Create(s); 41 | _outport.Send(p); 42 | 43 | 44 | } 45 | 46 | // output.close(); 47 | // terminate(); 48 | } 49 | /* 50 | public override System.Object[] Introspect() 51 | { 52 | 53 | return new Object[] { 54 | "generates a set of Packets under control of a counter" , 55 | "OUT", "output", Type.GetType("System.String"), 56 | "lines generated", 57 | "COUNT", "parameter", Type.GetType("System.String"), 58 | "Count of number of entities to be generated"}; 59 | } 60 | */ 61 | public override void OpenPorts() 62 | { 63 | 64 | _outport = OpenOutput("OUT"); 65 | // _outport.SetType(Type.GetType("System.String")); 66 | 67 | _count = OpenInput("COUNT"); 68 | // _count.SetType(Type.GetType("System.String")); 69 | 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Generate.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | using FBPLib; 5 | 6 | 7 | 8 | 9 | namespace Components 10 | { 11 | 12 | /** Component to generate a stream of 'n' packets, where 'n' is 13 | * specified in an InitializationConnection. 14 | */ 15 | [InPort("COUNT", description="Number of packets", type=typeof(System.String))] 16 | [OutPort("OUT")] 17 | [ComponentDescription("Generate stream of packets based on count")] 18 | 19 | public class Generate : Component 20 | { 21 | 22 | internal static string _copyright = 23 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 24 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 25 | "based on the Everything Development Company's Artistic License. A document describing " + 26 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 27 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 28 | 29 | OutputPort _outport; 30 | IInputPort _count; 31 | 32 | 33 | public override void Execute() /* throws Throwable */ { 34 | Packet ctp = _count.Receive(); 35 | 36 | string param = ctp.Content.ToString(); 37 | Int32 ct = Int32.Parse(param); 38 | Drop(ctp); 39 | _count.Close(); 40 | 41 | for (int i = ct; i > 0; i--) 42 | { 43 | string s = String.Format("{0:d6}", i) + "abcd"; 44 | 45 | Packet p = Create(s); 46 | _outport.Send(p); 47 | 48 | 49 | } 50 | 51 | // output.close(); 52 | // terminate(); 53 | } 54 | /* 55 | public override System.Object[] Introspect() 56 | { 57 | 58 | return new Object[] { 59 | "generates a set of Packets under control of a counter" , 60 | "OUT", "output", Type.GetType("System.String"), 61 | "lines generated", 62 | "COUNT", "parameter", Type.GetType("System.String"), 63 | "Count of number of entities to be generated"}; 64 | } 65 | */ 66 | public override void OpenPorts() 67 | { 68 | 69 | _outport = OpenOutput("OUT"); 70 | // _outport.SetType(Type.GetType("System.String")); 71 | 72 | _count = OpenInput("COUNT"); 73 | // _count.SetType(Type.GetType("System.String")); 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /FBPLib/Lib/SubOutSS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | 8 | /** Look after output from subnet - added for subnet support 9 | * Substream Sensitive SubOut 10 | */ 11 | [InPort("NAME")] 12 | [InPort("IN")] 13 | public class SubOutSS : Component 14 | { 15 | /* * 16 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 17 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 18 | * based on the Everything Development Company's Artistic License. A document describing 19 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 20 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 21 | * */ 22 | IInputPort _inport, _nameport; 23 | OutputPort _outport; 24 | 25 | 26 | public override void Execute() 27 | { 28 | Packet np = _nameport.Receive(); 29 | if (np == null) 30 | { 31 | return; 32 | } 33 | _nameport.Close(); 34 | string pname = np.Content as string; 35 | Drop(np); 36 | 37 | _outport = (_mother._outputPorts)[pname] as OutputPort; 38 | _mother.Trace(Name + ": Accessing output port: " + _outport.Name); 39 | _outport.SetSender(this); 40 | Packet p; 41 | p = Create(Packet.Types.Open, ""); 42 | _outport.Send(p); 43 | while ((p = _inport.Receive()) != null) 44 | { 45 | _outport.Send(p); 46 | 47 | } 48 | p = Create(Packet.Types.Close, ""); 49 | _outport.Send(p); 50 | 51 | // outport.close(); 52 | _mother.Trace(Name + ": Releasing output port: " + _outport.Name); 53 | _outport = null; 54 | } 55 | //public override Object[] Introspect() 56 | //{ 57 | // return new Object[] { 58 | // "handles one output stream for subnet", 59 | // "NAME", "input", Type.GetType("System.String"), 60 | // "name of higher level output port", 61 | // "IN", "input", Type.GetType("System.Object"), 62 | // "input (from subnet) to external port"}; 63 | // } 64 | public override void OpenPorts() 65 | { 66 | 67 | _nameport = OpenInput("NAME"); 68 | _inport = OpenInput("IN"); 69 | } 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/WriteToConsole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FBPLib; 3 | 4 | 5 | namespace Components 6 | { 7 | /** 8 | * Component to write data to console. 9 | */ 10 | 11 | [InPort("IN")] 12 | [OutPort("OUT", optional = true)] 13 | [ComponentDescription("Write text to console")] 14 | 15 | public class WriteToConsole : Component 16 | { 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | 25 | IInputPort _inport; 26 | OutputPort _outport; 27 | static string _linesep = System.Environment.NewLine; 28 | double _timeout = 2.0; // 2 secs 29 | 30 | public override void OpenPorts() 31 | { 32 | _inport = OpenInput("IN"); 33 | _outport = OpenOutput("OUT"); 34 | } 35 | 36 | public override void Execute() /*throws Throwable*/ 37 | { 38 | Packet p; 39 | while ((p = _inport.Receive()) != null) 40 | { 41 | string line = p.Content as string; 42 | LongWaitStart(_timeout); 43 | //Thread.Sleep(3000); // testing only 44 | if (p.Type == Packet.Types.Open) 45 | Console.Out.WriteLine("==> Open Bracket"); 46 | else 47 | if (p.Type == Packet.Types.Close) 48 | Console.Out.WriteLine("==> Close Bracket"); 49 | else 50 | if (p.Content == null) 51 | Console.Out.WriteLine("null"); 52 | else 53 | Console.Out.WriteLine(p.Content); 54 | //} 55 | LongWaitEnd(); 56 | if (_outport.IsConnected()) 57 | { 58 | _outport.Send(p); 59 | } 60 | else 61 | { 62 | Drop(p); 63 | } 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /TestCases/MergeAndSort/MergeAndSort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Components; 4 | using FBPLib; 5 | 6 | 7 | namespace TestNetworks 8 | { 9 | public class MergeAndSort : Network 10 | { 11 | 12 | /* * 13 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 14 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 15 | * based on the Everything Development Company's Artistic License. A document describing 16 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 17 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 18 | * */ 19 | 20 | public override void Define() /* throws Throwable */ { 21 | 22 | 23 | Component("Generate", typeof(GenerateTestData)); 24 | Component("ProcessWRandDelays", typeof(ProcessWRandDelays)); 25 | Component("ProcessWRandDelays2", typeof(ProcessWRandDelays)); 26 | Component("Sort", typeof(Sort)); 27 | Component("Write", typeof(WriteToConsole)); 28 | 29 | Connect(Component("Generate"), 30 | Port("OUT"), 31 | Component("ProcessWRandDelays"), 32 | Port("IN")); 33 | 34 | Connect("ProcessWRandDelays2.OUT", "ProcessWRandDelays.IN"); 35 | Initialize("120", 36 | Component("Generate"), 37 | Port("COUNT")); 38 | 39 | Connect(Component("Generate2", typeof(GenerateTestData)), 40 | Port("OUT"), 41 | Component("ProcessWRandDelays2"), 42 | Port("IN")); 43 | 44 | Connect("ProcessWRandDelays.OUT", "Sort.IN"); 45 | 46 | Initialize("75", 47 | Component("Generate2"), 48 | Port("COUNT")); 49 | 50 | Connect(Component("Sort"), 51 | Port("OUT"), 52 | Component("Write"), 53 | Port("IN")); 54 | 55 | 56 | 57 | } 58 | /// 59 | /// The main entry point for the application. 60 | /// 61 | [STAThread] 62 | public static void Main() 63 | { 64 | //Application.EnableVisualStyles(); 65 | //Application.SetCompatibleTextRenderingDefault(false); 66 | 67 | 68 | for (int i = 0; i <10; i++) 69 | new MergeAndSort().Go(); 70 | //Console.Read(); 71 | } 72 | 73 | } 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Match.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | using FBPLib; 7 | 8 | 9 | namespace Components 10 | { 11 | [InPort("IN")] 12 | [InPort("CONFIG")] 13 | [OutPort("OUTN")] 14 | [OutPort("OUT")] 15 | [ComponentDescription("Read from IN, compare to Regex in CONFIG, write to OUT if match, else OUTN")] 16 | 17 | public class Match : Component 18 | { 19 | // Regex code contributed by David Bennett 20 | 21 | internal static string _copyright = 22 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 23 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 24 | "based on the Everything Development Company's Artistic License. A document describing " + 25 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 26 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 27 | 28 | IInputPort _inp; 29 | IInputPort _cfgp; 30 | OutputPort _outp; 31 | OutputPort _outpn; 32 | /* 33 | public override object[] Introspect() 34 | { 35 | return new object[] { 36 | "Read from IN, compare to Regex in CONFIG, write to OUT if match else OUTN.", 37 | "Looper. N->M+~M" 38 | }; 39 | } 40 | */ 41 | public override void OpenPorts() 42 | { 43 | _cfgp = OpenInput("CONFIG"); 44 | _inp = OpenInput("IN"); 45 | _outp = OpenOutput("OUT"); 46 | _outpn = OpenOutput("OUTN"); 47 | 48 | } 49 | 50 | public override void Execute() 51 | { 52 | Regex regex = null; 53 | Packet p = _cfgp.Receive(); 54 | string pattern = p.Content.ToString(); 55 | try 56 | { 57 | regex = new Regex(pattern); 58 | } 59 | catch (Exception) 60 | { 61 | FlowError.Complain("invalid regular expression " + pattern); 62 | } 63 | Drop(p); 64 | _cfgp.Close(); 65 | 66 | for (p = _inp.Receive(); p != null; p = _inp.Receive()) 67 | { 68 | if (regex.IsMatch(p.Content.ToString())) 69 | _outp.Send(p); 70 | else 71 | _outpn.Send(p); 72 | } 73 | } 74 | 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/ReplString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | namespace Components 7 | { 8 | /** Replicate a stream of Packets to 'n' output streams, where 9 | * each Packet points at a String. 10 | * Note: this is a specific variant of the general Replicate verb (q.v.) 11 | **/ 12 | [InPort("IN")] 13 | [OutPort("OUT", arrayPort=true)] 14 | [ComponentDescription("Replicates input stream and sends copies to array port OUT")] 15 | public class ReplString : Component 16 | { 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | 25 | IInputPort _inport; 26 | OutputPort[] _outportArray; 27 | 28 | public override void Execute() /* throws Throwable */ { 29 | 30 | int no = _outportArray.Length; 31 | 32 | Packet p; 33 | long count = 0; 34 | while ((p = _inport.Receive()) != null) 35 | { 36 | ++count; 37 | string o = (string)p.Content; 38 | Drop(p); 39 | 40 | for (int i = 0; i < no; i++) 41 | { 42 | string o2 = o + ""; 43 | 44 | Packet p2 = Create(o2); 45 | _outportArray[i].Send(p2); 46 | 47 | // else System.out.println( "Line written " + count + " by" + getName()); 48 | } 49 | } 50 | Console.Out.WriteLine("Repl complete. " + Name); 51 | } 52 | /* 53 | public override Object[] Introspect() 54 | { 55 | return new Object[] { 56 | "replicates input stream at port IN and sends them to array port OUT", 57 | "IN", "input", Type.GetType("System.Object"), 58 | "input stream", 59 | "OUT", "output", Type.GetType("System.Object"), 60 | "multiple output streams"}; 61 | } 62 | */ 63 | public override void OpenPorts() 64 | { 65 | 66 | _inport = OpenInput("IN"); 67 | // _inport.SetType(Type.GetType("System.Object")); 68 | 69 | _outportArray = OpenOutputArray("OUT"); 70 | 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /TestCases/Concord/resources/fake_japanese.txt: -------------------------------------------------------------------------------- 1 | 饦ざ仯ギひゅ ゐ壌奤㨣䏦 婩䤨 ナ橣榟, けしゃ ぞ穃め窣基 レ゜よ䰥ひょあ 饦ざ仯, 奤㨣 にゅ駤ぢゃ䋩ぴゅ 姎じわほチュ 娩ゞ鰦饺駣 揨知ぎゃ あトゥ奊 韥ミョ 襦楎にひゃ焣 婩䤨ぎごふ びゃぶ鏧黧ラ゜ な儦く 窣基 襦楎にひゃ焣 饦ざ仯ギひゅ ぞ穃め窣基 き妦ちょクォづ 囨ッぐしょ裟 しゅせ焨祣盯 らヴュぱ 矩馩, 覦饊 饨覨はぴゃぎゅ 襦楎にひゃ焣 儦くリ゜穯廥 ゑにょみょ, 簯襊荤駧諯 きょ獧䋯穨黨 ジョ秞郎䧦靨 䏦イィ ほチュレ゜ リ゜穯 訊らヴュぱで 儦くリ゜穯廥 䋩ぴゅ矩, 骦椢 きゃ䥺訊 イィ䥞シュきゃ䥺 姨榚堩が騧, ッぐ 堩が騧 囨ッぐしょ裟 にゅ駤ぢゃ䋩ぴゅ 姎じわほチュ 訊らヴュぱで しゅせ焨祣盯 儦くリ゜穯廥 ちょクォづ テち 2 | 3 | 骦椢 フぼ䝧へ覧 ぞ穃め窣基 揣ゔびょ奯禺 りゅ揧鎌, 氩曣 フャゝ楌 ぴょ檨れ谯睢 楌嫧覥樦骤, ふ姨榚 みゅ择 饊嫣妧 てを 焧觃奟覵狥 ほチュレ゜ ジョ秞郎䧦靨 娩ゞ鰦饺駣 にょみょ, そディべうウ 饦ざ仯ギひゅ 嶥婨けしゃにゃ 䋯穨黨 姚そ へ覧 ん楟もい稪 イィ䥞シュきゃ䥺 で襟䨦, てを 囨ッぐしょ裟 イィ䥞シュきゃ䥺 ぢょナ橣榟ぜ ウき妦, 穃め 媯蟤ね 勯む䦪驚䛨 ぴょ檨れ谯睢 ぢょナ橣榟ぜ 槣フュ棃 簯襊荤駧諯 襟䨦媯蟤ね ハし䧟䧣滧 大と, イィ䥞シュきゃ䥺 蟦げえど妤 谧た韥ミョヴィ 蟦げえ 骦椢 妧 てを 囨ッぐしょ裟 勯む䦪驚䛨 しゅせ焨祣盯 にひゃ, 襦楎にひゃ焣 趣夯りゅ揧鎌 覦饊 飌チョ尥, 簯襊 ど妤婩 ん楟もい稪 趣夯りゅ揧鎌 詃サ揨知ぎゃ レ゜よ䰥ひょあ 蟦げえど妤 ゑにょみょ氧褚 榚堩 ぜ趣夯, 䋯穨黨 きゃ䥺 きょ獧䋯穨黨 しゅせ焨祣盯 杧ひ詧襞か 4 | 5 | 盯詃サ 滩馺䧎ゆ土 檧訦みゅ择ろ 窣基 卣ぬ 襟䨦媯蟤ね 姨榚堩が騧 テちば, 駧諯ん ちょクォ フぼ䝧へ覧 娩ゞ鰦饺駣 き妦 䋯穨黨 卣ぬ大とウゥ 姨榚堩が騧 みゃな 杧ひ詧襞か 蟦げえど妤 䰦婧蟥みゃな とウゥ勯, 祣盯 揨知ぎゃ そディべうウ びゃぶ鏧黧ラ゜ とウゥ勯 卣ぬ大とウゥ 滩馺䧎ゆ土 檧訦みゅ择ろ ッぐ, き妦ちょクォづ 襦楎にひゃ焣 ゆ土 奟覵狥, ざ仯 奟覵狥 フぼ䝧へ覧 簯襊荤駧諯 6 | 7 | 荤駧 そディべうウ 襨槣フュ棃覦 訊らヴュぱで ジョ秞郎, 饊嫣妧 てを ゐ壌奤㨣䏦 穃め 埥トぞ にゃ娩ゞ 骦椢功ヒェ姚 ぞ穃め窣基 ゐ壌奤㨣䏦 にゃ娩 滩馺䧎 骦椢功ヒェ姚 ぴょ檨れ谯睢 尥埥, そディべうウ ゑにょみょ氧褚 ど妤婩 びょ奯, 杧ひ 䧣滧びゃ き妦ちょクォづ 襦楎にひゃ焣 ぴ秤ビョ褦䧨 矩馩 䋯穨黨 饊嫣妧 てを 杧ひ詧襞か 娩ゞ鰦饺駣, 媯蟤ね 襨槣フュ棃覦 娩ゞ鰦饺駣 ぴ秤, 訊らヴュぱで きょ獧䋯穨黨 トゥ奊す氩曣 リ゜穯廥 り坣 8 | 9 | 穨黨 そディべうウ ぞ穃め窣基 ゑにょみょ氧褚 駧諯ん, で襟 襨槣フュ棃覦 ぢょナ橣榟ぜ 盯詃サ にゃ娩ゞ 大と りゃこヂュ砥ぎょ 趣夯りゅ揧鎌, にひゃ焣 矩馩 襟䨦媯蟤ね ぢょナ橣榟ぜ 婩䤨ぎごふ じわ 埥トぞ ん楟もい稪 襟䨦媯蟤ね 蟦げえど妤, フャゝ楌 ジョ秞郎䧦靨 ハし䧟䧣滧 訊ら, そディべうウ 饦ざ仯ギひゅ りゃこヂュ砥ぎょ にゅ駤ぢゃ ヂュ砥 蟦げえ ぎご 簯襊荤駧諯 襨槣フュ棃覦 揣ゔびょ奯禺, 婨けしゃ ビョ褦 にゅ駤ぢゃ䋩ぴゅ 綦礨期グォ褤, 䋯穨黨 襟䨦媯蟤ね 揣ゔびょ奯禺 楌嫧覥樦骤 禺きょ 饊嫣妧 てを ぞ穃め窣基 ゐ壌奤㨣䏦 䋩ぴゅ矩 嫣妧, そディべうウ .涥娪フャゝ 大と .涥娪 10 | 11 | 囨ッぐしょ裟 りゃこヂュ砥ぎょ ぴ秤ビョ褦䧨 リ゜穯廥 榟ぜ, ぷぴょ ナ橣榟 囨ッぐしょ裟 ジョ秞郎䧦靨 儦くリ゜穯廥 イィ䥞シュきゃ䥺 卣ぬ大とウゥ グォ褤 駧諯ん, 襦楎にひゃ焣 りゃこヂュ砥ぎょ 尥埥 檧訦みゅ 娪フャ ナ橣榟 ゐ壌奤㨣䏦 綦礨期グォ褤, 䧦靨綦 ちょクォ 襟䨦媯蟤ね ゑにょみょ氧褚 禺きょ 卣ぬ大とウゥ 姨榚堩が騧 ナ橣榟 嶥婨 ゐ壌奤㨣䏦 卣ぬ大とウゥ リ゜穯廥, 趣夯 ん楟もい稪 卣ぬ大とウゥ 焧觃奟覵狥 ゑにょみょ 12 | 13 | ウき妦 骦椢功ヒェ姚 りゃこヂュ砥ぎょ 娪フャ にひゃ焣 し䧟 そディべうウ 杧ひ詧襞か, 飌チョ尥 ナ橣 骦椢功ヒェ姚 にゅ駤ぢゃ䋩ぴゅ, ぎゅフ 饊嫣妧 てを 谧た韥ミョヴィ な儦く り坣テちば 趣夯りゅ揧鎌 䰦婧蟥みゃな 䧦靨綦 ビョ褦, 䋯穨黨 ジョ秞 襦楎にひゃ焣 飌チョ尥埥ト ぢょナ橣榟ぜ, 囨ッぐしょ裟 綦礨期グォ褤 ゑにょみょ氧褚 䛨り坣 ぎゅフ しゅせ焨祣盯 トゥ奊す氩曣 .涥娪フャゝ す氩曣 ぷぴょ 饨覨はぴゃぎゅ 姨榚堩が騧 はぴゃ 䧣滧びゃ, 趣夯 ディべう き妦ちょクォづ 谧た韥ミョヴィ 14 | 15 | しょ裟饨 奤㨣 フぼ䝧へ覧 レ゜よ䰥ひょあ 䰦婧蟥みゃな, 氧褚 .涥娪 囨ッぐしょ裟 婩䤨ぎごふ 䰦婧蟥みゃな ウゥ勯 囨ッぐしょ裟 卣ぬ大とウゥ 蟦げえど妤 よ䰥ひょ, .涥 䝧へ覧 きょ獧䋯穨黨 レ゜よ䰥ひょあ らヴュぱ き妦ちょクォづ ぴょ檨れ谯睢 杧ひ詧襞か 郎䧦, 谧た韥 きょ獧䋯穨黨 蟦げえど妤 谧た韥ミョヴィ 娪フャ ヴィ䰦 襦楎にひゃ焣 訊らヴュぱで ぶ鏧黧, 矩馩 滩馺䧎 骦椢功ヒェ姚 詃サ揨知ぎゃ, き妦 䤨ぎご 饨覨はぴゃぎゅ 勯む䦪驚䛨 16 | 17 | 綦礨期グォ褤 儦くリ゜穯廥 へ覧 婨けしゃ, 骦椢功ヒェ姚 綦礨期グォ褤 で襟䨦 氩曣 獧䋯 ウき妦 饨覨はぴゃぎゅ 綦礨期グォ褤 ハし䧟䧣滧, 祣盯 砥ぎょぢょ そディべうウ 囨ッぐしょ裟 趣夯りゅ揧鎌, ラ゜焧 骦椢功ヒェ姚 簯襊荤駧諯 ぴ秤ビョ褦䧨 槣フュ棃 婧蟥みゃ 禺きょ 饊嫣妧 てを 揣ゔびょ奯禺 綦礨期グォ褤, ゐ壌 饨覨はぴゃぎゅ 卣ぬ大とウゥ 婧蟥みゃ, 訊ら 飌チョ尥埥ト にゅ駤ぢゃ䋩ぴゅ フャゝ楌 䧨ゑ 襦楎にひゃ焣 飌チョ尥埥ト ゑにょみょ氧褚 ぜ趣夯, せ焨 砥ぎょぢょ ん楟もい稪 襟䨦媯蟤ね 勯む䦪驚䛨 ぴょ檨れ谯睢 綦礨期グォ褤 趣夯 ふ姨榚 ばにゅ な儦く 矩馩楯ちゅぷ 楌嫧覥樦骤 18 | 19 | 䥞シュ 婨けしゃ 囨ッぐしょ裟 襦楎にひゃ焣 りゃこヂュ砥ぎょ 奤㨣䏦 ぴ秤 ん楟もい稪 きょ獧䋯穨黨, 囨ッぐ 祣盯 饨覨はぴゃぎゅ り坣テちば 杧ひ詧襞か 襨槣フュ棃覦 飌チョ尥埥ト 詃サ れ谯睢 砥ぎょぢょ 觃奟 骦椢功ヒェ姚 飌チョ尥埥ト 杧ひ詧襞か, い稪 䋯穨黨 蟦げえど妤 ぴ秤ビョ褦䧨 20 | -------------------------------------------------------------------------------- /TestCases/Concord/Concordance.cs: -------------------------------------------------------------------------------- 1 | 2 | using FBPLib; 3 | using Components; 4 | using System.Windows.Forms; 5 | using System.IO; 6 | using System; 7 | 8 | namespace Concord 9 | { 10 | class Concordance : Network 11 | { 12 | public override void Define() 13 | { 14 | 15 | Component("Dir1", typeof(DirList)); 16 | Component("Match", typeof(Match)); 17 | Component("Show3", typeof(WriteTextBox)); 18 | Component("Read", typeof(ReadStreamBlob)); 19 | Component("Clean", typeof(CleanBlob)); 20 | Component("Words", typeof(TextToWords)); // drop words of 3 characters or less 21 | Component("DisplayWords", typeof(DisplayWords)); 22 | Component("Sort", typeof(Sort)); 23 | Component("Format", typeof(FormatConcord)); 24 | Component("Show1", typeof(WriteTextBox)); 25 | Component("Show2", typeof(WriteTextBox)); 26 | 27 | string currentDir = Environment.CurrentDirectory; 28 | //DirectoryInfo directory = new DirectoryInfo( 29 | // Path.GetFullPath(Path.Combine(currentDir, @"..\..\Resources"))); 30 | Initialize(Path.GetFullPath(Path.Combine(currentDir, @"..\..\Resources\")), "Dir1.IN"); 31 | Initialize(@"fake_cy", "Match.CONFIG"); 32 | Initialize(@"5,50", "Format.CONFIG"); 33 | TextBox tb = parms[0] as TextBox; 34 | TextBox tb2 = parms[1] as TextBox; 35 | TextBox tb3 = parms[2] as TextBox; 36 | Initialize(tb, "Show1.DESTINATION"); 37 | Initialize(tb2, "Show2.DESTINATION"); 38 | Initialize(tb3, "Show3.DESTINATION"); 39 | 40 | Connect("Dir1.OUTF", "Match.IN"); 41 | Connect("Match.OUT", "Show3.IN"); 42 | Connect("Show3.OUT", "Read.IN"); 43 | Connect("Read.OUT", "Clean.IN"); 44 | Connect("Clean.OUT", "Words.IN"); 45 | Connect("Words.OUT", "DisplayWords.IN"); 46 | Connect("DisplayWords.OUT", "Sort.IN"); 47 | Connect("DisplayWords.OUTD", "Show1.IN"); 48 | Connect("Sort.OUT", "Format.IN"); 49 | Connect("Format.OUT", "Show2.IN"); 50 | 51 | Component("Discard1", typeof(Discard)); 52 | Component("Discard2", typeof(Discard)); 53 | Component("Discard3", typeof(Discard)); 54 | Component("Discard4", typeof(Discard)); 55 | Connect("Dir1.OUT", "Discard1.IN"); 56 | Connect("Dir1.OUTD", "Discard2.IN"); 57 | Connect("Match.OUTN", "Discard3.IN"); 58 | Connect("Words.OUTN", "Discard4.IN"); 59 | Connect("Show1.OUT", "Discard4.IN"); 60 | Connect("Show2.OUT", "Discard4.IN"); 61 | 62 | 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/FormatConcord.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | using FBPLib; 7 | 8 | 9 | namespace Components 10 | { 11 | [InPort("IN")] 12 | [InPort("CONFIG")] 13 | [OutPort("OUT")] 14 | [ComponentDescription("Read a word from IN, write a concordance line to OUT")] 15 | public class FormatConcord : Component 16 | { 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | IInputPort _inp; 25 | OutputPort _outp; 26 | IInputPort _cfgp; 27 | int _linlen = -1; 28 | int _wordoff = -1; 29 | 30 | 31 | /* 32 | public override object[] Introspect() 33 | { 34 | return new object[] { 35 | "Read a word from IN, write a concordance line to OUT.", 36 | "Uses attributes: Text and Offset", 37 | "Non-looper. 1->1" 38 | }; 39 | } 40 | */ 41 | public override void OpenPorts() 42 | { 43 | _inp = OpenInput("IN"); 44 | _cfgp = OpenInput("CONFIG"); 45 | _outp = OpenOutput("OUT"); 46 | } 47 | 48 | 49 | public override void Execute() 50 | { 51 | Packet p; 52 | if (null != (p = _cfgp.Receive())) 53 | { 54 | string param = p.Content.ToString(); 55 | string[] words = param.Split(','); 56 | _wordoff = Int32.Parse(words[0]); 57 | _linlen = Int32.Parse(words[1]); 58 | Drop(p); 59 | _cfgp.Close(); 60 | } 61 | 62 | p = _inp.Receive(); 63 | string word = p.Content.ToString(); 64 | string text = p.Attributes["Text"] as string; 65 | 66 | text = new string(' ', _linlen) + text + new string(' ', _linlen); 67 | int offset = (int)p.Attributes["Offset"]; 68 | int i = offset + _linlen - _wordoff; 69 | int j = text.Length - i; 70 | j = j < _linlen ? j : _linlen; 71 | string line = text.Substring(i, j); 72 | line = line.Substring(0, _wordoff) + "*" + line.Substring(_wordoff); 73 | _outp.Send(Create(line)); 74 | Drop(p); 75 | 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /TestNetworks/Networks/NoDeadlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using FBPLib; 4 | using Components; 5 | 6 | namespace TestNetworks.Networks 7 | { 8 | /** This network is similar to the one called Deadlock, but has been modified slightly 9 | so that it doesn't deadlock */ 10 | 11 | public class NoDeadlock : Network 12 | { 13 | 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | public override void Define() /* throws Throwable */ { 22 | // component("MONITOR", Monitor.class); 23 | Component("Passthru", typeof(Passthru)); 24 | Component("Passthru2", typeof(Passthru)); 25 | Connect(Component("Read", typeof(ReadText)), 26 | Port("OUT"), 27 | Component("Splitter1", typeof(Splitter1)), 28 | Port("IN")); 29 | Object d = (Object)@"..\..\mfile"; 30 | Initialize(d, 31 | Component("Read"), 32 | Port("SOURCE")); 33 | 34 | Connect(Component("Splitter1"), 35 | Port("OUT", 0), 36 | Component("Concatenate", typeof(Concatenate)), 37 | Port("IN", 0)); 38 | 39 | Connect(Component("Concatenate"), 40 | Port("OUT"), 41 | Component("Discard", typeof(Discard)), 42 | Port("IN")); 43 | 44 | Connect(Component("Splitter1"), 45 | Port("OUT", 1), 46 | Component("Passthru"), 47 | Port("IN")); 48 | Connect(Component("Passthru"), 49 | Port("OUT"), 50 | Component("Concatenate"), 51 | Port("IN", 1)); 52 | 53 | Connect(Component("Splitter1"), 54 | Port("OUT[2]"), 55 | Component("Concatenate"), 56 | Port("IN[2]")); 57 | Connect(Component("Splitter1"), 58 | Port("OUT[3]"), 59 | Component("Passthru2"), 60 | Port("IN")); 61 | Connect(Component("Passthru2"), 62 | Port("OUT"), 63 | Component("Concatenate"), 64 | Port("IN[3]")); 65 | Connect(Component("Splitter1"), 66 | Port("OUT[4]"), 67 | Component("Concatenate"), 68 | Port("IN[4]")); 69 | Connect(Component("Splitter1"), 70 | Port("OUT[5]"), 71 | Component("Concatenate"), 72 | Port("IN[5]")); 73 | Connect(Component("Splitter1"), 74 | Port("OUT[6]"), 75 | Component("Concatenate"), 76 | Port("IN[6]")); 77 | } 78 | static void main(String[] argv) { 79 | new NoDeadlock().Go(); 80 | } 81 | 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /FBPLib/Lib/IInputPort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | 8 | /// This interface is used within Components to declare instance variables 9 | /// that hold input ports. Such instance variables should be assigned 10 | /// within the openPorts routine of the Component and never 11 | /// changed thereafter. Packets can be received, and the status of the 12 | /// port manipulated, using the API specified by this interface. 13 | ///

This is a bit misleading, as it is the Connection object which holds IPs, not 14 | /// the InputPort. 15 | /// * 16 | ///

17 | 18 | public interface IInputPort 19 | { 20 | /* * 21 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 22 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 23 | * based on the Everything Development Company's Artistic License. A document describing 24 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 25 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 26 | * */ 27 | /// The maximum number of packets which this InputPort can hold. 28 | /// 29 | /// maximum packet count 30 | /// * 31 | /// 32 | //string GetName(); 33 | string Name {get; set;} 34 | int Capacity(); 35 | /// Close Initialization Connection (dummy method) 36 | /// 37 | void Close(); 38 | /// Return the number of packets currently at this Input Port. 39 | /// 40 | int Count(); 41 | Component Receiver { get; set;} 42 | void SetReceiver(Component receiver); 43 | 44 | 45 | /// Receive the next available packet from this InputPort. 46 | /// The thread is suspended if no packets are currently available. 47 | /// At the end of input (when all upstream threads have closed their 48 | /// connected OutputPorts), null is returned. 49 | /// 50 | /// next packet, null if none 51 | /// * 52 | /// 53 | Packet Receive(); 54 | /* 55 | /// Specify the type of packet content that will be accepted from this 56 | /// InputPort. Specifying null is equivalent to specifying 57 | /// Object.class -- in other words, any packet content is 58 | /// acceptable. 59 | /// 60 | /// the class of acceptable packet content 61 | /// * 62 | /// 63 | void SetType(System.Type type); 64 | */ 65 | 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/GenSS.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | using System; 4 | using FBPLib; 5 | 6 | 7 | 8 | 9 | namespace Components 10 | { 11 | 12 | /** Component to generate a stream of 'n' packets, where 'n' is 13 | * specified in an InitializationConnection. 14 | */ 15 | [InPort("COUNT")] 16 | [OutPort("OUT")] 17 | [ComponentDescription("Generate packets based on count, inserting brackets between every 5 packets")] 18 | 19 | public class GenSS : Component 20 | { 21 | 22 | internal static string _copyright = 23 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 24 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 25 | "based on the Everything Development Company's Artistic License. A document describing " + 26 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 27 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 28 | 29 | OutputPort _outport; 30 | IInputPort _count; 31 | 32 | 33 | public override void Execute() /* throws Throwable */ { 34 | Packet ctp = _count.Receive(); 35 | 36 | string param = ctp.Content.ToString(); 37 | Int32 ct = Int32.Parse(param); 38 | Drop(ctp); 39 | _count.Close(); 40 | 41 | Packet p = Create(Packet.Types.Open, ""); 42 | _outport.Send(p); 43 | 44 | for (int i = 0; i < ct; i++) 45 | { 46 | if (i % 20 == 4) 47 | { 48 | p = Create(Packet.Types.Close, ""); 49 | _outport.Send(p); 50 | p = Create(Packet.Types.Open, ""); 51 | _outport.Send(p); 52 | } 53 | int j = 100 - i; 54 | string s = String.Format("{0:d4}", j) + " abc"; 55 | 56 | p = Create(s); 57 | _outport.Send(p); 58 | } 59 | p = Create(Packet.Types.Close, ""); 60 | _outport.Send(p); 61 | // output.close(); 62 | // terminate(); 63 | } 64 | /* 65 | public override System.Object[] Introspect() 66 | { 67 | 68 | return new Object[] { 69 | "generates a set of Packets under control of a counter" , 70 | "OUT", "output", Type.GetType("System.String"), 71 | "lines read", 72 | "COUNT", "parameter", Type.GetType("System.String"), 73 | "Count of number of entities to be generated"}; 74 | } 75 | */ 76 | public override void OpenPorts() 77 | { 78 | 79 | _outport = OpenOutput("OUT"); 80 | // _outport.SetType(Type.GetType("System.String")); 81 | 82 | _count = OpenInput("COUNT"); 83 | // _count.SetType(Type.GetType("System.String")); 84 | 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /FBPLib/Lib/PacketBuffer.cs: -------------------------------------------------------------------------------- 1 | /// This class is founded on Doug Lea's BoundedBuffer class 2 | /// from his book _Concurrent Programming in Java_. 3 | /// 4 | namespace FBPLib 5 | { 6 | using System; 7 | 8 | internal class PacketBuffer 9 | { 10 | /* * 11 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 12 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 13 | * based on the Everything Development Company's Artistic License. A document describing 14 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 15 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 16 | * */ 17 | // The packets currently in transit. 18 | internal Packet[] _array; 19 | 20 | // Index into array where the next packet sent should go. 21 | internal int _sendPtr = 0; 22 | 23 | // Index into array where the next packet received should come from. 24 | internal int _receivePtr = 0; 25 | 26 | // Number of slots in array currently in use. 27 | internal int _usedSlots = 0; 28 | 29 | 30 | internal PacketBuffer(int size) 31 | { 32 | _array = new Packet[size]; 33 | } 34 | /// Returns the number of packets this buffer can hold. 35 | /// 36 | internal virtual int Capacity() 37 | { 38 | return _array.Length; 39 | } 40 | /// Return the number of packets currently in this buffer. 41 | /// 42 | //UPGRADE_NOTE: Synchronized keyword was removed from method 'count'. Lock expression was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1027"' 43 | internal virtual int Count() 44 | { 45 | lock (this) 46 | { 47 | return _usedSlots; 48 | } 49 | } 50 | 51 | internal virtual void Put(Packet x) 52 | { 53 | _array[_sendPtr] = x; 54 | if (++_sendPtr >= _array.Length) 55 | _sendPtr = 0; 56 | IncUsedSlots(); 57 | } 58 | internal virtual Packet Take() 59 | { 60 | --_usedSlots; 61 | Packet old = _array[_receivePtr]; 62 | _array[_receivePtr] = null; 63 | if (++_receivePtr >= _array.Length) 64 | _receivePtr = 0; 65 | return old; 66 | } 67 | 68 | //UPGRADE_NOTE: Synchronized keyword was removed from method 'incUsedSlots'. Lock expression was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1027"' 69 | protected internal virtual void IncUsedSlots() 70 | { 71 | lock (this) 72 | { 73 | ++_usedSlots; 74 | // System.Threading.Monitor.Pulse(this); 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/ReadStreamBlob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using FBPLib; 6 | 7 | 8 | namespace Components 9 | { 10 | [InPort("IN")] 11 | [InPort("CONFIG")] 12 | [OutPort("OUT")] 13 | [ComponentDescription("Read name of input file from IN, output contents as blob to OUT")] 14 | public class ReadStreamBlob : Component 15 | { 16 | /* Thanks to David Bennett, Melbourne, Australia */ 17 | internal static string _copyright = 18 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 19 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 20 | "based on the Everything Development Company's Artistic License. A document describing " + 21 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 22 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 23 | 24 | IInputPort _inp; 25 | OutputPort _outp; 26 | IInputPort _cfgp; 27 | double _timeout = 3.0; 28 | /* 29 | public override object[] Introspect() 30 | { 31 | return new object[] { 32 | "Read name of input file from IN, output contents as blob to OUT", 33 | "Sets attributes: Path=input path", 34 | "Non-looper. 1->1" 35 | }; 36 | } 37 | */ 38 | public override void OpenPorts() 39 | { 40 | _inp = OpenInput("IN"); 41 | _outp = OpenOutput("OUT"); 42 | _cfgp = OpenInput("CONFIG"); 43 | } 44 | 45 | public override void Execute() 46 | { 47 | Packet p = _cfgp.Receive(); 48 | if (p != null) 49 | { 50 | string param = p.Content.ToString(); 51 | _timeout = Double.Parse(param); 52 | Drop(p); 53 | _cfgp.Close(); 54 | } 55 | 56 | Packet p0 = _inp.Receive(); 57 | string path = p0.Content as string; 58 | if (path != null) 59 | { 60 | TextReader tr = new StreamReader(path); 61 | string blob = ReadBlobItem(tr); 62 | p = Create(blob); 63 | p.Attributes.Add("Path", path); 64 | _outp.Send(p); 65 | } 66 | Drop(p0); 67 | } 68 | string ReadBlobItem(TextReader tr) 69 | { 70 | //using (TimeoutHandler t = new TimeoutHandler(_timeout, this)) //db's suggestion 71 | //{ 72 | LongWaitStart(_timeout); 73 | //Thread.Sleep(10000); // testing only //pm 74 | string s = tr.ReadToEnd(); 75 | //} 76 | LongWaitEnd(); 77 | return s; 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/Sort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FBPLib; 5 | 6 | namespace Components 7 | { 8 | /** Sort a stream of Packets to an output stream 9 | **/ 10 | [InPort("IN")] 11 | [OutPort("OUT")] 12 | [ComponentDescription("Sort input stream")] 13 | public class Sort : Component 14 | { 15 | internal static string _copyright = 16 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 17 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 18 | "based on the Everything Development Company's Artistic License. A document describing " + 19 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 20 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 21 | 22 | 23 | IInputPort _inport; 24 | OutputPort _outport; 25 | 26 | public override void Execute() /* throws Throwable */ { 27 | 28 | 29 | Packet p; 30 | int i = 0, j, k, n; 31 | Packet[] array = new Packet[9999]; 32 | while ((p = _inport.Receive()) != null) 33 | { 34 | array[i] = p; 35 | // Console.WriteLine("in: " + p.GetContent()); 36 | ++i; 37 | } 38 | 39 | Console.Out.WriteLine("No. of elements:" + i); 40 | j = 0; 41 | k = i; 42 | n = k; 43 | 44 | string t = null; 45 | 46 | while (n > 0) 47 | { 48 | t = null; 49 | for (i = 0; i < k; ++i) 50 | { 51 | if (array[i] != null) 52 | { 53 | string s = (string)array[i].Content; 54 | if (t == null || (String.Compare(s, t) < 0)) 55 | { 56 | j = i; 57 | t = (string)array[j].Content; 58 | } 59 | } 60 | } 61 | 62 | _outport.Send(array[j]); 63 | array[j] = null; 64 | 65 | --n; 66 | 67 | } 68 | 69 | } 70 | /* 71 | public override Object[] Introspect() 72 | { 73 | return new Object[] { 74 | "sorts input stream arriving at port IN and sends result to port OUT", 75 | "IN", "input", Type.GetType("Packet"), 76 | "input stream", 77 | "OUT", "output", Type.GetType("Packet"), 78 | "output stream"}; 79 | } 80 | */ 81 | public override void OpenPorts() 82 | { 83 | 84 | _inport = OpenInput("IN"); 85 | // _inport.SetType(Type.GetType("Packet")); 86 | 87 | _outport = OpenOutput("OUT"); 88 | // _outport.SetType(Type.GetType("Packet")); 89 | 90 | } 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalancer/TestLoadBalancer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {33BFDFF7-F467-4DF5-A2A6-3566D875750B} 9 | Exe 10 | Properties 11 | TestLoadBalancer 12 | TestLoadBalancer 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | x86 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {4E7DACA9-4D36-4029-8528-85DFA03754FD} 51 | FBPLib 52 | 53 | 54 | {4A5825D9-E8B2-4F4C-AE4B-0573DA5B5CE9} 55 | FBPVerbs 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /FBPVerbs/FBPComponents/TextToWords.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | //using System.Text.RegularExpressions; 6 | using FBPLib; 7 | 8 | 9 | namespace Components 10 | { 11 | [InPort("IN")] 12 | [OutPort("OUTN")] 13 | [OutPort("OUT")] 14 | [ComponentDescription("Read a chunk of text from IN, write words to OUT, rejects to OUTN. Set attributes: Text=input text, Offset=word offset in text")] 15 | public class TextToWords : Component 16 | { 17 | // Thanks to David Bennett 18 | 19 | internal static string _copyright = 20 | "Copyright 2007, 2008, 2009, J. Paul Morrison. At your option, you may copy, " + 21 | "distribute, or make derivative works under the terms of the Clarified Artistic License, " + 22 | "based on the Everything Development Company's Artistic License. A document describing " + 23 | "this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. " + 24 | "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK."; 25 | 26 | IInputPort _inp; 27 | OutputPort _outp; 28 | OutputPort _outpn; 29 | /* 30 | public override object[] Introspect() 31 | { 32 | return new object[] { 33 | "Read a chunk of text from IN, write words to OUT, rejects to OUTN.", 34 | "Set attributes: Text=input text, Offset=word offset in text", 35 | "Non-looper. 1->N" 36 | }; 37 | } 38 | */ 39 | public override void OpenPorts() 40 | { 41 | _inp = OpenInput("IN"); 42 | _outp = OpenOutput("OUT"); 43 | _outpn = OpenOutput("OUTN"); 44 | } 45 | 46 | public override void Execute() 47 | { 48 | Packet p = _inp.Receive(); 49 | string text = p.Content.ToString(); 50 | StringBuilder sb = new StringBuilder(); 51 | bool inword = false; 52 | int offs = 0; 53 | int offset = 0; 54 | foreach (char c in text + ' ') 55 | { 56 | if (Char.IsLetterOrDigit(c)) 57 | { 58 | sb.Append(c); 59 | if (!inword) 60 | { 61 | inword = true; 62 | offset = offs; 63 | } 64 | } 65 | else if (inword) 66 | { 67 | Packet pp = Create(sb.ToString()); 68 | pp.Attributes.Add("Text", text); 69 | pp.Attributes.Add("Offset", offset); 70 | 71 | if (sb.Length >= 4) 72 | _outp.Send(pp); 73 | else 74 | _outpn.Send(pp); 75 | sb.Length = 0; 76 | inword = false; 77 | } 78 | ++offs; 79 | } 80 | Drop(p); 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /TestCases/Concord/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.225 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Concord.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Concord.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.225 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FBPTest.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FBPTest.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /TestCases/TestLoadBalanceWithSubstreams/TestLoadBalanceWithSubstreams.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {A0C51A6C-065E-4983-8289-EAA8C0721F54} 9 | Exe 10 | Properties 11 | TestLoadBalanceWithSubstreams 12 | TestLoadBalanceWithSubstreams 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | x86 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {4E7DACA9-4D36-4029-8528-85DFA03754FD} 51 | FBPLib 52 | 53 | 54 | {4A5825D9-E8B2-4F4C-AE4B-0573DA5B5CE9} 55 | FBPVerbs 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /TestCases/Concord/resources/fake_cyrillic.txt: -------------------------------------------------------------------------------- 1 | Но мэя амэт мюкиуж дытыррюизщэт, кюм мютат дэльэнйт ат. Мэль но квюач долорэм аппарэат, ючю пожжёт рыпримёквуы но, эи вяш хабымуч дэниквюы. Факэтэ минемум ючю ан. Эа зыд жанктюч рыкючабо, пэр ку ныморэ дэлььынётё шынчебюз, декат мовэт аппарэат ты пэр. Но тальэ квуёдам мэль, экз зыд вивэндюм щуавятатэ тхэопхражтуз. 2 | 3 | Но декта вокынт нык. Вэл экз импэрдеэт эффикеэнди. Ючю тебиквюэ ыпикурэи мэнандря йн, шэа хомэро примич ад. Эжт ад хёнк пропрёаы, жольюта иреуры ыпикурэи экз прё. Ыам эа декта мальорум вёртюты. 4 | 5 | Алььтыра коммюны витюпырата йн эож, ад ыам вёжи мовэт волуптариа. Жольюта зэнтынтиаэ нэ мэль. Нам ютенам ажжынтиор рыфэррэнтур эи, хаж эю пауло оратио дёкант, эож ку адолэжкэнс интыллыгам. Ажжюм факэтэ пырикульа векж ут, выро пхйложопхяа ты мэль. Эа эож эрат пожйдонёюм, фачтидёе юрбанйтаж нык ат. 6 | 7 | Мэя экз факэтэ юлламкорпэр, дэлььынётё ометтантур ныглэгэнтур экз квюо. Ыт факильизиж мныжаркхюм нам. Мыа эуежмод ёудёкабет ылаборарэт эи, квуй ку льаборэж дежпютатионй, но зыд примич плььатонэм. Мэль рыквюы дигнижжим ывыртятюр эи, ед фабулаз рэктэквуэ пэр. Еюж нибх факёльиси конклььюжионэмквуэ йн. Ку ючю мюндй клита татион. Мюнырэ мыдиокрым аккоммодары ку вим, эож ыкжпэтэндяз дйжпютандо ты. 8 | 9 | Хабэо примич бландит нам экз, шэа квюандо дёкант эквюедым ед. Пытынтёюм конжыквуюнтюр ат нам. Мыа тамквюам волуптюа ед. Тота трётанё дыфяниэбаж мыа ан, мольлиз интэллэгат волуптатум ку вэл. Мюндй пэрпэтюа ку вэл, вим мютат мюндй ты. Хаж фюйзчыт квюальизквюэ ан, ыюм ед эзшэ дэфянятйоныс. 10 | 11 | Эю ипзум нощтыр ючю, вэрйтюж алёквюам дыфинитеоным про ед. Копиожаы опортэры волютпат эож эю, видэ жкрипта дуо эю. Мэль выльёт оффэндйт ут, но эож кевёбюж фачтидёе мныжаркхюм. Омниюм ёудёкабет ед еюж, эним доктюж бонорюм эож ты. 12 | 13 | Долорюм дигнижжим ючю эю, ыюм чент ножтрюм молэчтёэ экз. Про пожжэ декам примич ыт. Атквюе рыпримёквуы инзтруктеор ад векж, мёнём зюжкепиантюр но ючю. Экз модо дольорэ вэл, йн эжт пауло ийжквюы запиэнтэм. Агам дыфяниэбаж ку мыа. 14 | 15 | Жят но квюандо фабулаз. Фюйзчыт еракюндйа квуй ут. Вэрйтюж адолэжкэнс ут про, ку ыррор емпыдит ючю. Аффэрт зальутанде ут вэл. Йн тымпор омниюм коррюмпит жят, пожжэ пэржыкюти конжтетуто мэль ку, тантаз вэртырэм кончэктэтюыр пэр йн. Пэр съюммо нужквюам майыжтатйж эа, ут агам еракюндйа тинкидюнт кюм. Ыкчпэтында витюпырата шэа ку. 16 | 17 | Фырре вюльпутаты хаж йн, эож ед пробатуж конкльюдатюрквюэ. Хёз мандамюч пэрпэтюа эа, ножтро фэюгаят луптатум векж ут, эа дуо квюот хэндрэрет интэллэгат. Экз ножтрюм пэрпэтюа вюльпутаты мэя. Мэя но чонэт видырэр, емпэтюсъ омйттам ад квюо. Эжт эи ридэнж дэбетиз. Эю фабулаз пхаэдрум пырикульа вяш. 18 | 19 | Зыд граэкы праэчынт эю. Ыам ку омнеж модюж молыжтйаы, ты нам алиё пэркёпитюр аппэльлььантюр, фиэрэнт нолюёжжэ такематыш дуо ан. Нам ат модюж вэрыар эффикеэнди, ратионебюж пожйдонёюм ут квуй, жят компльыктётюр мэдиокретатым эю. Ёужто ёудико эрепюят жят ан, йн жят квюот тебиквюэ мныжаркхюм, квюач анкилльаы ут квуй. Зыд эю ыпикурэи кончюлату, кхоро пэркёпитюр конкльюдатюрквюэ ат мэя. Мацим ыкчпэтында дэмокритум дуо ут, эжт нюлльам вёвындо мэнандря йн, йн квюод долорэж хёз. 20 | -------------------------------------------------------------------------------- /TestCases/CopyFileToConsole/Resources/fake_cyrillic.txt: -------------------------------------------------------------------------------- 1 | Но мэя амэт мюкиуж дытыррюизщэт, кюм мютат дэльэнйт ат. Мэль но квюач долорэм аппарэат, ючю пожжёт рыпримёквуы но, эи вяш хабымуч дэниквюы. Факэтэ минемум ючю ан. Эа зыд жанктюч рыкючабо, пэр ку ныморэ дэлььынётё шынчебюз, декат мовэт аппарэат ты пэр. Но тальэ квуёдам мэль, экз зыд вивэндюм щуавятатэ тхэопхражтуз. 2 | 3 | Но декта вокынт нык. Вэл экз импэрдеэт эффикеэнди. Ючю тебиквюэ ыпикурэи мэнандря йн, шэа хомэро примич ад. Эжт ад хёнк пропрёаы, жольюта иреуры ыпикурэи экз прё. Ыам эа декта мальорум вёртюты. 4 | 5 | Алььтыра коммюны витюпырата йн эож, ад ыам вёжи мовэт волуптариа. Жольюта зэнтынтиаэ нэ мэль. Нам ютенам ажжынтиор рыфэррэнтур эи, хаж эю пауло оратио дёкант, эож ку адолэжкэнс интыллыгам. Ажжюм факэтэ пырикульа векж ут, выро пхйложопхяа ты мэль. Эа эож эрат пожйдонёюм, фачтидёе юрбанйтаж нык ат. 6 | 7 | Мэя экз факэтэ юлламкорпэр, дэлььынётё ометтантур ныглэгэнтур экз квюо. Ыт факильизиж мныжаркхюм нам. Мыа эуежмод ёудёкабет ылаборарэт эи, квуй ку льаборэж дежпютатионй, но зыд примич плььатонэм. Мэль рыквюы дигнижжим ывыртятюр эи, ед фабулаз рэктэквуэ пэр. Еюж нибх факёльиси конклььюжионэмквуэ йн. Ку ючю мюндй клита татион. Мюнырэ мыдиокрым аккоммодары ку вим, эож ыкжпэтэндяз дйжпютандо ты. 8 | 9 | Хабэо примич бландит нам экз, шэа квюандо дёкант эквюедым ед. Пытынтёюм конжыквуюнтюр ат нам. Мыа тамквюам волуптюа ед. Тота трётанё дыфяниэбаж мыа ан, мольлиз интэллэгат волуптатум ку вэл. Мюндй пэрпэтюа ку вэл, вим мютат мюндй ты. Хаж фюйзчыт квюальизквюэ ан, ыюм ед эзшэ дэфянятйоныс. 10 | 11 | Эю ипзум нощтыр ючю, вэрйтюж алёквюам дыфинитеоным про ед. Копиожаы опортэры волютпат эож эю, видэ жкрипта дуо эю. Мэль выльёт оффэндйт ут, но эож кевёбюж фачтидёе мныжаркхюм. Омниюм ёудёкабет ед еюж, эним доктюж бонорюм эож ты. 12 | 13 | Долорюм дигнижжим ючю эю, ыюм чент ножтрюм молэчтёэ экз. Про пожжэ декам примич ыт. Атквюе рыпримёквуы инзтруктеор ад векж, мёнём зюжкепиантюр но ючю. Экз модо дольорэ вэл, йн эжт пауло ийжквюы запиэнтэм. Агам дыфяниэбаж ку мыа. 14 | 15 | Жят но квюандо фабулаз. Фюйзчыт еракюндйа квуй ут. Вэрйтюж адолэжкэнс ут про, ку ыррор емпыдит ючю. Аффэрт зальутанде ут вэл. Йн тымпор омниюм коррюмпит жят, пожжэ пэржыкюти конжтетуто мэль ку, тантаз вэртырэм кончэктэтюыр пэр йн. Пэр съюммо нужквюам майыжтатйж эа, ут агам еракюндйа тинкидюнт кюм. Ыкчпэтында витюпырата шэа ку. 16 | 17 | Фырре вюльпутаты хаж йн, эож ед пробатуж конкльюдатюрквюэ. Хёз мандамюч пэрпэтюа эа, ножтро фэюгаят луптатум векж ут, эа дуо квюот хэндрэрет интэллэгат. Экз ножтрюм пэрпэтюа вюльпутаты мэя. Мэя но чонэт видырэр, емпэтюсъ омйттам ад квюо. Эжт эи ридэнж дэбетиз. Эю фабулаз пхаэдрум пырикульа вяш. 18 | 19 | Зыд граэкы праэчынт эю. Ыам ку омнеж модюж молыжтйаы, ты нам алиё пэркёпитюр аппэльлььантюр, фиэрэнт нолюёжжэ такематыш дуо ан. Нам ат модюж вэрыар эффикеэнди, ратионебюж пожйдонёюм ут квуй, жят компльыктётюр мэдиокретатым эю. Ёужто ёудико эрепюят жят ан, йн жят квюот тебиквюэ мныжаркхюм, квюач анкилльаы ут квуй. Зыд эю ыпикурэи кончюлату, кхоро пэркёпитюр конкльюдатюрквюэ ат мэя. Мацим ыкчпэтында дэмокритум дуо ут, эжт нюлльам вёвындо мэнандря йн, йн квюод долорэж хёз. 20 | -------------------------------------------------------------------------------- /FBPLib/Lib/SubIn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FBPLib 6 | { 7 | /** 8 | * Look after input to subnet - added for subnet support 9 | */ 10 | [InPort("NAME")] 11 | [OutPort("OUT")] 12 | public class SubIn : Component 13 | { 14 | /* * 15 | * Copyright 2007, 2008, J. Paul Morrison. At your option, you may copy, 16 | * distribute, or make derivative works under the terms of the Clarified Artistic License, 17 | * based on the Everything Development Company's Artistic License. A document describing 18 | * this License may be found at http://www.jpaulmorrison.com/fbp/artistic2.htm. 19 | * THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK. 20 | * */ 21 | IInputPort _inport, _nameport; 22 | 23 | OutputPort _outport; 24 | 25 | public override void Execute() 26 | { 27 | 28 | Packet np = _nameport.Receive(); 29 | if (np == null) 30 | { 31 | return; 32 | } 33 | _nameport.Close(); 34 | string pname = np.Content as string; 35 | Drop(np); 36 | 37 | _inport = (_mother._inputPorts)[pname] as IInputPort; 38 | _mother.Trace(Name + ": Accessing input port: " + _inport.Name); 39 | Packet p; 40 | // I think this works! 41 | Component oldReceiver = _inport.Receiver; 42 | if (_inport is InitializationConnection) 43 | { 44 | InitializationConnection iico = (InitializationConnection)_inport; 45 | InitializationConnection iic = new InitializationConnection( 46 | iico.Content, this); 47 | iic.Name = iico.Name; 48 | // iic.network = iico.network; 49 | 50 | p = iic.Receive(); 51 | p.Owner = this; 52 | _outport.Send(p); 53 | iic.Close(); 54 | } 55 | else 56 | { 57 | Connection cnxt = _inport as Connection; 58 | cnxt.SetReceiver(this); 59 | while ((p = cnxt.Receive()) != null) 60 | { 61 | p.Owner = this; 62 | _outport.Send(p); 63 | } 64 | // cnxt.setReceiver(oldReceiver); // moved down, as per JavaFBP 65 | } 66 | 67 | // inport.close(); 68 | 69 | _mother.Trace(Name + ": Releasing input port: " + _inport.Name); 70 | _inport.SetReceiver(oldReceiver); 71 | // inport = null; 72 | } 73 | 74 | //public override Object[] Introspect() 75 | //{ 76 | // return new Object[] { "handles one input stream for subnet", "NAME", 77 | // "input", Type.GetType("System.String"), "name of higher level input port", 78 | // "OUT", "output", Type.GetType("System.Object"), 79 | // "output from external port (into subnet)" }; 80 | // } 81 | 82 | public override void OpenPorts() 83 | { 84 | 85 | _nameport = OpenInput("NAME"); 86 | _outport = OpenOutput("OUT"); 87 | } 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /TestCases/FBPTest/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.IO; 9 | using TestNetworks.Networks; 10 | //using FBPLib; 11 | 12 | 13 | namespace FBPTest 14 | { 15 | 16 | internal partial class Form1 : Form 17 | { 18 | 19 | 20 | internal Form1() 21 | { 22 | InitializeComponent(); 23 | 24 | } 25 | 26 | 27 | private void button1_Click(object sender, EventArgs e) 28 | { 29 | new Update().Go(); 30 | } 31 | 32 | 33 | private void button2_Click(object sender, EventArgs e) 34 | { 35 | new TestInfQueue().Go(); 36 | } 37 | 38 | private void button3_Click(object sender, EventArgs e) 39 | { 40 | new MergeAndSort().Go(); 41 | } 42 | 43 | 44 | private void button4_Click(object sender, EventArgs e) 45 | { 46 | 47 | new CopyFileToCons().Go(); 48 | } 49 | 50 | private void button5_Click(object sender, EventArgs e) 51 | { 52 | new Deadlock().Go(); 53 | } 54 | 55 | private void button6_Click(object sender, EventArgs e) 56 | { 57 | new NoDeadlock().Go(); 58 | } 59 | 60 | private void button7_Click(object sender, EventArgs e) 61 | { 62 | new TestLoadBalanceWithSubstreams().Go(); 63 | } 64 | private void button8_Click(object sender, EventArgs e) 65 | { 66 | new TestRunExe().Go(); 67 | } 68 | private void button9_Click(object sender, EventArgs e) 69 | { 70 | new TestLoadBalanceWRandDelay().Go(); 71 | } 72 | private void button10_Click(object sender, EventArgs e) 73 | { 74 | new TestPassthrus().Go(); 75 | } 76 | private void button11_Click(object sender, EventArgs e) 77 | { 78 | new TSS().Go(); 79 | } 80 | private void button12_Click(object sender, EventArgs e) 81 | { 82 | new TestArrayPorts().Go(); 83 | } 84 | private void button13_Click(object sender, EventArgs e) 85 | { 86 | new TestDeadlockDetection().Go(); 87 | } 88 | private void button14_Click(object sender, EventArgs e) 89 | { 90 | new TestNestedSubstreams().Go(); 91 | } 92 | private void button15_Click(object sender, EventArgs e) 93 | { 94 | new TestSockets().Go(); 95 | } 96 | private void button16_Click(object sender, EventArgs e) 97 | { 98 | new TestLoadBalancer().Go(); 99 | } 100 | 101 | private void button17_Click(object sender, EventArgs e) 102 | { 103 | new VolumeTest().Go(); 104 | } 105 | 106 | private void button18_Click(object sender, EventArgs e) 107 | { 108 | new DropOldest().Go(); 109 | } 110 | 111 | 112 | 113 | } 114 | 115 | 116 | } 117 | --------------------------------------------------------------------------------