include "primitives.alh"
include "modelling.alh"
include "object_operations.alh"

Composite schedule {
    {Contains} Success success {}
    {Contains} Failure failure {}

    {Contains} ForAll render_dataset {
        LHS {
            Pre_abstract/Signal {
                label = "0"
            }
        }
        RHS {
            Post_abstract/Signal post_ds_0 {
                label = "0"
            }
            Post_rendered/Plot post_ds_1 {
                label = "1"
                value_title = $
                    String function value(model : Element, name : String, mapping : Element):
                        return read_attribute(model, mapping["0"], "name")!
                    $
                value_legend = $
                    Boolean function value(model : Element, name : String, mapping : Element):
                        return False!
                    $
            }
            Post_rendered/Dataset post_ds_2 {
                label = "2"
                value_legend = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "signal"!
                    $
                value_color = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "blue"!
                    $
                value_linestyle = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "solid"!
                    $
            }
            Post_TracabilityLink (post_ds_0, post_ds_2) {
                label = "3"
            }
            Post_rendered/XAxis post_ds_4 {
                label = "4"
                value_name = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "time"!
                    $
                value_unit = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "seconds"!
                    $
            }
            Post_rendered/YAxis post_ds_5 {
                label = "5"
                value_name = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "signal"!
                    $
                value_unit = $
                    String function value(model : Element, name : String, mapping : Element):
                        return "power"!
                    $
            }
            Post_rendered/x (post_ds_1, post_ds_4) {
                label = "6"
            }
            Post_rendered/y (post_ds_1, post_ds_5) {
                label = "7"
            }
            Post_rendered/data (post_ds_1, post_ds_2) {
                label = "8"
            }
        }
    }

    {Contains} ForAll render_points {
        LHS {
            Pre_abstract/Signal pre_p_0 {
                label = "0"
            }
            Pre_abstract/Point pre_p_1 {
                label = "1"
            }
            Pre_rendered/Dataset pre_p_2 {
                label = "2"
            }
            Pre_TracabilityLink (pre_p_0, pre_p_2) {
                label = "3"
            }
            Pre_abstract/contains (pre_p_0, pre_p_1) {
                label = "4"
            }
        }
        RHS {
            Post_abstract/Signal post_p_0 {
                label = "0"
            }
            Post_abstract/Point post_p_1 {
                label = "1"
            }
            Post_rendered/Dataset post_p_2 {
                label = "2"
            }
            Post_TracabilityLink (post_p_0, post_p_2) {
                label = "3"
            }
            Post_abstract/contains (post_p_0, post_p_1) {
                label = "4"
            }
            Post_rendered/Datapoint post_p_5 {
                label = "5"
                value_x = $
                    Float function value(model : Element, name : String, mapping : Element):
                        return read_attribute(model, mapping["1"], "x")!
                    $
                value_y = $
                    Float function value(model : Element, name : String, mapping : Element):
                        return read_attribute(model, mapping["1"], "y")!
                    $
            }
            Post_rendered/point (post_p_2, post_p_5) {
                label = "6"
            }
        }
    }
}

Initial (schedule, render_dataset) {}

OnSuccess (render_dataset, render_points) {}
OnFailure (render_dataset, failure) {}

OnSuccess (render_points, success) {}
OnFailure (render_points, failure) {}
