# HG changeset patch # User Benjamin Weber # Date 1668418378 -3600 # Mon Nov 14 10:32:58 2022 +0100 # Node ID 473a8981b640caa80551264bfe4a7af086b4fd72 # Parent d15060ebf05628f287b4963315858a2be5df2693 display scrapped share of NKIT diff --git a/src/Main.elm b/src/Main.elm --- a/src/Main.elm +++ b/src/Main.elm @@ -105,7 +105,7 @@ else update (NextSteps (n - 1)) <| Tuple.first <| update (NextStep model.finishRound) model - + Step s -> case s of S0 -> @@ -120,9 +120,18 @@ S2 -> -- S2 does S3 - let f = conditionalScrap model.scrapLimit >> justDoneToDone >> wipToJustDone model.round in - ( chain <| applyStep model.kitForNkit ( Just f, - Just f) model, Cmd.none ) + let + f = + conditionalScrap model.scrapLimit >> justDoneToDone >> wipToJustDone model.round + in + ( chain <| + applyStep model.kitForNkit + ( Just f + , Just f + ) + model + , Cmd.none + ) -- FIXME: updatewaiting moves justDone to Done, which it shouldn't S3 -> @@ -193,7 +202,7 @@ defaultToCurrentModel <| Maybe.map (\y -> applyStep model.kitForNkit ( Just <| identifyScrap y, Just <| identifyScrap y ) <| { model | scrapLimit = Just y }) <| validIntInput 0 500 x SwapKITForNKIT -> - ( { model | kitForNkit = not model.kitForNkit}, Cmd.none ) + ( { model | kitForNkit = not model.kitForNkit }, Cmd.none ) SwapAutoPlay -> ( { model | autoPlay = not model.autoPlay }, Cmd.none ) @@ -362,6 +371,24 @@ scrapLimitInterface = interface2 (String.fromInt <| Maybe.withDefault 0 model.scrapLimit) (Maybe.Extra.isNothing model.scrapLimit) [ text "scrap after", text "rounds" ] ChangedScrapLimit (text "rounds") + scrapShare = + case model.scrapLimit of + Nothing -> + Element.none + + Just _ -> + let + all = + getAll model.nkit + + scrapped = + List.filter (.conditions >> .scrapped) all + + share = + (\x -> x * 100) <| safeDiv (toFloat <| List.length scrapped) (toFloat <| List.length all) + in + column [ width fill, height fill, spacing 5 ] [ text <| String.fromFloat share ++ "% of jobs", text "in NKIT scrapped" ] + batchButtons = let bButton n = @@ -439,16 +466,16 @@ playInterface = row [ spacing 10, padding 13, Font.size 12, width fill ] - [ column [width fill, height fill, spacing 7] [autoPlayer, kitForNkit] + [ column [ width fill, height fill, spacing 7 ] [ autoPlayer, kitForNkit ] , reworkProbInterface - , scrapLimitInterface + , column [ width fill, height fill, spacing 5 ] [ scrapLimitInterface, scrapShare ] --, stopThresholds ] kitForNkit = row [ Font.size 12, spacing 10, width fill ] - [ column [ spacing 5, Border.width 1, padding 5 ] [ text "KIT4NKIT", swapKITForNKITButton] + [ column [ spacing 5, Border.width 1, padding 5 ] [ text "KIT4NKIT", swapKITForNKITButton ] ] autoPlayer = @@ -456,7 +483,6 @@ [ column [ spacing 5, Border.width 1, padding 5 ] [ text "AutoPlay", autoPlayButton ] ] - --lower = -- row [ spacing 20, width fill, height fill ] [ viewField squareSizeUndone squareSizeDone model.nkit "NKIT", viewField squareSizeUndone squareSizeDone model.kit "KIT" ] netWidth = diff --git a/src/Stats.elm b/src/Stats.elm --- a/src/Stats.elm +++ b/src/Stats.elm @@ -65,26 +65,33 @@ getAll f +safeDiv : Float -> Float -> Float +safeDiv x y = + if y == 0 then + 0 + + else + x / y + + createDataPoint : Round -> Field -> Field -> DoneData createDataPoint r kit nkit = let flowtimes = List.filterMap flowTime - safeDiv x y = - if y == 0 then - 0 - - else - x / y - reworkShare xs = safeDiv (100 * (toFloat <| List.length <| List.filter (\x -> x.conditions.rework /= NoRework) xs)) (toFloat <| List.length xs) interruptedShare field = - let totalNumber = List.length field.w0 - interrupted = List.length <| List.filter (\x -> x.conditions.interruptedProcessing) field.w0 - in (\x -> 100 * x) <| safeDiv (toFloat interrupted) (toFloat totalNumber) + let + totalNumber = + List.length field.w0 + + interrupted = + List.length <| List.filter (\x -> x.conditions.interruptedProcessing) field.w0 + in + (\x -> 100 * x) <| safeDiv (toFloat interrupted) (toFloat totalNumber) flowtimeG n xs = safeDiv (100 * (toFloat <| List.length <| List.filter (\x -> x > n) xs)) (toFloat <| List.length xs)