Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsso committed Jul 31, 2021
1 parent 666a3a3 commit 6b58909
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 163 deletions.
3 changes: 2 additions & 1 deletion myps/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub fn lex_string(source: String) -> MypsResult<Item> {
}

pub fn lex_file<P: Into<PathBuf> + std::fmt::Debug>(path: P) -> MypsResult<Item> {
let f = File::open(path.into()).unwrap();
let path_string = format!("{:?}", path);
let f = File::open(path.into()).expect(&path_string);
let f = BufReader::new(f);
let lines = f.lines().collect::<Result<Vec<_>, _>>().unwrap();
lex_lines(lines.into_iter())
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
furnace = d0
tankC = d1
tankH = d2
nCPump = d3
nHPump = d4
nIAnlzr = d5
#furnace = d0
#nIAnlzr = d5

tankC = d0
tankH = d1
nCPump = d2
nHPump = d3
progressDest = d4

def vF = 1000 # furnace volume
def R = 8.314 # universal gas consant
Expand All @@ -15,14 +17,14 @@ def nCfactor = (6200) / 6000
def nHfactor = (6200) / 6000

# PD coefficients and minimum error (perhaps adjust)
def kPF = 0.06
def kDF = 0.03
def kPF = 0.09
def kDF = 0.06

def kPC = 0.06
def kDC = 0.03
def kPC = 0.09
def kDC = 0.06

def kPH = 0.06
def kDH = 0.03
def kPH = 0.09
def kDH = 0.06

def ERRORF = 0.01
def ERRORC = 0.03
Expand Down
12 changes: 12 additions & 0 deletions myps/test-scripts/factory/furnace/input.myps
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tTSDial = d0
tTMDial = d1
tTLDial = d2
pTSDial = d3
pTMDial = d4
pTLDial = d5

loop:
yield()
tT = (tTSDial.Setting + 10 * tTMDial.Setting + 100* tTLDial.Setting)
pT = (pTSDial.Setting + 10 * pTMDial.Setting + 100* pTLDial.Setting) * 1000
db.Setting = tT + pT
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
furnace = d0
tankC = d1
tankH = d2
eFdest = d3
eCdest = d4
eHdest = d5
progressDest = d3

def vF = 1000
def R = 8.314
Expand All @@ -15,10 +13,26 @@ def ERRORF = 0.01
def ERRORC = 0.03
def ERRORH = 0.03

eFdest.Mode = 1 # percentages
eCdest.Mode = 1
eHdest.Mode = 1

db.Setting = 0
loop:
yield()
input = db.Setting
if input > 0:
haveInput = input > 0

eFdest.On = haveInput
eCdest.On = haveInput
eHdest.On = haveInput

fix nR, nHI, nCI
if haveInput:
eFdest.Setting = 0
eCdest.Setting = 0
eHdest.Setting = 0

input = trunc(input)
tT = (input % 1000) * 10
pT = trunc(input / 1000) * 100
Expand All @@ -37,13 +51,10 @@ loop:
nCI = nI - nHI

fix rF = nF - nR

nC = nCfactor * tankC.TotalMoles
fix rC = nC - nCI

nH = nHfactor * tankH.TotalMoles
fix rH = nH - nHI

tag PDLoop:
yield()
nF = furnace.TotalMoles
Expand All @@ -54,17 +65,11 @@ loop:
eC = nC - rC
eH = nH - rH

FNotDone = (eF > ERRORF)
CNotDone = (eC > ERRORC)
HNotDone = (eH > ERRORH)
eFdest.Setting = (1 - eF / nR )
eCdest.Setting = (1 - eC / nCI)
eHdest.Setting = (1 - eH / nHI)

eFdest.Setting = FNotDone ? eF : 0
#eFdest.On = FNotDone ? eF : 0
eCdest.Setting = FNotDone ? eC : 0
#eCdest.On = FNotDone ? eC : 0
eHdest.Setting = CNotDone ? eH : 0
#eHdest.On = CNotDone ? eH : 0
loop = eF > ERRORF or eC > ERRORC or eH > ERRORH
bnez(loop, PDLoop)

bnez(FNotDone, PDLoop)
bnez(CNotDone, PDLoop)
bnez(HNotDone, PDLoop)
db.Setting = 0
28 changes: 28 additions & 0 deletions myps/test-scripts/factory/furnace/validator-dispatcher.myps
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
inputControl = d0
tTDisp = d1
pTDisp = d2
tankC = d3
tankH = d4
furnaceControl = d5

def GREEN = 2
def GRAY = 1

loop:
yield()
input = inputControl.Setting
tT = (input % 1000) * 10
pT = trunc(input / 1000) * 100
tC = tankC.Temperature
tH = tankH.Temperature
tValid = tC < tT and tT < tH
pValid = 0 < pT and pT < 60000

tTDisp.Setting = tT
pTDisp.Setting = pT
tTDisp.Color = tValid ? GREEN : GRAY
pTDisp.Color = pValid ? GREEN : GRAY

#if tValid and db.Setting != 0:
# if dse(furnaceControl):
# furnaceControl.Setting = input
131 changes: 0 additions & 131 deletions myps/test-scripts/factory/gas.myps2

This file was deleted.

0 comments on commit 6b58909

Please sign in to comment.