SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-26-2017, 11:02 AM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Studio and enums

Hi,

I am not sure if I am just being dense, but I am having an issue utilizing enums in a project I am working on in studio.

Here is the scenario

Method I am calling which returns an enum
Code:
public HVACMode getHVACMode()
The enum
Code:
public enum HVACMode
    {
        OFF("Off", "Off"),
        HEAT_ON("HeatOn", "Heat On"),
        COOL_ON("CoolOn", "Cool On"),
        AUTO_CHANGE_OVER("AutoChangeOver", "Auto Change Over"),
        UNKNOWN("Unknown", "Unknown");
        
        private String mode;
        private String name;
        
        private HVACMode(String mode, String name)
        {
            this.mode = mode;
            this.name = name;
        }
        
        public static HVACMode parseMode(String mode)
        {
            if(mode.equals(OFF.getMode()))
            {
                return OFF;
            }
            else if(mode.equals(HEAT_ON.getMode()))
            {
                return HEAT_ON;
            }
            else if(mode.equals(COOL_ON.getMode()))
            {
                return COOL_ON;
            }
            else if(mode.equals(AUTO_CHANGE_OVER.getMode()))
            {
                return AUTO_CHANGE_OVER;
            }
            else
            {
                return UNKNOWN;
            }
            
        }
        
        public String getMode()
        {
            return mode;
        }
        
        public String getName()
        {
            return name;
        }
    }
So I am trying to do this call and it is saying that is can not reflect the static value

Code:
IF jvl_vera_devices_Thermostat_getHVACMode(instance) == jvl_vera_devices_Thermostat_HVAVMode_OFF

Sage says it does not know what "jvl_vera_devices_Thermostat_HVAVMode_OFF" is. Is this possible. Am I doing something wrong. What do you do if there is an underscore in the name of the enum like "HEAT_OFF"?

Any help would be appreciated.

Josh
Reply With Quote
  #2  
Old 01-26-2017, 11:52 AM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
I don't think I've seen an enum used in studio - it my simply not be supported. You likely should implement a simpler method that either returns a string, or a series of boolean 'isOff, isOn' etc methods.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #3  
Old 01-26-2017, 12:19 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Quote:
Originally Posted by Fuzzy View Post
I don't think I've seen an enum used in studio - it my simply not be supported. You likely should implement a simpler method that either returns a string, or a series of boolean 'isOff, isOn' etc methods.
Yeah... That is what I have been doing

Do you know if there is a way to handle method names or variables with an underscore in them?
Reply With Quote
  #4  
Old 01-26-2017, 12:31 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by jvl711 View Post
Yeah... That is what I have been doing

Do you know if there is a way to handle method names or variables with an underscore in them?
Same... I don't think you can. From what I remember, Sun recommends against using underscores in method and variable names, and recommends using CamelCase for everything.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #5  
Old 01-26-2017, 12:59 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Quote:
Originally Posted by Fuzzy View Post
Same... I don't think you can. From what I remember, Sun recommends against using underscores in method and variable names, and recommends using CamelCase for everything.
I would generally agree that ubderscores are not common, but in this particular case it 100% follows the java convention. Below is the convention for constants, which is what I would consider the value of an enum.

http://www.oracle.com/technetwork/ja...ns-135099.html

Quote:
Constants:

The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ("_"). (ANSI constants should be avoided, for ease of debugging.)

static final int MIN_WIDTH = 4;

static final int MAX_WIDTH = 999;

static final int GET_THE_CPU = 1;
Reply With Quote
  #6  
Old 01-26-2017, 01:48 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Right, just remember that Studio is not Java. It utilized Java for it's expressions, but it is not equivalent to java code completely. It you want to run full java code, you compile that into a .jar, and make calls to that from the STV.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #7  
Old 01-26-2017, 06:02 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
I figured out my issue. Apparently studio somehow handles variables and methods with underscores without issues. It also can handle enums without issues.

Where my issue was I created my enum as a subclass/innerclass of another class. Sage was having issues creating an instance of the enum or referencing methods of the enum in this manner. I moved it out to its own and it works great!

So in otherwords I am not sure Studio can handle inner classes, or enums inside a class. This might have been my own stupidity, or possible just a weird reflection issue.

Josh
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with enums in Studio tmiranda SageTV Studio 2 09-04-2010 03:50 PM
Studio for V7 bclenney SageTV Studio 2 07-30-2010 02:57 PM
any chances of altering the graphics in sage without studio? studio users please read reboot_this SageTV Customizations 1 12-03-2004 04:03 AM


All times are GMT -6. The time now is 11:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.