Question using run() to advance simulation clock

Hey guys! First, I have a class that implements Runnable. I am using the class to store a number of features, including a systemClock which [phone] class has but stores as a default to '0'. What I am trying to achieve is a systemClock that runs till 168 "hours" irrespective of the [phone] battery's charge state, to indicate the running time of the simulation. My question is, how can I manipulate run() to advance systemClock by 1 (hour) for every half second (real-time) in the simulation? Please check my code below (and thank you!):
public void run()
            while(true)
                      // sleep delay of 500 milliseconds
                    try {runner.sleep(500);}
                    catch (Exception e) {}
                    while(systemClock < 168)
                         systemClock++;
     }

NPP83 wrote:
Sorry. The Phone implements Runnable and has a variable systemClock which stores the number of "hours" in a week. What I am asking is, does run()'s method of sleep (runner.sleep(500)) mean that every 500 miliseconds (or 1/2 second) mean it will execute the enclosed method of increasing systemClock by one (clock++)?Sort of. The main while loop will pause during the Thread.sleep for half a second. Whether it's precisely half a second or not is apparently affected by the OS (some OSes have different granularities;I don't know the details), but it's probably fine for your purposes.
You might want to look at java.util.Timer, which has different methods that try to enforce different rules about the regularity of events. It'll probably be a lot easier to use without your having to reinvent those rules.
This was a problem however:
                    while(systemClock < 168)
                         systemClock++;
                    }What this does is set systemClock to 168 in a really inefficient way. So the run() method as a whole, as you wrote it, would pause a half second, set systemClock to 168 (assuming it was less than that initially), and then do nothing, pausing while it did it. You could replace that entire run method with this:
public void run() {
    systemClock = 168;
}That's probably not what you want.

Similar Messages

  • Regarding Clocking wizard and Simulation clock generation - document and their uses VIVADO IPI

    While working with Vivado IPI , I came across two different IPs, one is simulation clock and the other is clocking wizard IP.
    But got error while generating wrapper of these IPs with the steps I did , I am unable to instantiate the IP of simulation clock generation version 1 of 2014.4.1 vivado. And get error "Clk gen" not found.
    So, can you please just give me correct direction whether these can be used  together, that is input of clocking wizard IP is simulation clock generation IP ( please correct if i am wrong) or I need to make external port in clocking wizard and assign Y9 pin of zedboard to that.
    In brief, I want to know the uses of these IPs w.r.t to some sequential design , please just elaborate theoretical example even.
     

     What do you want to do? Simulation only CLOCK Generator is only for simulation purpose.
    Can you please just give me correct direction whether these can be used  together, that is input of clocking wizard IP is simulation clock generation IP 
    --> No
    I need to make external port in clocking wizard and assign Y9 pin of zedboard to that
    --> Yes, Use the cloking Wizard 
     

  • I got a question regarding running iOs and Windows using virtual software.

    Greetings!
    I got a question regarding running iOs and Windows using virtual software. I recently bought a monitor so I can display Windows on it and run both OS at the same time.Now,I'm using BootCamp. I downloaded VirtualBox for "tranferring" Windows on it. Since I'm a new iOs user , what do I need to do in order to make work?
    Do I need to un-install Windows from BootCamp,install VirtualBox and then install them again?
    Any information would be appreciate it!

    That should work to use OS X, you can run MS Windows using Virtual Box and use a seperate display for the Virtual Box window. That way you can run OS X and MS Windows simultaneously. However remember Virtual Box is freeware and not a commercial application like Parallels or VMWare Fusion and may not have the features of a commercial application. Support for Windows run in any virtualization application (Virtual Box, Parallels or Fusion) is not generally done on this forum as they are not OS X related. To get help on those apps you usually will need to go to their forums.
    Remember IOS will not run on either OS X or MS Windows, it only works on IOS devices.
    Good luck with your installation.

  • Need help in using [RUN PROGRAM] Activity against a server in another domain

    Hi Experts,
    We have two domains with two way trust enabled. Orch server exists in DomainA and target server exists in DomainB.
    We are trying to execute some scripts(g:IPCONFIG) from orch server to target server using RUN PROGRAM activity. This is  running fine and give expected results, if I give Built-in Administrator credentials in Security Tab. But I'm getting some
    strange values like chinese/japanese language strings, If I use a DomainB/DomainA user (Part of local admin of the target server) in security tab as well as Advanced tab-->Runas.
    Things I tried:
    - DomainA/DomainB user in Security Tab as well as RunAs tab  ---> Strange Strings
    - DomainA/DomainB user in Security Tab and BuiltIn Administrator in RunAs tab  ---> Strange Strings
    - BuiltIn Administrator in Security Tab ---> Expected result
    - BuiltIn Administrator in Security Tab and DomainA/DomainB user in RunAs tab  --> ProgramExitCode = -10xxxxxx
    But our requirement is to run the script on the target server as Domain User(Part of local admin).
    Thanks in Advance
    Thanks and Regards, Narayana Babu

    Hi Experts,
    We have two domains with two way trust enabled. Orch server exists in DomainA and target server exists in DomainB.
    We are trying to execute some scripts(g:IPCONFIG) from orch server to target server using RUN PROGRAM activity. This is  running fine and give expected results, if I give Built-in Administrator credentials in Security Tab. But I'm getting some
    strange values like chinese/japanese language strings, If I use a DomainB/DomainA user (Part of local admin of the target server) in security tab as well as Advanced tab-->Runas.
    Things I tried:
    - DomainA/DomainB user in Security Tab as well as RunAs tab  ---> Strange Strings
    - DomainA/DomainB user in Security Tab and BuiltIn Administrator in RunAs tab  ---> Strange Strings
    - BuiltIn Administrator in Security Tab ---> Expected result
    - BuiltIn Administrator in Security Tab and DomainA/DomainB user in RunAs tab  --> ProgramExitCode = -10xxxxxx
    But our requirement is to run the script on the target server as Domain User(Part of local admin).
    Thanks in Advance
    Thanks and Regards, Narayana Babu

  • Questions on running an Arch Mirror

    Questions on running an Arch Mirror
    Does anyone here run a public arch mirror that can give me any idea of bandwith they use ?
    Is there any issues with running the Current and Extra mirrors in the US ?
    Is there any issues with running the Community mirror in the US ?
    Mostly I would like to know what bandwidth consumption on a public mirror is for the mirrors that are normally used.  Any help with this would be greatly appreciated. 

    I don't think he would mind this info being posted... i emailed him asking for the bandwidth info for the server for a one month period.... an average.......
    - we dont have
    a record of actual data transferred, just the amount requested (which
    stands at 5440.17 GB).
    My server only allows approx 2500 GB transfer per month... so, until i can find a way to upgrade that, I won't make it a public server.... if i did, i'd owe WAY too much money at the end of every month

  • How can I turn my Mac using iTunes into an alarm clock?

    Here's my question: How can I turn my Mac, using iTunes, into an alarm clock?
    I want to be able to put my Mac to sleep but have it set up so that when it wakes up at the predetermined time iTunes will open and start playing the music I've selected....
    A "musical alarm clock"...
    A friend suggested using the Energy Saver option in Sys. Preferences to wake the computer at the right time. He said that then I could use iCal to start iTunes. I would then have to use an Apple Script to get iTunes to play the song I want.
    But is there a SIMPLER way to do this? Are there any programs out there that do this already??
    Thanks for any help....

    I recently got a copy of AlarmClock Pro from MacWorld UK. It is shareware, I think it is (USD?)19. I haven't had a chance to try it out much, but it does look quite good. I have an older version. The latest version looks even better.
    I'm sure there's plenty of freeware apps out there. You might also want to try looking here for an applescript here Doug's AppleScripts for iTunes
    p53

  • Is there any way to use RUN button to deploy the application and open IE...

    Hi
    Thank you for reading my post
    i used to use Run button to compile / deploy and run (opening the browser to project context path) .
    i want to know is there any way to use RUN button to deploy an application to standalone OC4J and opening browser?
    I know that we can define ear or war deployment profiles and use them to deploy the application to stand alone server , but i want a single click solution.
    thanks

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • Using RunAs to enable Lync users

    Is it possible to use RunAs on a Windows 7 SP1 x64 workstation to enable Lync users. I have a one line powershell command to enable Lync users but the command the account the person is using doesn't have the correct rights. I played around with the RunAs
    command but can't seem to get it to work.

    Try this:
    $UserCredential = Get-Credential
    $a = New-PSSession -connectionuri https://lync01.domain.com/ocspowershell -Credential $UserCredential
    Import-PSSession $a
    Then run enable-csuser from there.
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
    SWC Unified Communications

  • How to use Spotify as an alarm clock

    I use Winamp as my alarm clock, a custom script runs as a scheduled task that randomly chooses from a list of playlist files, some point to local music and some point to internet radio stations. Is it possible to get Spotify to automatically play music so I can add that to my script?  I tried using the "spotify:user:username:playlist:..." and "http" links but the playlist just loads, the music doesn't start playing automatically. Any ideas?  Thanks!

    The easiest way is to have a vbs file that does this I have one that plays music atomatically(paste this into notepad): Set WshShell = WScript.CreateObject("WScript.Shell")
    Comandline = "C:\Users\Max\AppData\Roaming\Spotify\Spotify.exe"
    WScript.sleep 500
    CreateObject("WScript.Shell").Run("spotify:user:8aller:playlist:4aoBDuMJnk4Oza13a8Fnbo")
    WScript.sleep 3000
    WshShell.SendKeys " " Change the path to your spotify app location on your pc.change the my url to the "Spotify Url" of your playlist. click file>save as then save as something.vbs and save as all files click on the vbs script - it should open and play your playlistif you go to bed at the same time every day you can use task scheduler for it to autoplay at the same time every day it is also possible to have the music fade(for sleeping) via vbs and get gradually louder as well(think an alarm).

  • I need to install windows on my new Macbook pro for running my flight simulator software

    Hi!
    I'm new to the Mac world and I need to install windows on my new Macbook pro for running my flight simulator software which only runs on windows. I would like to purchase and download the windows 8.1 rather than buying the CD.
    When i go to the microsoft store and click windows 8.1 it says it is only for who has windows xp or vista...
    can you tell me where and how can i purchase the full installation 8.1 for download?
    i will keep the ISO file on my flash drive.
    Thanks!
    <Re-Titled By Host>

    it's likely an upgrade you are looking for and not a full install of windows
    http://www.techrepublic.com/blog/windows-and-office/get-the-iso-you-need-to-crea te-your-own-windows-81-dvd/
    if you get it as an iso file then you need to burn the iso file to a optical disc to install it

  • How to get Hide/Show using details in advanced table

    Hi,
    I develeoped one custom page using advanced table region and i used detail from advanced table for getting hide/show functionaliy in one column in that table. It is showing hide/show properly..but if I click on Show it is not doing any action..pls let me need to write any code in CO for getting action..
    Thanks in advance,
    Hanimi......

    If you are using the same VO and you execute in on page load then it must populate all view attribute.
    Check in back end that is there any data in that VO attribute exists or not.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                               

  • Build process by using -run-in-place option

    Hi,
    I want use runAssembler -run-in-plcae option for my developement purpose, I Dont want to do ant script for every time while hot-swap. So how to use this option, I have checked out my module under ATG 10.Root,
    And I tried this command " D:\ATG\10.0.1\home\bin>runAssembler -run-in-place test.ear -m B2CCommerce TestRun DafEar.Admin | ATGLogColorizer.exe"
    this create's in the ear with test.war as well, I want to know if we use -run-in-place, should test.war also creates or not.
    Please help me for the right command.
    Thanks,
    Prabhu.Chinaraj

    swhinck wrote:
     But if I export as SWF, some people will not be able to open it.
    Whatever format you send it, some people will not be able to open it because they may not have the software to view it.  SWF files can be viewed on any platform with Adobe Media Player.

  • I had to reinstall Win 7 and PS CS5, and the updates fail even when opened using 'run-as-admin'. Why?

    The title says it all ...
    I had to reinstall Win 7 and PS CS5, and the updates fail even when opened using 'run-as-admin'. Why?

    If you are using Help 》updates, it is outdated. You can however go to Product Updates on the Adobe.com website and download your updates there. I am not at my desk b<t when I get back, I'll get the links unless someone else can do that sooner.

  • Using Run As Account credentials

    I want to use Run As Account (SCOM) credentials (created by me using simple authentication) in a PowerShell script (on RMS machine).
    Can I be able to get the username and password and pass these into my script?
    Regards,
    Ravi

    Hi!
    Long time ago...
    I assume you need to handover Username and Password as parameter to your PoSh workflow. For that you should add the following to your probe action where you trigger the powershell module:
    <Parameter>
    <Name>RunAsUsername</Name>
    <Value>$RunAs[Name="your.mp.namespace.here.RunAsProfile"]/UserName$</Value>
    </Parameter>
    <Parameter>
    <Name>RunAsPassword</Name>
    <Value>$RunAs[Name="your.mp.namespace.here.RunAsProfile"]/Password$</Value>
    </Parameter>
    Within your script you can create a PSCredential object if needed:
    $RunAsCredential = New-Object System.Management.Automation.PSCredential -Argumentlist @($RunAsUsername,(ConvertTo-SecureString -String $RunAsPassword -AsPlainText -Force))
    Now you can access that secure variable in a given CMDLET (mostly by -credential $RunAsCredential)
    HTH (still),
    Patrick
    http://www.syliance.com | http://www.systemcenterrocks.com

  • Start sap using run

    hi guys
    start sap using run
    in c: type startsapr3 and follow the syntax

    Hello
    1 - Start CMD.exe
    2- Goto directory of Kernel
    3- sapstart.exe name=<SID> nr=<SYS_NUMBER> sapdiahost=<hostanme>
    Cheers,
    Levi Shaked

Maybe you are looking for

  • Changing FX plug in settings for channel strip aliases?

    I've been trying to migrate my live performance rig from Kore 2 to Mainstage 3, and truth be told it has not been easy, nor yet successful.  Every time I overcome one roadblock to something that was so easy to set in Kore, another problem presents it

  • How to select data from table having date in timestamp

    hi All, I have table and having one field date in type (Timestamp(6)) Date Timestamp(6) I want to select the data from this table for yesterday or current date or someother day Please let me know the query for the same. Regards Kumar

  • Frozen during installing updates unresponsive to any commands any ideas?

    Screen frozen whilst installing updates unresponsive to any commands any ideas how to come out?

  • Welcome & Rules of Engagement

    Welcome to the Remote Connection to SAP Forum! Please use the search before you post. More detailed <a href="https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement">rules of engagement</a>, can be found on the Wiki. Happy posting! The Community

  • Adobe Flash Updater

    I run OSX 10.5. I am frequently asked to update Adobe Flash, but the new version requires 10.6. Is there any way to stop the Flash Updater from prompting me to update?