Commit d857d8e8 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Add custom queries to smv output

parent 97d330db
......@@ -83,10 +83,16 @@ update msg model =
Debug.log "error" "No rail example present"
|> always Nothing
Just example ->
let
additional_queries =
case (parseQuery model.next_query) of
[] -> []
x -> [x]
in
Just
{ filename = example.name ++ ".smv"
, content =
NuSmvOutput.compile example
NuSmvOutput.compile example additional_queries
|> NuSmvOutput.show
}
in
......@@ -139,13 +145,7 @@ update msg model =
QueryRun ->
let
query =
model.next_query
-- extract all numbers, no matter how they are separated
|> Regex.find Regex.All (regex "[0-9]+")
|> List.map (.match)
|> List.filterMap (Result.toMaybe << String.toInt)
|> List.map (\x -> x - 1) -- make them 0-indexed.
|> ListUtils.dropDuplicates
parseQuery model.next_query
in
(model, RPCmd.SetQuery query)
......@@ -237,6 +237,15 @@ compileTraceLine line =
|> RPCmd.Batch
))
parseQuery : String -> List Int
parseQuery =
-- extract all numbers, no matter how they are separated
Regex.find Regex.All (regex "[0-9]+")
>> List.map (.match)
>> List.filterMap (Result.toMaybe << String.toInt)
>> List.map (\x -> x - 1) -- make them 0-indexed.
>> ListUtils.dropDuplicates
viewQuery : List Int -> Html.Html a
viewQuery query =
let
......
......@@ -268,10 +268,10 @@ showDetailedShuntMovement dsm =
{-|
Given a rail tree and the car positions, compute a smv file.
The query is still missing.
Optionally, add some additional queries
-}
compile : RailExample -> SmvFile
compile rail_example =
compile : RailExample -> List RailExample.Query -> SmvFile
compile rail_example additional_queries =
let
shunts : Array (NonEmptyList RT.Path)
shunts = -- the array of non-empty shunts
......@@ -463,6 +463,7 @@ compile rail_example =
-- in order to get a 'Nothing' value for an empty query list
-- replace that 'Nothing' by the default query of sorting the cars
|> Maybe.withDefault ([List.indexedMap always rail_example.car_positions])
|> (flip (++) additional_queries)
|> List.map permutation2query
}
......
......@@ -12,10 +12,13 @@ type alias RailExample =
{ name : String
, rail_net : RailTree (Has RT.Hint ()) (Has RT.Angles ())
, car_positions : List RT.Path
, queries : List (List Int) -- 0-indexed query
, queries : List Query -- 0-indexed query
, rotation : Float -- the initial angle
}
type alias Query = List Int
{-| permute the cars on a rail example
That is the perm : List Int describes the order in which
the cars appear in the initial configuration.
......@@ -27,7 +30,7 @@ permute_by perm re =
}
-- add a 1-indexed query
addQuery : List Int -> RailExample -> RailExample
addQuery : Query -> RailExample -> RailExample
addQuery perm re =
{ re
| queries = re.queries ++ [List.map (\x -> x - 1) perm]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment