diff --git a/Orchid_2.0.2/Makefile b/Orchid_2.0.2/Makefile new file mode 100644 index 0000000..98540a9 --- /dev/null +++ b/Orchid_2.0.2/Makefile @@ -0,0 +1,9 @@ +Build: + mkdir Build + mkdir Build/Public + cp -R Orchid/Public/ Build/Public/ + cp Orchid/Sample.py Build/ + python3 Setup.py +Install: + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew install python3 \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Comp/Instance.py b/Orchid_2.0.2/Orchid/Comp/Instance.py new file mode 100644 index 0000000..79112a2 --- /dev/null +++ b/Orchid_2.0.2/Orchid/Comp/Instance.py @@ -0,0 +1,50 @@ +while True: + # check if theres a new command to process + + if open("Instrc_n.txt", 'r').read() == "n": + # read the commands + + fil1 = open("Instrc_r.txt", "r").read() + fil2 = open("Instrc_s.txt", "w") + + # format commands to variables + fil1 = fil1.split(" ") + A = fil1[0] + B = fil1[1] + Type = fil1[2] + + # execute the new command + if Type == "A": + Out = float(A)+float(B) + if Type == "S": + Out = float(A)-float(B) + if Type == "M": + Out = float(A)*float(B) + if Type == "D": + Out = float(A)/float(B) + if Type == "IF=": + print(A) + print(B) + if A == B: + Out = "T" + else: + Out = "F" + if Type == "IF!": + if A == B: + Out = "F" + else: + Out = "T" + if Type == "IF>": + if A > B: + Out = "T" + else: + Out = "F" + if Type == "IF<": + if A < B: + Out = "T" + else: + Out = "F" + + # return the output + fil2.write(str(Out)) + fil2.close() \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Comp/Instrc_n.txt b/Orchid_2.0.2/Orchid/Comp/Instrc_n.txt new file mode 100644 index 0000000..e69de29 diff --git a/Orchid_2.0.2/Orchid/Comp/Instrc_r.txt b/Orchid_2.0.2/Orchid/Comp/Instrc_r.txt new file mode 100644 index 0000000..3d101dc --- /dev/null +++ b/Orchid_2.0.2/Orchid/Comp/Instrc_r.txt @@ -0,0 +1 @@ +! 123 IF= \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Comp/Instrc_s.txt b/Orchid_2.0.2/Orchid/Comp/Instrc_s.txt new file mode 100644 index 0000000..c137216 --- /dev/null +++ b/Orchid_2.0.2/Orchid/Comp/Instrc_s.txt @@ -0,0 +1 @@ +F \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Comp/start.sh b/Orchid_2.0.2/Orchid/Comp/start.sh new file mode 100644 index 0000000..1e97325 --- /dev/null +++ b/Orchid_2.0.2/Orchid/Comp/start.sh @@ -0,0 +1 @@ +python3 Instance.py \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Public/Orchid.py b/Orchid_2.0.2/Orchid/Public/Orchid.py new file mode 100644 index 0000000..6bd069a --- /dev/null +++ b/Orchid_2.0.2/Orchid/Public/Orchid.py @@ -0,0 +1,42 @@ +import time + +class Node(): + def __init__(self, UUID): + self.UUID = UUID # Localize UUID variable + self.result = None + def Process(self, A, B, Type): + Input_File = open("Comp"+str(self.UUID)+"/Instrc_r.txt", "w") # open the input file + Output_File = open("Comp"+str(self.UUID)+"/Instrc_s.txt", "w") # open the output file for writing + Output_File.write("P") # Write Placeholder to overwrite previous output + Output_File.close() + Output_File = open("Comp"+str(self.UUID)+"/Instrc_s.txt", "r") # open output file + Input_File.write(str(A)+r" "+str(B)+r" "+str(Type)) # Send the Command to Be Processed + Input_File.close() + open("Comp"+str(self.UUID)+"/Instrc_n.txt", "w").write("n") # Inform the Node that there is a new command + while Output_File.read() == "P": # Wait until the Output File changes from The Placeholder to the new Output + time.sleep(0.01) + open("Comp"+str(self.UUID)+"/Instrc_n.txt", "w").write("") # Upon Receipt of Output Inform the Node there is no new command + def Read(self): + while(True): + Output_File = open("Comp"+str(self.UUID)+"/Instrc_s.txt", "r") + #time.sleep(0.01) + A_str = Output_File.read() + if A_str == "P": # Check Processing Status + Output_File.close() + continue + if A_str == "": # Check Processing Status + Output_File.close() + continue + if open("Comp"+str(self.UUID)+"/Instrc_n.txt", "r").read() == "n": # Check If file is ready for read + Output_File.close() + continue + if A_str == "F": # Check if its a boolean and return proper output + Output_File.close() + return False + elif A_str == "T": # Check if its a boolean and return proper output + Output_File.close() + return True + else: # Output is a number, to keep float and int, support return string + Output_File.close() + return A_str + \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/Public/__pycache__/Orchid.cpython-311.pyc b/Orchid_2.0.2/Orchid/Public/__pycache__/Orchid.cpython-311.pyc new file mode 100644 index 0000000..a4e5fb0 Binary files /dev/null and b/Orchid_2.0.2/Orchid/Public/__pycache__/Orchid.cpython-311.pyc differ diff --git a/Orchid_2.0.2/Orchid/Sample.py b/Orchid_2.0.2/Orchid/Sample.py new file mode 100644 index 0000000..3efe7fc --- /dev/null +++ b/Orchid_2.0.2/Orchid/Sample.py @@ -0,0 +1,12 @@ +from Public.Orchid import Node #import Library + +C1 = Node("1") +C2 = Node("2") + +for i in range(100): + C1.Process(i, 3, "M") + C2.Process(C1.Read(), 9, "A") + + print(i) + print(C1.Read()) + print(C2.Read()) \ No newline at end of file diff --git a/Orchid_2.0.2/Orchid/int.sh b/Orchid_2.0.2/Orchid/int.sh new file mode 100644 index 0000000..75c412c --- /dev/null +++ b/Orchid_2.0.2/Orchid/int.sh @@ -0,0 +1,3 @@ +cd ./Build || cd ../Build; ls +cd ../../Build || cd ../../../Build; ls +cd Comp_; sh start.sh & \ No newline at end of file diff --git a/Orchid_2.0.2/README.md b/Orchid_2.0.2/README.md new file mode 100644 index 0000000..6432c7d --- /dev/null +++ b/Orchid_2.0.2/README.md @@ -0,0 +1,26 @@ +# Orchid +Orchid was my first attempt at a distributed computing software. though it turned out as more of a library. + +# Installation +1. Build with "make Build" +2. Install with "make Install" + #it will ask for sudo, this is to install brew, which is a requirement + +# First Steps +start in the folder "Comp1" +next, youll need to run start.sh with "sh start.sh" in order to run any commands. this turns on the node "Comp1" +for debug purposes you can run "sh -v Build/int.sh" this will turn on all nodes locally + +# Docs +- Input1 and Input2 can be variables, constants, or strings +- First this is a library. you can import it using "from Public.Orchid import Instance" +- to instantiate a node in your program you can use "C = Instance('')" +- to send a command to a node you can use "C.Process(, , '')" +- to read the output use "C.Read()" it will return either a boolean or a string containing your value + +# Operation Types +1. A is Add +2. S is subtract +3. M is multiply +4. D is divide +5. IF= is an if statement it will output a boolean \ No newline at end of file diff --git a/Orchid_2.0.2/Setup.py b/Orchid_2.0.2/Setup.py new file mode 100644 index 0000000..02fcf19 --- /dev/null +++ b/Orchid_2.0.2/Setup.py @@ -0,0 +1,18 @@ +import os + +inp = input("Computer Count: ") +content = open("Orchid/int.sh", "r").read() +content_snp = content +file = open("Orchid/int.sh", "w") + +file.write("#! /bin/sh \n") + +for i in range(1, int(inp)): + content = content_snp.replace("_", str(i))+"\n" + file.write(content) + os.system(f"mkdir Build/Comp{i}; cp -R Orchid/Comp/ Build/Comp{i}") +file.close() +os.system("cp Orchid/int.sh Build/") +file = open("Orchid/int.sh", "w") +file.write(content_snp) +file.close() \ No newline at end of file