Table of Contents
  1. Preface
  2. Language Reference
    1. An introduction to my OCELOT compiler
    2. OCELOT compiler features
    3. Installation
    4. Syntax and Grammer
    5. Sample program
  3. Function Reference
    1. Variable definitions
    2. Macro definitions
    3. IF statements
    4. THEN statements
    5. Miscellaneous

  1. Preface

    OCELOT is a language designed to control the Ocelot. Much of its syntax is borrowed from C and Perl.

  2. Language Reference

  3. Function Reference

    1. Variable definitions

      1. Constant

        constant <varname> = <number>;
        constant <varname> = "<string>";

        A constant definition consists of a variable name followed by either a number or a string. The compiler will substitute the value of the variable wherever the variable name is used. Example:

        constant bedroom_light = "C/3";
        constant tvPowerOn = 13;

      2. Timer

        timer [(<timer_number>)] <varname>
        timer [(<timer_number>)] <varname> = <number>;

        A timer definition consists of a variable name, or a variable name followed by a number. If it is followed by a number, then the timer will be initialized to that number after powerup on the Ocelot. Optionally, you may specify the timer number. Example:

        timer sleep;
        timer secondsSinceLastReboot = 1;
        timer(22) this_is_timer_no_22 = 1;

      3. Variable

        variable [(<variable_number>)] <varname>
        variable [(<variable_number>)] <varname> = <number>;

        A variable definition consists of a variable name, or a variable name followed by a number. If it is followed by a number, then the variable will be initialized to that number after powerup on the Ocelot. Optionally, you may specify the variable number. Example:

        variable watchingWhat;
        variable watchingTV = 0;
        variable(60) last_received_ir;

    2. Macro definitions

      macro <macro name> ( <parameter 1>, <parameter 2>, etc. ) {
      <THEN statements>
      }

      A macro definition consists of a macro name, zero or more parameters, and one or more THEN statements. Parameters must be typed with one of the following: string, number or variable. Example:

      macro entertainmentSystemOn(number whichInput, variable watching) {
        transmit_ir(tvPowerOn);
        transmit_ir(rcvrPowerOn);
        transmit_ir(whichInput);
        watching = whichInput;
      }
      

    3. IF statements

      if (<IF_function> [&& <IF_function>] [|| <IF_function>]) {
      <THEN_statements>
      } [else { <THEN_statements> }]

      An IF statement consists of one or more IF_functions (seperated by && or ||, note that there is no grouping -- they are evaluated in order) followed by one or more THEN_statements. Optionally, you may add an else statement followed by one or more THEN_statements. Example:

      if (receive_x10("A/2") || receive_ir(32)) {
        transmit_ir(2);
      } else {
        transmit_ir(3);
      }
      

      1. <variable_or_timer>

        <variable_or_timer> <Condition_code> <number>

        This statement is used to compare a variable or timer with a number. Example:

        if (sleepTimer B> 300) {
          transmit_ir(200);
        }
        
      2. Module_point

        module_point("<module>/<point>", <IO_Status>)
        module_point(<module>, <point>, <IO_Status>)

        This statement is used to check the status of a point on a particular module. Example:

        if (module_point("1/2", Turns_on) || module_point(3, 4, Is_on)) {
          transmit_ir(300);
        }
        
      3. Module_param

        module_param("<module>/<param>") <Condition_code> <number>
        module_param(<module>, <param>) <Condition_code> <number>

        This statement is used to check the status of a parameter on a particular module. Example:

        if (module_param("1/2") B> 3 || module_param(3, 5) == 6) {
          transmit_ir(440);
        }
        
      4. Receive_x10

        receive_x10("<house_code>/<key_code>")
        receive_x10("<house_code>", <key_code>)

        This statement is used to check for the receipt of an X10 signal. Example:

        if (receive_x10("A/3") ||
            receive_x10("B", 5)) {
          transmit_ir(22);
        }
        
      5. Time_of_day

        time_of_day <Is_Condition_code> "<hour>:<minute>"
        time_of_day <Is_Condition_code> "[SR][+-]<minutes>"

        This statement is used to check the current time of day. In the first format, the time must be expressed in 24 hour mode. In the second format, the time must be specified as an offset from sunSet or sunRise (currently +/- 120 minutes). Example:

        if (time_of_day = "17:30") || time_of_day = "S") {
          transmit_ir(33);
        }
        
      6. Month

        month <Is_Condition_code> <month>

        This statement is used to check the current month. Note that the month is the month number (1=January, 2=February, ..., 12=December), or you can use the predefined constants (January, February, ..., December). Example:

        if (month = February ||
            month > 9) {
          transmit_ir(33);
        }
        
      7. Day_of_month

        day_of_month <Is_Condition_code> <day>

        This statement is used to check the current day. Example:

        if (day_of_month = 9) {
          transmit_ir(33);
        }
        
      8. Day_of_week

        day_of_week <Is_Condition_code> <day>

        This statement is used to check the day of the week. Note that the day begins with 0 (Sunday=0, Monday=1, ..., Saturday=6), or you can use the predefined constants (Sunday, Monday, ..., Saturday). Example:

        if (day_of_week = 1 ||
            day_of_week = Thursday) {
          transmit_ir(33);
        }
        
      9. Year

        year <Is_Condition_code> <year>

        This statement is used to check the year. Example:

        if (year = 9) {
          transmit_ir(33);
        }
        
      10. Date

        date <Is_Condition_code> "<Month>/<Day>/<Year>"

        This statement is used to check the date. Note that the year MUST be 4 digits. Example:

        if (date > "10/14/2000") {
          transmit_ir(33);
        }
        
      11. Receive_ir

        receive_ir(<ir_number>)
        receive_ir(<module>, <ir_number>)

        This statement is used to check the receipt of an IR code. If you leave the module out, it defaults to the local module. Example:

        if (receive_ir(2) || receive_ir(1, 3)) {
          transmit_x10("A/2");
        }
        
      12. X10_status_change

        x10_status_change("<house_code>/<key_code>", <x10_status>)
        x10_status_change("<house_code>", <key_code>, <x10_status>)

        This statement is used to check for the status of an X10 signal changing. Example:

        if (x10_status_change("A/3", Turns_on) ||
            x10_status_change("B", 5, Turns_off) {
          transmit_ir(22);
        }
        
      13. IO_error_occurs

        io_error_occurs

        This statement is used to check for an io_error_occur. Example:

        if (io_error_occurs) {
          transmit_ir(22);
        }
        
      14. touch_button_pressed

        touch_button_pressed("<module>/<button>")
        touch_button_pressed(<module>, <button>)

        This statement is used to check the status of a button being pressed. Example:

        if (touch_button_pressed("1/2") || touch_button_pressed(3, 4)) {
          transmit_ir(300);
        }
        
      15. bobcat_data

        bobcat_data(<bobcat_module>) <Condition_code> <number>

        This state is used to check the status of a bobcat module. Example:

        if (bobcat_data(3) B> 2) {
          transmit_ir(22);
        }
        
    4. THEN statements

      1. <Variable>

        <variable> <Arithemetic_Op> <number>

        This statement is used to set a variable or to a number. Example:

        if (receive_x10("A/2")) {
          days += 1;
        }
        
      2. <Timer>

        <timer> = <number>

        This statement is used to set a timer or to a number. Example:

        if (x10_status_change("A/2") turns_on) {
          sleepTimer = 1;
        }
        
      3. Module_point

        module_point("<module>/<point>") <IO_State>
        module_point(<module>, <point>) <IO_State>

        This statement is used to set the point on a particular module. Example:

        if (receive_ir(2)) {
          module_point(2, 3) Turns_on;
        }
        
      4. Transmit_x10

        transmit_x10("<house_code>/<key_code>"[, <repeat_count>])
        transmit_x10(<house_code>, <key_code>[, <repeat_count>])

        This statement is used to transmit an X10 command. If a key code of 21(Dim) or 22(Bright) is specified, then an optional <repeat_count> can be specified. Example:

        if (receive_ir(2)) {
          transmit_x10("A/2");
          transmit_x10("A", 21, 6);
        }
        
      5. Transmit_ir

        transmit_ir(<ir_code>)
        transmit_ir("<module>/<zone>", <ir_code>)
        transmit_ir(<module>, <zone>, <ir_code>)

        This statement is used to transmit an IR command. Example:

        if (receive_ir(2)) {
          transmit_ir(100);
          transmit_ir("2/1", 101);
        }
        
      6. X10_preset_dim

        x10_preset_dim(<which_one>, "<x10_code>/<key_code>", <dim_level>)
        x10_preset_dim(<which_one>, "<x10_code>", <key_code>, <dim_level>)

        This statement is used to transmit a preset dim to an X10 module. The parameter <which_one> is either 0 (for PCS) or 1 (for Leviton). You may use the predefined constants 'PCS' or 'Leviton' instead of the number. Example:

        if (receive_x10("A/2")) {
          x10_preset_dim(PCS, "C/3", 22);
        }
        
      7. X10_quick_on

        x10_quick_on("<x10_code>/<key_code>")
        x10_quick_on("<x10_code>", <key_code>)
        This statement turns the specified X10 device on. Example:

        if (receive_ir(2)) {
          x10_quick_on("A", 3);
        }
        
      8. X10_quick_off

        x10_quick_off("<x10_code>/<key_code>")
        x10_quick_off("<x10_code>", <key_code>)
        This statement turns the specified X10 device off. Example:

        if (receive_ir(2)) {
          x10_quick_off("A", 3);
        }
        
      9. Send_page

        send_page(<number>)

        This statement sends a page. Example:

        if (receive_x10("A/1")) {
          send_page(2);
        }
        
      10. Transmit_x10_group

        transmit_x10_group("<house_code>", <group_command>, <number>)

        This statement sends a group command to all Leviton modules on a given house code. The group command is either 0 (for group to off) or 1 (for group to preset). You can use the predefined constants (group_to_off or group_to_preset) instead of the numbers if you wish. Example:

        if (receive_ir(1, 7)) {
          transmit_x10_group("B", group_to_preset, 23);
        }
        
      11. Transmit_speak_easy

        transmit_speak_easy("<module>/<message_no>)

        transmit_speak_easy(<module>, <message_no>)

        This statement allows you to send an audible pre-recorded message from the Speak Easy. Example:

        if (receive_x10("B/3")) {
          transmit_speak_easy("1/5");
          transmit_speak_easy(2, 3);
        }
        
      12. Transmit_ascii_string

        transmit_ascii_string(<number>)

        This statement allows you to send an ascii string out the RS-232 port of the Ocelot. Example:

        if (receive_x10("B/3")) {
          transmit_ascii_string(3);
        }
        
      13. Set_slave_variable

        set_slave_variable("<slave_type>", <slave_address>, <variable_number>, <data>)

        This statement sets a variable on a slave "Ocelot" or "Leopard". Example:

        if (receive_ir(2, 3)) {
          set_slave_variable("Ocelot", 2, 23, 32700);
        }
        
      14. Load_data_to

        load_data_to(<variable_number>)

        This state allows you to load data to a variable. Sorry, I don't know what this means -- if you do, please send me an explanation. :-) Example:

        if (receive_x10("B/2")) {
          load_data_to(3);
        }
        
      15. Send_rcs_x10

        send_rcs_x10(<house_code>, "<rcs_command>" [, <data>]) This statement sends an RCS command to a the specified thermostat. Example:

        if (receive_ir(3, 4)) {
          send_rcs_x10("A", "Heat Mode");
          send_Rcs_x10("A", "Setpoint", 68);
        }
        
      16. Send_bobcat_thermostat

        send_bobcat_thermostat(<bobcat_address>, "<bobcat_command>" [, <data>]) This statement sends a command to a bobcat thermostat. Example:

        if (receieve_x10("A/3")) {
          send_bobcat_thermostat(3, "System Mode Heat");
          send_bobcat_thermostat(3, "Setpoint", 69);
        }
        
    5. Miscellaneous

      • Condition code

        Condition codes followed by "(*)" are "Is" condition codes. Only use one of these four codes when the statement definition calls for an Is_condition_code.

        Condition Code Description
        > (*) is greater than
        < (*) is less than
        != (*) is not euqal to
        = (*) is equal to
        B> becomes greater than
        B< becomes less than
        B!= becomes not equal to
        B= becomes equal to

      • IO State

        Note that you can either use the predefined variable name from the table below, or you can use its numeric equivalent.

        Predefined Variable Value
        Turns_off 0
        Turns_on 1

      • IO Status

        IO Status
        Is_off
        Is_on
        Turns_off
        Turns_on

      • Arithemetic Op

        Operation Description
        = set equal to number
        += add number to variable
        -= subtract number from variable
        *= multiple variable by number
        /= divide variable by number

      • X10 Status

        X10 Status
        Is_off
        Is_on
        Turns_off
        Turns_on
        On_command_pair
        Off_command_pair

      • Slave Type

        Type Description
        "Ocelot" Slave is an ocelot (or cpuxa)
        "Leopard" Slave is a leopard

      • RCS Command

        RCS Command
        Setpoint
        System OFF
        Heat Mode
        Cool Mode
        Auto Mode
        Fan ON
        Fan OFF
        Setback ON
        Setback OFF
        Increase 1 Degree
        Decrease 1 Degree
        Setback Delta 6F/3C
        Setback Delta 8F/4C
        Setback Delta 10F/5C
        Setback Delta 12F/6C
        Setback Delta 14F/7C
        Setback Delta 16F/8C
        Unit ON
        Unit OFF
        Preset ON
        Preset OFF
        Ack ON
        Ack OFF
        Echo ON
        Echo OFF
        Safe ON
        Safe OFF
        Autosend ON
        Autosend OFF
        DT1
        DT2
        DT3
        DT4

      • Bobcat Command

        Bobcat Command
        Setpoint
        System Mode Auto
        System Mode Cool
        System Mode Heat
        System Mode OFF
        Fan Mode Auto
        Fan Mode ON
        Hold Release