Skip to content

Commit fd0df55

Browse files
authored
Merge pull request #94 from CSchank/dev
Dev
2 parents 3669b48 + 5ede7d9 commit fd0df55

16 files changed

+1614
-171
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
language: elm
2+
3+
install:
4+
- npm install -g elm@0.19.1-3
5+
- npm install -g elm-test@0.19.1
6+
- npm install -g elm-format@0.8.2
27
env:
38
global:
49
- secure: C9poA+wbk5f2SMct/hZe2GDGRvGofIwoGJyvWQOkSVfV016YrtDMmOrrYXjx5qBmY3mO7dejG/D7yZHUKHqQO6QmAOMyrP1Efj1xqAZwOUH8z0I82mb7xjfd0pSrT/HHxd030orVRxqfOTXawvkRHcQ9/H3oREiHgV+IccFRVpTVf8avYREV7cds7p62VNj/3uK1De/etdnDxWFWEQldkdlE1dNE/KMX6SsJGs0JMMC8ubyG5sVIaBs9XPo6DPs9jphioyCmZbVzqms8F0Wirzn4OYbLIXMkV73OywCQmRBo41i/SOHIfACfKBzTnleQ8RwuCxMr9PxGD0s8+W8r1tsWYsr5nqxj8YtW2U9BI8a2P3yYyfw95jh2xrKYiJGHvVZaE0crB8xK9V7UurvrBZs1W402mKCmw0RCqc5HGyCwT4croJb6cj6IdVLurBbomcR3iUL8JuFPPihJdCVjJddO9hEnqcwr2MzcLNXR2MXIlSGX5WPAB+D7WYsfMfJwTdO2LvvToXPUc4dujnodWKjpk/PDAiOJNSEOdyTXOP/bQn7+9B9kwngfqTXdSM/EngabpdZhjRDSLqtkxzR6/3AMWvg/X0jKPds7Z1xn8cDcshOhFuHrKD6BacbkGuN7WHtemm+JCowSn70Yl/6xIWA1bpa6suFLzbCpvKXlHgk=

elm.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@
33
"source-directories": [
44
"src"
55
],
6-
"elm-version": "0.19.0",
6+
"elm-version": "0.19.1",
77
"dependencies": {
88
"direct": {
99
"MacCASOutreach/graphicsvg": "5.1.0",
10-
"billstclair/elm-sha256": "1.0.8",
10+
"billstclair/elm-sha256": "1.0.9",
1111
"elm/browser": "1.0.1",
1212
"elm/core": "1.0.2",
1313
"elm/html": "1.0.0",
1414
"elm/http": "1.0.0",
1515
"elm/json": "1.1.2",
1616
"elm/random": "1.0.0",
17+
"elm/svg": "1.0.1",
1718
"elm/time": "1.0.0",
1819
"elm/url": "1.0.0",
19-
"elm-community/undo-redo": "3.0.0"
20+
"elm-community/undo-redo": "3.0.0",
21+
"ianmackenzie/elm-units": "2.2.0",
22+
"rundis/elm-bootstrap": "5.2.0"
2023
},
2124
"indirect": {
25+
"avh4/elm-color": "1.0.0",
2226
"elm/regex": "1.0.0",
23-
"elm/svg": "1.0.1",
2427
"elm/virtual-dom": "1.0.2",
2528
"elm-community/list-extra": "8.1.0"
2629
}
@@ -31,4 +34,4 @@
3134
},
3235
"indirect": {}
3336
}
34-
}
37+
}

src/ApplicationModel.elm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module ApplicationModel exposing (..)
2+
3+
import Building
4+
import Exporting
5+
import SharedModel exposing (SharedModel)
6+
import Simulating
7+
8+
9+
type ApplicationState
10+
= Building Building.Model
11+
| Simulating Simulating.Model
12+
| Exporting Exporting.Model
13+
14+
15+
type alias ApplicationModel =
16+
{ appState : ApplicationState
17+
, simulatingData : Simulating.PersistentModel
18+
, buildingData : Building.PersistentModel
19+
, exportingData : Exporting.PersistentModel
20+
, sharedModel : SharedModel
21+
}

src/Building.elm

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module Building exposing (Model, Msg(..), PersistentModel(..), editingButtons, init, initPModel, onEnter, onExit, subscriptions, update, updateArrowPos, updateStatePos, view)
22

33
import Browser.Events
4-
import Debug
54
import Dict exposing (Dict)
65
import Environment exposing (Environment)
76
import GraphicSVG exposing (..)
87
import Helpers exposing (..)
98
import Json.Decode as D
109
import Machine exposing (..)
10+
import Mistakes exposing (..)
1111
import Set
1212
import SharedModel exposing (SharedModel)
1313
import Task
@@ -148,34 +148,6 @@ update env msg ( model, pModel, sModel ) =
148148
isValidTransition =
149149
checkTransitionValid newTrans
150150

151-
oldTransitionMistakes =
152-
oldMachine.transitionMistakes
153-
154-
newTransitionMistakes =
155-
if isValidTransition then
156-
case oldTransitionMistakes of
157-
Just setOfMistakes ->
158-
let
159-
newSetOfMistakes =
160-
Set.remove newTransID setOfMistakes
161-
in
162-
if Set.isEmpty newSetOfMistakes then
163-
Nothing
164-
165-
else
166-
Just newSetOfMistakes
167-
168-
Nothing ->
169-
Nothing
170-
171-
else
172-
case oldTransitionMistakes of
173-
Just setOfMistakes ->
174-
Just <| Set.insert newTransID setOfMistakes
175-
176-
Nothing ->
177-
Just <| Set.singleton newTransID
178-
179151
newDelta : Delta
180152
newDelta =
181153
Dict.update st
@@ -209,7 +181,6 @@ update env msg ( model, pModel, sModel ) =
209181
| delta = newDelta
210182
, transitionNames = Dict.insert newTransID newTrans oldMachine.transitionNames
211183
, stateTransitions = Dict.insert ( st, newTransID, s1 ) newTransPos oldMachine.stateTransitions
212-
, transitionMistakes = newTransitionMistakes
213184
}
214185
}
215186
)
@@ -489,15 +460,11 @@ update env msg ( model, pModel, sModel ) =
489460
, stateTransitions = newStateTransitions
490461
, stateNames = Dict.remove stId oldMachine.stateNames
491462
, transitionNames = Dict.diff oldMachine.transitionNames removedTransitions
492-
, transitionMistakes = newTMistakes
493463
}
494464

495465
newStateTransitions =
496466
Dict.filter (\( _, t, _ ) _ -> not <| Dict.member t removedTransitions) oldMachine.stateTransitions
497467

498-
newTMistakes =
499-
List.foldr (\tId mistakes -> tMistakeRemove (first tId) mistakes) oldMachine.transitionMistakes removedTransitionsLst
500-
501468
removedTransitionsLst =
502469
List.map (\( _, t, _ ) -> ( t, () )) <| Dict.keys <| Dict.filter (\( s0, _, s1 ) _ -> s0 == stId || s1 == stId) oldMachine.stateTransitions
503470

@@ -516,14 +483,10 @@ update env msg ( model, pModel, sModel ) =
516483
| delta = newDelta
517484
, stateTransitions = newStateTransitions
518485
, transitionNames = Dict.remove tId oldMachine.transitionNames
519-
, transitionMistakes = newTMistakes
520486
}
521487

522488
newStateTransitions =
523489
Dict.filter (\( _, tId0, _ ) _ -> tId /= tId0) oldMachine.stateTransitions
524-
525-
newTMistakes =
526-
tMistakeRemove tId oldMachine.transitionMistakes
527490
in
528491
( ( { model | machineState = Regular }, pModel, { sModel | machine = newMachine } ), True, Cmd.none )
529492

@@ -572,20 +535,9 @@ update env msg ( model, pModel, sModel ) =
572535
isValidTransition =
573536
checkTransitionValid newTransitions
574537

575-
oldTransitionMistakes =
576-
oldMachine.transitionMistakes
577-
578-
newTransitionMistakes =
579-
if isValidTransition then
580-
tMistakeRemove tId oldTransitionMistakes
581-
582-
else
583-
tMistakeAdd tId oldTransitionMistakes
584-
585538
newMachine =
586539
{ oldMachine
587540
| transitionNames = Dict.insert tId newTransitions oldMachine.transitionNames
588-
, transitionMistakes = newTransitionMistakes
589541
}
590542
in
591543
( ( { model | machineState = Regular }, pModel, { sModel | machine = newMachine } ), True, Cmd.none )
@@ -635,6 +587,9 @@ view env ( model, pModel, sModel ) =
635587

636588
winY =
637589
toFloat <| second env.windowSize
590+
591+
transMistakes =
592+
getTransitionMistakes sModel.machine
638593
in
639594
group
640595
[ rect winX winY
@@ -669,7 +624,7 @@ view env ( model, pModel, sModel ) =
669624

670625
_ ->
671626
group []
672-
, GraphicSVG.map MachineMsg <| Machine.view env model.machineState sModel.machine Set.empty
627+
, GraphicSVG.map MachineMsg <| Machine.view env model.machineState sModel.machine Set.empty transMistakes
673628
, editingButtons model |> move ( winX / 2 - 30, -winY / 2 + 25 )
674629
]
675630

@@ -766,17 +721,3 @@ snapIcon =
766721
]
767722
|> move ( 5, -10 )
768723
]
769-
770-
771-
checkTransitionValid : Set.Set String -> Bool
772-
checkTransitionValid set =
773-
case Set.member "\\epsilon" set of
774-
False ->
775-
True
776-
777-
True ->
778-
if Set.size set == 1 then
779-
True
780-
781-
else
782-
False

src/Environment.elm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module Environment exposing (Environment, init)
22

3+
import Time
4+
35

46
init : Environment
57
init =
68
{ windowSize = ( 0, 0 )
79
, holdingShift = False
810
, holdingControl = False
911
, holdingMeta = False
12+
, currentTime = Time.millisToPosix 1576798602274
13+
, timeZone = Time.utc
1014
}
1115

1216

@@ -15,4 +19,6 @@ type alias Environment =
1519
, holdingShift : Bool
1620
, holdingControl : Bool
1721
, holdingMeta : Bool
22+
, currentTime : Time.Posix
23+
, timeZone : Time.Zone
1824
}

src/Error.elm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Environment exposing (Environment)
99
import GraphicSVG exposing (..)
1010
import Helpers exposing (..)
1111
import Machine exposing (Machine, StateID, TransitionID)
12+
import Mistakes exposing (..)
1213
import Set exposing (Set)
1314
import SharedModel exposing (..)
1415
import Tuple exposing (first, second)
@@ -57,7 +58,7 @@ machineCheck sModel =
5758
sModel.machine
5859

5960
tMistakes =
60-
sModel.machine.transitionMistakes
61+
getTransitionMistakes mac
6162

6263
allTransitionLabels =
6364
List.sort <| Set.toList <| Set.remove "\\epsilon" <| List.foldr Set.union Set.empty <| Dict.values mac.transitionNames

src/Exporting.elm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Html as H
1111
import Html.Attributes as A
1212
import Json.Decode as D
1313
import Machine exposing (..)
14+
import Mistakes exposing (..)
1415
import Set exposing (Set)
1516
import Sha256 exposing (sha256)
1617
import SharedModel exposing (..)
@@ -122,6 +123,9 @@ view env ( model, pModel, sModel ) =
122123
hasErr =
123124
contextHasError errCheck sModel.machineType
124125

126+
transMistakes =
127+
getTransitionMistakes oldMachine
128+
125129
-- TODO: Adjust popup box size to fix custom error messages
126130
errHover =
127131
group
@@ -137,7 +141,7 @@ view env ( model, pModel, sModel ) =
137141
|> move ( winX / 6 - 100, -105 )
138142
in
139143
group
140-
[ (GraphicSVG.map MachineMsg <| Machine.view env Regular sModel.machine sModel.machine.start) |> move ( -winX / 6, 0 )
144+
[ (GraphicSVG.map MachineMsg <| Machine.view env Regular sModel.machine sModel.machine.start transMistakes) |> move ( -winX / 6, 0 )
141145
, machineSelected sModel.machineType winX winY
142146
, text "Choose format:"
143147
|> size 20

src/Helpers.elm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ type LatexAlign
9696

9797

9898
latex w h backclr txt align =
99+
--image (latexurl txt)
100+
-- |> move
101+
-- ( case align of
102+
-- AlignLeft ->
103+
-- 0
104+
--
105+
-- AlignRight ->
106+
-- -w
107+
--
108+
-- AlignCentre ->
109+
-- -w / 2
110+
-- , 0
111+
-- )
99112
(html w h <|
100113
H.div
101114
[ style "width" "100%"

0 commit comments

Comments
 (0)