Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: couple code questions, since i'm coding again :)

  1. #1
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346

    couple code questions, since i'm coding again :)

    Since John has been posting lately, it really did invogorate me to get back to looking at some of the code. Since then, I have actually drawn up a design that I think might work. I am working on a couple different plugins (including a complete re-write of my sports plugin since I lost the code) and have just thought of a couple questions while designing. My apologies if these are easy to see in the IDE but here goes:

    Is there a z-order set for your controls? The normal .net environment used a .sendtoback or .bringtofront. Or is it set on the order in which controls are added?

    I've thought of using a couple different pulldown menu's to house buttons. Keeps the screen clear. I set the "up" and "down" portions in two different functions, then call either one as a separate safethread.asynchronous, so I'll assume the functions are called on separate threads. If the user activates one without the other finishing it would cause problems. I remember reading a while back of being able to 'queue' things, is that feasible with functions? Or, can code be locked out easily without a rediculous boolean variable hack checking it almost everyline if you need to exit?

    Other than that, new designs are going well and fast, almost ready to jump back into the actual coding! Thanks for the renewed interest
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

  2. #2
    Maximum Bitrate jmullan99's Avatar
    Join Date
    Feb 2009
    Location
    Niagara Falls, Ontario
    Posts
    682
    Hello detlion.

    Glad to have re-ignited the fire!

    One of the hardcore devs will have to answer these questions for you. I think I can partially answer your Z-order question. While you are coding .Net, you are not using forms based coding, so the senttoback and bringtofront don't apply. I'm pretty sure OM provides such functionality, but this is currently where my knowledge ends (can't tell you what many of the methods and properties are for many things).

    The guys have been away for a few days (work, vacation, whatever) and will probably reply soon.

    Cheers,
    John
    ZOTAC G43ITX-A-E 2.5ghz Core i3 2GB 160GB SSD
    Win7 Ultimate - OpenMobile - Directed HD - Wifi
    OMMaps + MS GPS Puck - WiFi via LTE Android phone
    2 Zones - Matrix Orbital LCD - Arduino - Build Pics

  3. #3
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by detlion1643 View Post
    Since John has been posting lately, it really did invogorate me to get back to looking at some of the code. Since then, I have actually drawn up a design that I think might work. I am working on a couple different plugins (including a complete re-write of my sports plugin since I lost the code) and have just thought of a couple questions while designing.
    Nice to see you back in action again!

    Quote Originally Posted by detlion1643 View Post
    Is there a z-order set for your controls? The normal .net environment used a .sendtoback or .bringtofront. Or is it set on the order in which controls are added?
    It is set by the order it's added but you can also affect it by using the following methods of the OMPanel object; increaseZOrder, decreaseZOrder, MoveControlToBack and MoveControlToFront.

    Quote Originally Posted by detlion1643 View Post
    I've thought of using a couple different pulldown menu's to house buttons. Keeps the screen clear. I set the "up" and "down" portions in two different functions, then call either one as a separate safethread.asynchronous, so I'll assume the functions are called on separate threads. If the user activates one without the other finishing it would cause problems. I remember reading a while back of being able to 'queue' things, is that feasible with functions? Or, can code be locked out easily without a rediculous boolean variable hack checking it almost everyline if you need to exit?
    Easiest way of controlling access to an object is by "locking" it;
    Pseudo-code:
    Code:
    lock (object to lock or a dummy object)
    {
       ....... Up/down code .......
    }
    This code would block other threads from accessing an object until the current lock has been released, which happens when the other thread exits.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  4. #4
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    ^^^ Thanks! Putting that stuff to good use.

    I have thought about something else that might help:

    I know there is a way to make multiple panels, and transition between them and whatnot, however, trying to look through the plugins, I cannot seem to figure it out ::.
    None of the original "main" panels in any plugin is given a name (ex, ompanel panelmain = new ompanel(). I have seen the next panel get a name though (ex, ompanel subpanel = new ompanel("subpanel"). Yet, it seems like every .transitiontopanel or .executetransition or anything to do with that always mentions a "Main Menu" and "subpanel", or a line with no mention of panel names? Is it possible to get quick psuedo-code to finish this out if possible:
    Code:
    OMPanel main = new OMPanel();
    OMPanel sub = new OMPanel("sub");
    ... other code here (including 2 buttons for this example) ...
    
    button1clickcode
    {
    //transition to "sub" panel here please
    }
    
    button2clickcode
    {
    //transition back to "main" panel here please - or original panel upon plugin load
    }
    I know the other code and code for buttons and all, the transitions need filled in. It would streamline my plugin so much, and allow me to sort and place the code and I'll know where things are! It would speed it up and make it more efficient as well since I'm going to have so much going on in it.
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

  5. #5
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by detlion1643 View Post
    Is it possible to get quick psuedo-code to finish this out if possible:
    Code:
    OMPanel main = new OMPanel("main");
    OMPanel sub = new OMPanel("sub");
    ... other code here (including 2 buttons for this example) ...
    
    button1clickcode
    {
    //transition to "sub" panel here please
    
    // Transit panel Main Out
                Host.execute(eFunction.TransitionFromPanel, screen.ToString(), (Name of your plugin), (Name of panel to remove; in this case "main"));
    
    // Transit panel Sub IN
                Host.execute(eFunction.TransitionToPanel, screen.ToString(), (Name of your plugin), (Name of panel to show; in this case "sub"));
    
    // Execute requested transition
                Host.execute(eFunction.ExecuteTransition, screen.ToString(), "SlideLeft");
    
    // Please note that you don't have to remove a panel unless you don't need it anymore. If you just 
    // want to show something temporarily to the user then transition your new panel in, do something 
    // then go back.
    }
    
    button2clickcode
    {
    //transition back to "main" panel here please - or original panel upon plugin load
                        Host.execute(eFunction.goBack, screen.ToString());
    
    }
    Not sure if the above code was what you where looking for, if not I'll provide another example.

    Naming of panels has been somewhat confusing earlier (this has now been addressed in the current development code) as if there is no name provided it means "default panel". All other panels would require named access. But basic rule (to keep your code compatible with future requirement) is to always use a name for you panels.
    So in your case I'd give the name "Main" to your panel without a name.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  6. #6
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    Naming of panels has been somewhat confusing earlier (this has now been addressed in the current development code) as if there is no name provided it means "default panel". All other panels would require named access. But basic rule (to keep your code compatible with future requirement) is to always use a name for you panels.
    So in your case I'd give the name "Main" to your panel without a name.
    Just did a quick test, but here's what happened:
    If I don't give a name to the "main" panel, it will load up as the first panel for the plugin. If I give a name of "main" to it, no panel loads when clicking the plugin. Without the "main" name for the panel, the .TransitionFromPanel function can be commented out, and the .TransitionToPanel function still works (the new "sub" panel shows) as noted in the code. But not removing the panels results in the first un-named panel to appear again when clicking out of the plugin (back home) and back into the plugin.

    The last version I bothered getting to dev with was back from April sometime... Maybe since you mentioned naming problems, I still have a version with naming problems?

    EDIT: Adding another in real fast before bed... If I add a systems.timers.timer with a tick event for every 30 seconds, the timer seems to start ok, but causes problems because my controls haven't really been set yet. Inside the timer tick event, I loop through the host.screencount and perform the update of data like this:
    Code:
    void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
            {
                for (int i = 0; i < theHost.ScreenCount; i++)
                {
                    OMList sportslist = (OMList)manager[i]["sportslist"];
                    sportslist.Clear();
                    SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                }
            }
    but inside the fillsportslist(screen) function it errors on this line:
    Code:
    OMList sportslist = (OMList)manager[screen]["sportslist"];
    saying "Index was outside the bounds of the array." Hovering over sportslists gives a value of null. So, sportslist hasn't been set yet (everything works without the timer). Is there a way around getting the controls set or the timer calling the controls before they actually set. This happens because I have not clicked into my plugin yet, so as I come to think of no controls for my plugin are really set yet at all?
    Last edited by detlion1643; 08-25-2011 at 09:47 PM.
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

  7. #7
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by detlion1643 View Post
    Just did a quick test, but here's what happened:
    If I don't give a name to the "main" panel, it will load up as the first panel for the plugin. If I give a name of "main" to it, no panel loads when clicking the plugin. Without the "main" name for the panel, the .TransitionFromPanel function can be commented out, and the .TransitionToPanel function still works (the new "sub" panel shows) as noted in the code. But not removing the panels results in the first un-named panel to appear again when clicking out of the plugin (back home) and back into the plugin.
    The last version I bothered getting to dev with was back from April sometime... Maybe since you mentioned naming problems, I still have a version with naming problems?
    This is not a naming problem, your plugin (as in you) are the one responsible for loading the panel you want to show when the frameworks asks for a panel without any name. This is all handled in the loadPanel method in your plugin. There you check for a panalname equal "", if true return the panel you want to show/hide/affect. This is the default panel for your plugin.

    Quote Originally Posted by detlion1643 View Post
    EDIT: Adding another in real fast before bed... If I add a systems.timers.timer with a tick event for every 30 seconds, the timer seems to start ok, but causes problems because my controls haven't really been set yet. Inside the timer tick event, I loop through the host.screencount and perform the update of data like this:
    Code:
    void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
            {
                for (int i = 0; i < theHost.ScreenCount; i++)
                {
                    OMList sportslist = (OMList)manager[i]["sportslist"];
                    sportslist.Clear();
                    SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                }
            }
    but inside the fillsportslist(screen) function it errors on this line:
    Code:
    OMList sportslist = (OMList)manager[screen]["sportslist"];
    saying "Index was outside the bounds of the array." Hovering over sportslists gives a value of null. So, sportslist hasn't been set yet (everything works without the timer). Is there a way around getting the controls set or the timer calling the controls before they actually set. This happens because I have not clicked into my plugin yet, so as I come to think of no controls for my plugin are really set yet at all?
    You load all the controls you need in the initialization part of your plugin, if this is done then they are accessible from thereon. What panel are they located on? Since you didn't pass a panel name along with the screen number it tries to use a control from the panel with no name in it.
    Use the following code to access a given control on a given panel (this is the command that you should always use, access without passing a name along will be discarded in later versions):
    Code:
    OMList sportslist = (OMList)manager[screen, panelName]["sportslist"];
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  8. #8
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    Actually, for the timer part, I haven't named a single panel yet (in fact, I only have the 1 still). So, I have 1 panel, not named, but loads correctly if I click into the plugin. However, even after clicking into the plugin and filling the sportslist, the timer still causes problems. I'm just commenting out the timer.enabled part because it's not the end all be all of the plugin.

    I'm probably starting to sound like a pain for all these questions, but I'm still a little confused as how to control which panel is actually loaded first? You need to load all panels through the intialize function, correct?

    Code:
    public OMPanel loadPanel(string name, int screen)
            {
                if (manager == null)
                    return null;
                return manager[screen, name];
            }
    [code]this.manager.loadPanel(p); //has no name
    this.manager.loadPanel(s); //has name of sub
    return eLoadStatus.LoadSuccessful;[code]
    This is what I'm referring to, if I give panel p a name of "main", it doesn't load... I'll bug off a little and keep coding my sports plugin, sorry for all these questions again...
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

  9. #9
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by detlion1643 View Post
    Actually, for the timer part, I haven't named a single panel yet (in fact, I only have the 1 still). So, I have 1 panel, not named, but loads correctly if I click into the plugin. However, even after clicking into the plugin and filling the sportslist, the timer still causes problems. I'm just commenting out the timer.enabled part because it's not the end all be all of the plugin.
    Not quite sure I follow you on this problem. Could you post some of your code?

    Quote Originally Posted by detlion1643 View Post
    I'm probably starting to sound like a pain for all these questions, but I'm still a little confused as how to control which panel is actually loaded first? You need to load all panels through the intialize function, correct?
    No worries. I'm glad you're interested and quite happy to help out.

    Your initialize method should look like this:
    Code:
    public eLoadStatus initialize(IPluginHost host)
    {
    OMPanel p = new OMPanel("main");
    OMPanel s = new OMPanel("sub");
    
    ... Add controls ...
    
    this.manager.loadPanel(p);
    this.manager.loadPanel(s);
    return eLoadStatus.LoadSuccessful;
    }
    Your loadPanel method should look like this:
    Code:
    public OMPanel loadPanel(string name, int screen)
            {
                // Errorhandling
                if (manager == null)
                    return null;
    
                // Load default panel
                if (name == "")
                    return manager[screen, "main"];
    
                // Return requested panel
                return manager[screen, name];
            }
    The reason why a panel named "main" doesn't load is because the framework doesn't know which panel to load by default (hence no name passed along) so you have to catch this request and return the panel you want to load as default.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  10. #10
    Variable Bitrate
    Join Date
    Jul 2010
    Posts
    346
    Your initialize method should look like this:
    Code:
    public eLoadStatus initialize(IPluginHost host)
    {
    OMPanel p = new OMPanel("main");
    OMPanel s = new OMPanel("sub");

    ... Add controls ...

    this.manager.loadPanel(p);
    this.manager.loadPanel(s);
    return eLoadStatus.LoadSuccessful;
    }
    Your loadPanel method should look like this:
    Code:
    public OMPanel loadPanel(string name, int screen)
    {
    // Errorhandling
    if (manager == null)
    return null;

    // Load default panel
    if (name == "")
    return manager[screen, "main"];

    // Return requested panel
    return manager[screen, name];
    }
    The reason why a panel named "main" doesn't load is because the framework doesn't know which panel to load by default (hence no name passed along) so you have to catch this request and return the panel you want to load as default.
    Works good, and the transitions a couple posts back are working good as well. If I transitionfrompanel "main" topanel "sub", click home, and back into my plugin I am at the "main" panel again. I figured this would be the case, so is there a way to leave the plugin somehow remember what panel you were on, and somehow navigate back to that panel?

    Not quite sure I follow you on this problem. Could you post some of your code?
    Sure (this is the most simplified version I have working - none of the new panel names and additional panels are included yet in this attempt):
    Code:
    namespace OMSports
    {
        public class OMSports : IHighLevel
        {
            private ScreenManager manager;
            private IPluginHost theHost;
            private Settings settings;
            private System.Timers.Timer updatetimer = new System.Timers.Timer();
    
            public OMPanel loadPanel(string name, int screen)
            {
                if (manager == null)
                    return null;
                return manager[screen, name];
            }
    
            public eLoadStatus initialize(IPluginHost host)
            {
                OMPanel p = new OMPanel();
    
                OMList sportslist = new OMList(0, 175, 600, 275);
                sportslist.Name = "sportslist";
                sportslist.ListStyle = eListStyle.MultiListText;
                //sportslist.OnClick += new userInteraction(sportslist_onclick);
                sportslist.Visible = false;
    
                updatetimer.Interval = 30000; //30 second update
                updatetimer.Elapsed += new System.Timers.ElapsedEventHandler(updatetimer_tick);
                updatetimer.Enabled = true;
    
                this.manager.loadPanel(p);
                return eLoadStatus.LoadSuccessful;
            }
    
             void updatetimer_tick(object sender, System.Timers.ElapsedEventArgs e)
            {
                for (int i = 0; i < theHost.ScreenCount; i++)
                {
                    OMList sportslist = (OMList)manager[i]["sportslist"];
                    sportslist.Clear();
                    SafeThread.Asynchronous(delegate() { fillsportslist(i); }, theHost);
                }
            }
    
            private void fillsportslist(int screen)
            {
                OMList sportslist = (OMList)manager[screen]["sportslist"];
                ........snip.............
            }
    
        } //end class
    } //end namespace
    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
    www.rav4world.com - Forums for Rav4 owners
    www.flavorfeasts.com - Cooking website/forums
    -Basic forums live atm, come contribute!

Page 1 of 2 12 LastLast

Similar Threads

  1. Couple questions
    By Iamthehor in forum Qube
    Replies: 1
    Last Post: 06-30-2010, 09:18 PM
  2. code wizards, help with some coding? (OBDII diagnostic codes)
    By CTdubbin in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 35
    Last Post: 11-08-2009, 12:35 PM
  3. Few Coding questions
    By djurchicprelude in forum Fusion Brain
    Replies: 5
    Last Post: 11-24-2008, 08:01 AM
  4. Newbie with coding questions...
    By thekl0wn in forum Newbie
    Replies: 10
    Last Post: 08-29-2006, 05:45 AM
  5. Couple of Questions
    By tux11 in forum StreetDeck
    Replies: 6
    Last Post: 07-18-2006, 11:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •