-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17cb401
commit b2d52e2
Showing
12 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
! 123 IF= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 Instance.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd ./Build || cd ../Build; ls | ||
cd ../../Build || cd ../../../Build; ls | ||
cd Comp_; sh start.sh & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Comp number> = Instance('<Comp number>')" | ||
- to send a command to a node you can use "C<Comp number>.Process(<Input1>, <Input2>, '<Operation type>')" | ||
- to read the output use "C<Comp number>.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |