<?xml version="1.0" encoding="UTF-8"?>
<CSML xmlns="http://bacnet.org/csml/1.2" defaultLocale="en-US">
    <Definitions>
        <Composition name="DREventSummary" description="summary of OpenADR event information exchanges tied to a specific event.">
            <List name="DREventSummaryDetails" description="provides a summary of a single OpenADR event">
                <MemberTypeDefinition>
                    <Composition>
                        <String name="programName" description="facility user-provided name for DR program"/>
                        <String name="venID" description="VEN ID with format specified by DR program"/>
                        <Composition name="problem" optional="true" description="for error tracking">
                            <Integer name="status" optional="true" description="http status code in response from VEN back to VTN if there is an error"/>
                            <String name="detail" optional="true" description="provides a human readable explanation specific to this occurrence of the problem"/>
                            <Link name="type" optional="true" description="URI identifying specific problem type"/>
                            <String name="title" optional="true" description="short description of problem type"/>
                            <Link name="instance" optional="true" description="URI identifying specific problem"/>
                        </Composition>
                        <Composition name="event" description="key information elements from the Event component of the most recent DR event message">
                            <String name="eventID" optional="true" description="Unique event ID"/>
                            <DateTime name ="createdDateTime" optional="true" description="Server timestamp on event creation"/>
                            <String name="modificationDateTime" optional="true" description="Most recent event modification timestamp (if any)"/>
                            <String name="programID" description="ID attribute of program object this event is associated with"/>
                            <String name="eventName" optional="true" description="User-defined name for event (e.g., for user interface)"/>
                            <Integer name="priority" optional="true" description="Relative priority of event from 0 to 3, 0 being highest priority"/>
                            <DateTime name ="start" description="Start time of the event. BACnet ESI supports multi-interval price events where intervals have the same durations, but not multi-part events with varying durations."/>
                            <Integer name="duration" description="duration of each interval, seconds. If more than one interval, then each interval is of the same duration."/>
                            <Integer name="randomizeStart" optional="true" description="indicates a randomization time that may be applied to start, in seconds."/>
                            <String name="payloadType" optional="true" description=" From OA3 eventPayloadDescriptor/payloadType , e.g., 'SIMPLE' or 'PRICE'."/>
                            <Array memberType="String" name="values" description="OA3 event level (SIMPLE) is type INT, PRICE is type REAL. OA3 Data values: event/payloads/valuesMap/values. Note: Duration provides the length of each interval, and the length of this values array times duration provides the total event duration (if more than one interval)."/>
                            <String name="units" optional="true" description="OA3 eventPayloadDescriptor/units"/>
                            <String name="currency" optional="true" description="eventPayloadDescriptor/currency"/>
                        </Composition>
                    </Composition>
                </MemberTypeDefinition>
            </List>
        </Composition>

        <Composition name="DRProgram" description="DR Program provides program metadata with meter metadata for each DR program.">
            <String name="programID" description="VTN assigned program ID"/>
            <String name="programName" description="User provided short name for program, e.g., ComTOU"/>
            <String name="programLongName" optional="true" description="User provided long name for program, e.g., Commercial TOU-A"/>
            <String name="retailerName" optional="true" description="Name of energy retailer providing the program."/>
            <String name="programType" optional="true" description="user-defined program category (e.g., 'Pricing_Tariff')"/>
            <String name="venID" optional="true" description="Virtual end node object ID"/>
            <List memberType="Link" name="programDescription" optional="true" description="URI(s) pointing to human/machine-readable content."/>
            <List memberType="Link" name="drMeter" optional="true" description="Links point to some site-specific meter metadata. A link may point to a meter object, where 'http' or 'https' points to a BACnet/WS accessible resource, or may identify a meter ID or name using 'urn' or 'tag' as a non-locating 'identifier' (for example, 'tag:wossamotta.edu,2022:Meter12').  There may be more than one meter associated with a DR program."/>
        </Composition>

        <Composition name="DRMessageLog" description="log of all DR messages exchanged with facility ESI.">
            <DateTime name="logStartTime" description="start date and time for log record"/>
            <DateTime name="logEndTime" description="end date and time for log record"/>
            <String name="logDescription" optional="true" description="description of log contents"/>
            <List name="drLog" description=" message log for each event of each DR program ">
                <MemberTypeDefinition>
                    <Composition>
                        <String name="venID" description="VEN ID with format specified by DR program"/>
                        <String name="programID" description="DR program specific ID"/>
                        <List memberType="Link" name="programDescription" optional="true" description="URI(s) pointing to human/machine-readable content."/>
                        <String name="eventID" description="Unique event ID"/>
                        <List name="drLogMessageText" description="flattened text of each DR event-related message">
                            <MemberTypeDefinition>
                                <Composition>
                                    <DateTime name="MessageTime" description="datetime message was received at or sent from the VEN"/>
                                    <String name="MessageBody" description="flattened message text"/>
                                </Composition>
                            </MemberTypeDefinition>
                        </List>
                    </Composition>
                </MemberTypeDefinition>
            </List>
        </Composition>
    </Definitions>

</CSML>
