Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
wacksientrist authored Nov 3, 2023
1 parent 17cb401 commit b2d52e2
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Orchid_2.0.2/Makefile
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
50 changes: 50 additions & 0 deletions Orchid_2.0.2/Orchid/Comp/Instance.py
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.
1 change: 1 addition & 0 deletions Orchid_2.0.2/Orchid/Comp/Instrc_r.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
! 123 IF=
1 change: 1 addition & 0 deletions Orchid_2.0.2/Orchid/Comp/Instrc_s.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions Orchid_2.0.2/Orchid/Comp/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python3 Instance.py
42 changes: 42 additions & 0 deletions Orchid_2.0.2/Orchid/Public/Orchid.py
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.
12 changes: 12 additions & 0 deletions Orchid_2.0.2/Orchid/Sample.py
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())
3 changes: 3 additions & 0 deletions Orchid_2.0.2/Orchid/int.sh
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 &
26 changes: 26 additions & 0 deletions Orchid_2.0.2/README.md
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
18 changes: 18 additions & 0 deletions Orchid_2.0.2/Setup.py
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()

0 comments on commit b2d52e2

Please sign in to comment.