Monday, March 31, 2014

Download C 2010 For Programmers Fourth Edition by DEITEL DEVELOPER SERIES

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:


This post leads you to set a new password on your ZTE Nubia Z5S/Nubia Z5S Mini phone step by step.

Step 1: Go to Settings.

Step 2: Find and enter Security.

Step 3: Choose Screen lock to select a screen lock.

Step 4: Select Password from the provided options.

Step 5: Set up a password and tap Continue.

Please remember that the code should contain at least 4 characters, including at least 1 letter.

Step 6: Re-enter the code and click OK.

After setting a password in your phone, you should keep it firmly in your mind to avoid any inconvenience.


Related Articles:

Nokia 2630 White Screen, blank and blue LCD display problem solution

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:

Samsung has successfully revealed Galaxy S5 and has even announced the release date for its availability in 150 countries but what about the release date of its future successor, Galaxy S6? The heir of SGS5 will be coming out in next year’s first quarter as per the rumors wheezes on web. Here in this post I will be telling you Nokia 2630 White Screen, blank and blue LCD display problem solution about the best possibilities of Samsung Galaxy S6 release date.

Samsung launched the very first member of Galaxy S series in June 2010 and since then the world-famous smartphone series has received successors one after other each year. Samsung has usually released each successor at the end of first quarter or starting of second quarter every year and had made a tradition like phenomena for this famous mobile series. You can have an eye on the release dates of other Galaxy “S” series members below:

Galaxy S (i900): June 2010

Galaxy S2 (i9100): April 2011

Galaxy S3 (i9300): May 2012

Galaxy S4 (i9500): April 2013

The latest addition to this renowned mobile chain is revealed officially and is set to release in April in around 150 countries as mentioned above also. Talking about the Galaxy S6 release date and considering the tradition which Samsung has followed since the release of second member of Galaxy S series i.e. making the device officially public all over the world in February and then making it available for sale to all countries in April. This thing can somehow ensure that the Galaxy S VI will be also revealed around February and get release in the 2015’s second quarter i.e. in April or May.

Well, the above possibility makes it much truer as per the Samsung’s previous launches of S series devices is considered but if we mull over to the competition faced by the Korean firm we can expect the launch of Samsung Galaxy S6 in the late 2014 i.e. either November or December. This seems a little bit tougher for the firm to take such decision of launching two flagships in a year hence, making it immaterial for the release of SGS6 in 2014 only. 

Some other promising specs of the device include a 64 Bit process, 4 GB RAM, 21 megapixels back camera, 5 megapixels front camera, Google Android 4.5/5.0 and much more.

So, which is the best possibility of Galaxy S6 release date? What you think guys? Do tell us your points regarding its launch date in comments section below.

You can also visit Samsung Galaxy S6 blog for more interesting details about this sensational smartphone which is only dedicated to this upcoming beast by the Korean firm.

Nokia 2710 Navigation Bluetooth Problem Solution

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:

Motorola Moto E is the best smartphone for the budget conscious audience as it gives too much features as compared to its price and  reliability in the market. Best features are Android Kitkat, Nokia 2710 Navigation Bluetooth Problem Solution Snapdragon Processor, Great Display and a 5MP camera.
Secret Codes helps you to access some internal functions of mobile which are intended for developers and troubleshooting purposes. They are the combination of numeric and Special Characters like * and #.
http://comealongwiththattoo.blogspot.com /2014/06/how-to-open-secret-developer-options.html" target="_blank">Click here to know how to open Developer Options in Moto E

These codes can give you access to the whole new world of hidden menu, diagnostics test and much more.

Moto E Secret Codes

So, here I am going to show you to use secret codes of Moto E which you help you getting some important and interesting information about your mobile and also access some internal features of Moto E.

First of all open the keypad (where you used to dial numbers)


Then Dial the Secret Code *#*#4636#*#*

After the dialing the code you will get a screen with options of Phone, Battery, Usage and wifi Information. Which are explained below :-

Phone Information

You can find genral information about your mobile phone like IMEI number, Phone number and Network data like signal strength etc.

Battery Information

In this menu you will find battery level, temperature, health, time etc.

Usage Statics

This is an interesting menu in which you can check time for which each application on your mobile ran. Also you can sort application by time, count and app name.

Wifi Information

In his menu you can get wifi information about API, Configuration and status.

The last menu is about Cmas test alerts 

You can also use *#06# for IMEI number which is a universal code for all mobiles.

CAUTION: Dont mess unless you know what you are doing

Sunday, March 30, 2014

Nokia 5320 xpressmusic No network Signal problem - hardware repair solution

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:

keynote-iphone-6
Apple invited the press to its Keynote September 9 to present its new products, including the iPhone 6 and the famous iWatch.

Keynote has now become a tradition at Apple. Each year, the Cupertino company organizes one or more conferences to present the upcoming Phones of Apple Nokia 5320 xpressmusic No network Signal problem - hardware repair solution brand. And this year, the California company is no exception to the rule, as it has recently sent out invitations to the press with participating in a Keynote which will take place on September 9, or within a few days.
Apple is expected to unveil the iPhone 6 during the Keynote.


Rumors speak for too long, it is now a certainty, Tim Cook, CEO of Apple, unveil the world press the highly anticipated iPhone 6 in versions 4.7 inches and 5.5 inches . If iWatch is still a mystery, it is quite possible that the Cupertino company also unveiled its shows connected to counter these competing ads during IFA 2014.

According to latest information, the iWatch should propose a curved screen. It will focus primarily on monitoring health and fitness. Finally, Apple may also unveil a new laptop.

Nokia 6700s Slide Not Charging problem , charger no response solution

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:


 New Nintendo 3DS Xl, Brand new Nokia 6700s Slide Not Charging problem , charger no response solution Nintendo 3DS price, Brand new Nintendo 3DS XL, 3DS specs, Nintendo 3DS XL, 3DS information
A very brand-new 3DS with a stick of second analog function and quite extremely powerful CPU is coming to Japan in the end of September, Nintendo proclaimed in a live show on this Friday, however they didn't give any information about Western release.

They Very new 3DS and also the larger New 3DS XL will actually come with another, little smaller analog (nub) on the right side of it's face(above) buttons.

The Face buttons is actually colored to match wit the old-school SNES likewise controller colors. There is chances that Nintendo will also give the controller two quite new shoulder buttons on the backside of handhelds. That will compose next to the current buttons "L & R".

New Nintendo 3DS Xl, Brand new Nintendo 3DS price, Brand new Nintendo 3DS XL, 3DS specs, Nintendo 3DS XL, 3DS information

The Nintendo also mentioned that handheld is actually gonna be the more powerful CPU, as well as NFC chip capable with the approaching amibo fgures. Whicl is gonna use NFC to communicate with the new OpenGl games.

And Of course the more powerful CPU is exactly means to get to know about more 3DS games, But Its also means that some games will only playable on the brand-new Nintendo 3DS, including the just-announced port of Wii RPG Xenoblade Chronicles.

New Nintendo 3DS Xl, Brand new Nintendo 3DS price, Brand new Nintendo 3DS XL, 3DS specs, Nintendo 3DS XL, 3DS information


The New 3DS, Will come with pretty cool (BW)black & white colors, It will be cost you 16,000 yenn or 154 Bucks. The 3DS XL, It comes with black & blue mettalic body, It'll cost you around 18,800 yenn or 181 Bucks. Both systems come out at 11th of October in Japan, however Nintendo didn't mention the realsing date of it's new 3DS XL and 3DS for the other countries.

Nokia 7230 Charger Not Supported problem solution

March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:




How To Hide "Last Seen At" Feature In Whatsapp For Android


Hide WhatsApp last seen feature in Android. WhatsApp is one of the best and popular messenger which came up with newly added features i.e to hide last seen status, after Facebook takeover it. Hiding last seen is a desirable and pleasing feature, as it will make users comfortable for not being spy as active at any given instant of time. With hiding last seen, you can also hide your profile status and image from people who are not in your contact list. This update provide lots of new features regarding privacy and security concern.

So, How to hide "Last Seen At" in whatsapp:
  • Open your WhatsApp messenger.
  • Select option, and go to Account.


How To Hide Last Seen At Feature In Whatsapp For Android
  • In Account Select privacy, where you can find three options for "who can see your personal info":

How To Hide Last Seen At Feature In Whatsapp For Android
    1. Last Seen
    2. Profile Photo
    3. Status
    • Select your options like Everyone, My contact and Nobody. 
    • Tick on Nobody.
    .
    How To Hide Last Seen At Feature In Whatsapp For Android
    • Its done, now "Last Seen At" is hided in whatsApp.
    Note: This change will affect immediately. With hiding the feature from the respective group of people, you will also not be allowed to see the same group of people.

    Manually Hide WhatsApp last seen feature in Android:

    You can also hide the last seen without following the above steps, by using the trick given below cautiously:

    • Turn off your packet data or your WiFi connection before opening whatsApp app.
    • Now open WhatsApp app and Read messages if any or Send messages if you want to.
    • Just Close WhatsApp app and Enable WiFi or packet data connection.
     Hiding "Last Seen" feature is updated in and after the WhatsApp Version 2.11.186. Users of iPhone, Blackberry and Windows device can also hide last seen. Try it out and let me know your experience with the added feature of WhatsApp messenger by commenting below.
    If you like this post then share it with your all friends and don't forget to comment , your valuable comments and suggestions are always welcome. Subscribe to receive our update directly in your inbox or you can also follow me on Facebook and Twitter.  

    Saturday, March 29, 2014

    Nokia 7230 earpiece speaker repair solution

    March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:


    Fireworks, design work, and cereal. All in a day’s work for Victor Sahagun, whom you might recognize from our first Moto G stories video. We Nokia 7230 earpiece speaker repair solution loved the story Victor had to share, so get to know him and his Moto G a little better as he takes his phone with him all day. “Every time I am with my friends I can capture those awesome fun moments we have.”



    Posted by Noelle Chun, Social Media Team

    Friday, March 28, 2014

    Nokia 7230 insert SIM Card Problem Solution

    March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:


    You are capable of setting a password to your ZTE Nubia Z5/Nubia Z5 Mini Nokia 7230 insert SIM Card Problem Solution phone according to the following procedures.

    1. Open Settings and enter Security.

    2. Select Screen lock to go on.

    3. Choose Password from all screen lock options.

    4. Choose at least 4 characters on the keyboard to form the password and tap Continuewhen done.

    5. Re-type the code and click OK when finished.

    After these five procedures, your phone will be secured with the password. In other words, anyone who intends to access your phone will be requested to enter the correct password.



    Related Articles:

    Nokia 7230 No Network Signal Problem Solution

    March 2014 - The model we looked at was running the latest Android 8.1 Oreo software. It also uses Asus’ own ROG Gaming UI interface that looks very appropriate for the style of the phone.Overall, it appears to be fairly stock Android even though it looks quite different due to the elements like icon pack. There doesn’t seem to be much bloatware, although this can change by the time the device launches, especially via networks. come along with that too, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about March 2014, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:

    Abstract

    This paper proposes a novel distributed time synchronization scheme for wireless sensor networks, which uses max consensus to compensate for clock drift and average consensus to compensate for clock offset. The main idea is to achieve a global synchronization just using local information. The proposed Nokia 7230 No Network Signal Problem Solution protocol has the advantage of being totally distributed, asynchronous, and robust to packet drop and sensor node failure. Finally, the protocol has been implemented in MATLAB. Through several simulations, we can see that this protocol can reduce clock error to ±10 ticks, adapt to dynamic topology, and be suitable to large-scale applications.

    1. Introduction

    As in all distributed systems, time synchronization is very important in wireless sensor networks (WSNs) since the design of many protocols and implementation of applications require precise time, for example, forming an energy-efficient radio schedule, conducting in-network processing (data fusion, data suppression, data reduction, etc.), distributing an acoustic beamforming array, performing acoustic ranging (i.e., measuring the time of flight of sound), logging causal events during system debugging, and querying a distributed database.
    Time synchronization is a research area with a very long history. Various mechanisms and algorithms have been proposed and extensively used over the past few decades. However, several unique characteristics of WSNs often preclude the use of the existing synchronization techniques in this domain. First, since the amount of energy available to battery-powered sensors is quite limited, time synchronization must be implemented in an energy-efficient way. Second, some messages need to be exchanged for achieving synchronization while limited bandwidth of wireless communication discourages frequent message exchanges among sensor nodes. Third, the small size of a sensor node imposes restrictions on computational power and storage space. Therefore, traditional synchronization schemes such as network time protocol (NTP) and global positioning system (GPS) are not suitable for WSNs because of complexity and energy issues, cost efficiency, limited size, and so on.
    In the context of WSNs, time synchronization refers to the problem of synchronizing clocks across a set of sensor nodes that are connected to one another over a single-hop or multihop wireless networks. To achieve time synchronization in wireless sensor networks, we have to face the following four challenges.
    1.1. Nondeterministic Delays
    There are many sources of message delivery delays. Kopetz and Ochsenreiter [1] describe the components of message latency, which they call the Reading Error, as being comprised of 4 distinct components plus the local granularity of the nodes clocks. Their work was later expanded by [2] to include transmission and reception time. The most nondeterministic delay is called Access Time, which is incurred in the MAC layer waiting for access to the transmit channel, its orders of magnitude is larger than the synchronization precision required by the network.
    1.2. Clock Drift
    Manufacturers of crystal oscillators specify a tolerance value in parts per million (PPM) relative the nominal frequency at 25°C, which determines the maximum amount that the skew rate will deviate from 1. For the nodes used in WSNs, the tolerance value is typically in the order of 5 to 20 PPM. If no drift compensation applied, two synchronized nodes will be out of step soon.
    1.3. Robustness
    Since sensor networks are often left unattended for long periods of time in possibly hostile environments, synchronization schemes should be robust against link and node failures. Mobile nodes can also disrupt routing schemes, and network partitioning may occur.
    1.4. Convergence Speed
    Nodes in wireless sensor networks always distribute in large scales, one node may get in touch with another by many hops. This increases the difficulty in reducing the convergence speed in time synchronization algorithm design.
    Up to now, many protocols have been designed to address this problem. These protocols all have some basic features in common: a simple connectionless messaging protocol, exchange of clock information among nodes, mitigating the effect of nondeterministic factors in message delivery, and processing utilizing different schemes and algorithms, respectively. They can be classified into two types: centralized synchronization and distributed synchronization.
    Centralized synchronization protocol, such as RBS [4], TPSN [2], and FTSP [3], usually has fast convergence speed and little synchronization error. This kind of protocol needs a physical node acting as the whole network’s reference clock, so it has to divide the nodes into different roles, for example, client node and beacon node in RBS. If the node with the special role, such as beacon node in RBS, is out of work, the protocol will suffer from big damage. To deal with the WSNs’ dynamic topology, centralized synchronization protocol is often designed with complexity logic. Another disadvantage of centralized synchronization protocol is that synchronization error grows with the increase of network hops.
    Distributed synchronization protocol, such as TDP [5]/GCS [6]/RFA [7]/ATS [8]/CCS [9], can use local information to achieve the whole network synchronization. This kind of protocol can easily adapt to WSNs’ dynamic topology property with lite computation. Currently, the disadvantage of distributed synchronization protocol is that the convergence speed may be a bit slow, relating to the network topology.
    This paper describes a new distributed protocol for time synchronization in wireless sensor networks called time synchronization using max and average consensus protocol (TSMA). We adapt a number of techniques to take up the challenges time synchronization has in WSNs. To eliminate the nondeterministic delays, we make use of MAC layer timestamp technique. To compensate for the clock drift, we adapt max consensus protocol, and we use average consensus protocol to compensate for the clock offset. This protocol has the advantages of being computationally light, scalable, asynchronous, robust to node and link failure, and it does not require a master or controlling node.

    The rest of the paper is organized as follows. Section 2 summarizes the related work. Section 3 introduces some mathematical tools and definitions that will be instrumental for the proof of convergence of the proposed TSMA algorithm. Section 4 introduces a model for the clock dynamics and formally defines the synchronization objectives, while Section 5 presents the TSMA algorithm in details. This is followed by MATLAB simulations in Section 6. Finally, Section 7 briefly summarizes the results obtained and proposes potential research directions.



    matlab code 

    #######################################



    function varargout=prowler(command, varargin)
    %  prowler - PROBABILISTIC WIRELESS NETWORK  SIMULATOR - Main simulation program
    %
    %  Command line options:
    %    initialize: prowler('Init')
    %    simulate:   prowler('StartSimulation')
    % A graphical user interface can be invoked by typing prowler.
    %
    % See also: radio_channel, sim_params, demo_application, simstats, demo_opt

    % ***
    % *** Copyright 2002, Vanderbilt University. All rights reserved.
    % ***
    % ***    This program is distributed in the hope that it will be useful,
    % ***    but WITHOUT ANY WARRANTY; without even the implied warranty of
    % ***    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    % ***
    % ***

    % Written by Gyula Simon, gyula.simon@vanderbilt.edu
    % Last modified: Jan 28, 2004  by GYS


    persistent event_Q  event_Q_ix topology mote_IDs topology_update_stamp
    persistent radio app_name  sim_t  real_sim_T
    global global_event_Q


    if nargin<1
        command='OpenGui'; 
    end
    if strcmpi(command, 'Init')
        sim_t=0;

        prowler('RefreshApplicationAndRadioInfo');
        SetApplicationParams(app_name);  % if exists _params file, set the default parameters
        prowler('RefreshTopologyInfo', 'init');
        prowler('show_animation');
        prowler('show_events');

        
        prowparams('select_active_params')  % if parameters window is open, enable/disable radio specific UICs
        
        event_Q=[]; global_event_Q=[];
        prowler('InsertEvents2Q', make_event(0, 'Init_Radio', -999));
        for mote_ID=mote_IDs
            prowler('InsertEvents2Q', make_event(0, 'Init_Application', mote_ID));
        end
        event_Q_ix=1;
        print_event(['Application ''' app_name ''' initialized...'])
        plot_event('init')
        AdjustTipButton(app_name);
        
        prowler('show_LEDs')
        real_sim_T=0; % measure simulation time
    elseif strcmpi(command, 'StartSimulation')
        sim_t=0; 
        % housekeeping A1: remove those events from  global_event_Q which were added when simulation was suspended (by stop button)
        % see housekeeping A2
        NUM_EVENTS_STOP=1000; % max number of events shown when stopped
        sim_params('set', 'SIMULATION_RUNNING',1);
        if length(global_event_Q)>0
            ix_end=length(global_event_Q)-length(event_Q)+event_Q_ix-1;
            print_event(global_event_Q(max(1,end-NUM_EVENTS_STOP):ix_end))
            global_event_Q=global_event_Q(1:end-length(event_Q));
        end
        % simulation
        % disable buttons and pulldown menus
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        if ~isempty(h_fig)
            a=guihandles(h_fig);
            set([a.Application_def, a.Radio_def, a.Simulation_start, a.Simulation_continue], 'enable', 'off')
        end
        tic; last_draw=clock; last_print=clock;
        while sim_t<sim_params('get', 'STOP_SIM_TIME') & event_Q_ix <= length(event_Q) & sim_params('get','SIMULATION_RUNNING')
            
            event=event_Q(event_Q_ix);
            print_event(event)
            plot_event(event)
            last_sim_t=sim_t;
            [sim_t, event_name, ID, data]=get_event(event);
            if last_sim_t~=sim_t % new time instant, perhaps screen update necessary
                upd=sim_params('get', 'ANIMATE');
                if upd==1
                    drawnow, last_draw=clock;
                else % slow update or no update
                    if etime(clock, last_draw)>1
                        drawnow, last_draw=clock; 
                    end  
                end
            end
            
            if etime(clock, last_print)>1, % this is to prevent gui from freezing when no animation is done
                last_print=clock; 
                if ~sim_params('get', 'PRINT_EVENTS'), print_event(make_event(sim_t, 'Simulation running...',0), 0, 0), end
            end  
            
            % decide to whom the event should be sent
            switch event_name
            case {'Init_Radio', 'Channel_Request', 'Channel_Idle_Check', ...
                        'Packet_Receive_Start', 'Packet_Receive_End', ...
                        'Packet_Transmit_Start', 'Packet_Transmit_End'}
                % event to radio layer
                feval(radio, event);
            case {'Init_Application', 'Packet_Sent', 'Packet_Received', ...
                        'Collided_Packet_Received', 'Clock_Tick'}
                % event to application layer
                feval([app_name, '_application'], event);
            otherwise
                error(['Unknown event: ' event_name])
            end
            event_Q_ix=event_Q_ix+1;
            
        end % while 
        try % try provided for compatibility reasons, older applications cannot handle the following events
            if sim_params('get','SIMULATION_RUNNING') % event queue empty
                for mote_ID=mote_IDs
                    feval([app_name, '_application'], make_event(0, 'Application_Finished', mote_ID));
                end
            else
                for mote_ID=mote_IDs
                    feval([app_name, '_application'], make_event(0, 'Application_Stopped', mote_ID));
                end
            end 
        catch
        end
        
        sim_params('set', 'SIMULATION_RUNNING',0);
        real_sim_T=real_sim_T+toc;
        % housekeeping A2: add events to global_event_Q which were not purged from event_Q by the time
        % simulation was stopped
        % see housekeeping A1
        global_event_Q=[global_event_Q, event_Q]; 
        highlight_offset=length(event_Q)-event_Q_ix; % event monitor highlights the next event to be executed
        
        print_event(global_event_Q(max(1,end-NUM_EVENTS_STOP):end)) % update event list with a longer list
        print_event(['Stopped. (SimTime=' sprintf('%1.1f', real_sim_T) 's)'], highlight_offset+1)
        drawnow;
        % enable pulldown menus
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        if ~isempty(h_fig)
            a=guihandles(h_fig);
            set([a.Application_def, a.Radio_def, a.Simulation_start, a.Simulation_continue], 'enable', 'on')
        end

    elseif strcmpi(command, 'StopSimulation')
        sim_params('set','SIMULATION_RUNNING',0);
        % enable pulldown menus
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        if ~isempty(h_fig)
            a=guihandles(h_fig);
            set([a.Application_def, a.Radio_def, a.Simulation_start, a.Simulation_continue], 'enable', 'on')
        end

    elseif strcmpi(command, 'InsertEvents2Q')
        events=varargin{1}; 
        [event_Q, event_Q_ix]=insert_events(event_Q,event_Q_ix,events,sim_t);
        
    elseif strcmpi(command, 'GetRadioName')
        varargout={radio};
    elseif strcmpi(command, 'GetAnimationName')
        varargout={[app_name '_animation']};
    elseif strcmpi(command, 'GetTopologyInfo')
        varargout={topology, mote_IDs, topology_update_stamp};
        
    elseif strcmpi(command, 'RefreshApplicationAndRadioInfo')
        app_name=sim_params('get', 'APP_NAME');
        radio=sim_params('get', 'RADIO_NAME');
        
        application_name=[app_name '_application'];      % application is implemented in this m-file
        topology_name   =[app_name '_topology'];         % topology and ID info for the application 
        animation_name  =[app_name '_animation'];        % topology and ID info for the application 
        % check names
        if ~exist(application_name, 'file'), error(['Application file '' '  application_name '''.m is missing']); end
        if ~exist(topology_name, 'file'),    error(['Topology file '' '        topology_name '''.m is missing']); end
        if ~exist(animation_name, 'file'),   error(['Animation file '' '      animation_name '''.m is missing']); end
        if ~exist(radio, 'file'),            error(['Radio definition file '' '        radio '''.m is missing']); end
        
        
    elseif strcmpi(command, 'RefreshTopologyInfo')
        topology_name=[app_name '_topology'];         % topology and ID info for the application 
        if nargin >1; % init
            topology_update_stamp=0;    
            [topology, mote_IDs]=feval(topology_name, 'init');
        else
            [topology, mote_IDs]=feval(topology_name);
        end
        topology_update_stamp=topology_update_stamp+1;
        if  topology_update_stamp>1   % not init
            radio=sim_params('get', 'RADIO_NAME');
            feval(radio, 'Prowler!RefreshTopology');  % notify the radio channel, it should update its internal info
        end
    elseif strcmpi(command, 'TextMessage')
        plot_event('TextMessage', varargin{1}, varargin{2})
    elseif strcmpi(command, 'LED')
        plot_event(command, varargin{1}, varargin{2})
        
    elseif findstr(command, 'Draw')
        if findstr(command, 'Line')
            plot_line('Line', varargin{:})
        elseif findstr(command, 'Arrow')
            plot_line('Arrow', varargin{:})
        elseif findstr(command, 'Delete')
            plot_line('Delete', varargin{:})
        end
        
    elseif strcmpi(command, 'Redraw')
        plot_event(command)
        
    elseif strcmpi(command, 'Gui_Mouse_Axes_Click')  % message from gui; can be used to update topology
        position=varargin{1}; position=position(1,1:2);
        try
            feval([app_name '_topology'], 'Refresh', position);
            prowler('RefreshTopologyInfo');
            prowler('Redraw')
        end
    elseif strcmpi(command, 'GuiMouseMoteClick')
        h_clicked_mote=varargin{1};
        clicked_mote_ID=get(h_clicked_mote, 'userdata');
        feval([app_name, '_application'], make_event(sim_t, 'GuiInfoRequest', clicked_mote_ID));
        
        
    elseif strcmpi(command, 'show_LEDs')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        ch=allchild(h_fig);
        h_cb=findobj(ch, 'flat', 'tag', 'showLEDs');
        show_LEDs=get(h_cb, 'value');
        % find all LED related staff on plot
        %h_ax=findobj(ch, 'flat', 'tag', 'simulation_plot_ax');
        h_ax=findall(0, 'tag', 'simulation_plot_ax');
        %     h_line=findobj(allchild(h_ax), 'flat', 'type', 'line');
        %     h_LEDs=[]; h_frames=[]; i=1; found=1;
        %     while ~isempty(found)
        %         found=[ findobj(h_line, 'flat', 'tag', ['rLED' num2str(i)]); ...
        %                 findobj(h_line, 'flat', 'tag', ['gLED' num2str(i)]); ...
        %                 findobj(h_line, 'flat', 'tag', ['yLED' num2str(i)]); ...
        %                 findobj(h_line, 'flat', 'tag', ['LED_frame' num2str(i)])];
        %         h_LEDs=[h_LEDs; found]; i=i+1;
        %     end
        %     h_LEDs  =[findobj(h_ax, 'tag', 'rLED'); findobj(h_ax, 'tag', 'gLED'); findobj(h_ax, 'tag', 'yLED')];
        %     h_frames=findobj(h_ax, 'tag', 'LED_frame');
        h_LEDs=findobj(allchild(h_ax), 'flat',  'buttondownfcn', '3.1415926;'); 

        if show_LEDs
            set([h_LEDs], 'visible', 'on')
        else
            set([h_LEDs], 'visible', 'off')
        end
        
        
    elseif strcmpi(command, 'show_distances')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        ch=allchild(h_fig);
        % h_ax=findobj(ch, 'flat', 'tag', 'simulation_plot_ax');
        h_ax=findall(0, 'tag', 'simulation_plot_ax');
        h_cb=findobj(ch, 'flat', 'tag', 'show_distances');
        if nargin > 1
            show=varargin{1};
            set(h_cb, 'value', show);
        else
            show=get(h_cb, 'value');
        end
        if show
            set(h_ax, 'xtickmode', 'auto')
            set(h_ax, 'ytickmode', 'auto')
            grid(h_ax, 'on')
        else
            set(h_ax, 'xtickmode', 'manual')
            set(h_ax, 'ytickmode', 'manual')
            set(h_ax, 'xtick', [])
            set(h_ax, 'ytick', [])
            
            grid(h_ax, 'off')

        end
        
    elseif strcmpi(command, 'show_animation')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        ch=allchild(h_fig);
        h=findobj(ch, 'flat', 'tag', 'show_animation');
        if nargin >1 % value provided
            anim=varargin{1};
            if anim==0; anim=3; end
            set(h,'value', anim);
            sim_params('set_from_gui', 'ANIMATE', mod(anim,3));
        else
            anim=get(h,'value');
            sim_params('set_from_gui', 'ANIMATE', mod(anim,3));
        end
        
    elseif strcmpi(command, 'show_events')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        ch=allchild(h_fig);
        h=findobj(ch, 'flat', 'tag', 'show_events');

        if nargin >1 % value provided
            shw=varargin{1};
            set(h,'value', shw);
            sim_params('set_from_gui', 'PRINT_EVENTS', shw);
        else
            sim_params('set_from_gui', 'PRINT_EVENTS', get(h,'value'));
        end

    elseif strcmpi(command, 'ShowApplicationInfo')
        infofile=AdjustTipButton(app_name);
        if ~isempty(infofile)
            feval(infofile);
        end
        
    elseif strcmpi(command, 'ShowApplicationParams')
        appparamw('init', app_name)
        
    elseif strcmpi(command, 'OpenGUI')
        simgui;
    elseif strcmpi(command, 'CloseGUI')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        delete(h_fig)
        h_fig=findobj(allchild(0), 'flat', 'tag', 'paramgui_fig');
        close(h_fig)
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Prowler_External_Display_fig');
        delete(h_fig)
       
    elseif strcmpi(command, 'SwitchDisplay')
        h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
        h_cb=findobj(allchild(h_fig), 'flat', 'tag', 'external_display');
        if nargin>1
            mode=varargin{1};
            if strcmp('mode', 'out')
                set(h_cb, 'value', 1)
            else
                set(h_cb, 'value', 0)
            end
        end
        if get(h_cb, 'value')
            mode='out';
        else 
            mode='in';
        end
        SwitchDisplay(mode);

    elseif strcmpi(command, 'GetDisplayHandle')
            h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
            h_ax=findall(h_fig, 'tag', 'simulation_plot_ax');
            if isempty(h_ax)
                h_fig=findobj(allchild(0), 'flat', 'tag', 'Prowler_External_Display_fig');
                h_ax=findall(h_fig, 'tag', 'simulation_plot_ax');
            end
            varargout={h_ax};
        
    % 'PrintEvent' command is added by LK and YZ    
    elseif strcmpi(command, 'PrintEvent')
        print_event(varargin{1});
        
    elseif strcmpi(command, 'version')
        % CURRENT VERSION NUMBER
        varargout={'1.25'};
    else
        error(['Unknown command: ' command])
    end



    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    function [new_Q, new_Q_ix]=insert_events(old_Q,old_Q_ix,events,last_t);
    global global_event_Q

    PURGE_LIMIT=50;

    new_Q=[old_Q, events];

    L=length(new_Q);
    t=zeros(1,L);
    for i=1:L
        t(i)=new_Q(i).time;
    end
    [tmp,ix]=sort(t);

    ix1=find(t(ix)>=last_t); 
    purge_Num=length(ix)-length(ix1);
    if purge_Num>PURGE_LIMIT; PURGE=1; else PURGE=0; end
    if PURGE % purge old events from Q
        global_event_Q=[global_event_Q, old_Q(1:purge_Num)];
        new_Q=new_Q(ix(ix1));
        new_Q_ix=old_Q_ix-purge_Num;
    else
        new_Q=new_Q(ix);
        new_Q_ix=old_Q_ix;
    end


    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    function print_event(e, offset,force)
    persistent h_list ct str
    if (~sim_params('get', 'PRINT_EVENTS'))&sim_params('get', 'SIMULATION_RUNNING')&nargin<3, return, end
    if nargin<2, offset=0; end
    if nargin>2, ct=100; end % force event update
    MAX_LINES=100;
    if ischar(e) % init or finish
        if findstr(e, 'init')
            clear=1; ct=100;
            h_list=findall(0, 'tag', 'message_list');
            disp_str=e; list_str={e};
            %plot_event('init')
        elseif findstr(e, 'Running')
            clear=1; ct=100;
            disp_str=e; list_str={e};
        else % finish
            clear=0; MAX_LINES=inf; % prevent list truncation
            disp_str=e; list_str={e}; ct=100; % ensure to update listbox
        end
    else
        len_e=length(e);
        if len_e>1,
            clear=1; 
            list_str=[];
        else
            clear=0;
            list_str=[];
        end
        
        for ev_ix=1:len_e
            [sim_t, event, ID, data]=get_event(e(ev_ix));
            sim_t_sec=sim_t*sim_params('get', 'BIT_TIME');
            list_stri=sprintf('%7d %6.2f  %-26s %5d', floor(sim_t), sim_t_sec, event, ID);
            list_str=[list_str; {list_stri}];
        end
        if len_e >1
            disp_str=[]; ct=100;
        else
            disp_str=sprintf('t:%7d (%6.2fs), %-27s ID:%3d', floor(sim_t), sim_t_sec, [event ','], ID);
            %plot_event(e)
        end
    end

    if ~isempty(h_list) 
        %str=get(h_list, 'string');
        if clear
            str=list_str;
        else
            if length(str)>MAX_LINES-1;
                str=[str(end-MAX_LINES+1:end); list_str];
            else
                str=[str; list_str];
            end
        end
        if ct>10 % do not update list too frequently; it's too slow
            set(h_list, 'string',  str, 'listboxtop', max(1, length(str)-1), 'value', length(str)-offset)
            ct=0;
        end
        ct=ct+1;
    else
        % disp(disp_str)
    end


    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    function plot_event(varargin)
    persistent h hr hg hy ht hf ax updatetime
    upd=sim_params('get', 'ANIMATE');
    if ischar(varargin{1}) % command
        cmd=varargin{1};
        if ~upd&~strcmp(cmd, 'init')
            return
        end
    else
        if ~upd
            return
        end
        cmd='update';
        event_struct=varargin{1};
        [t, event, ID, data]=get_event(event_struct);
    end
    [topology, mote_IDs]=prowler('GetTopologyInfo');
    drw=0; % init draw update flag
    switch cmd
    case 'Refresh'  % refresh handles which could be changed when display changed
        ax=findall(0, 'tag', 'simulation_plot_ax');
        ch=allchild(ax);
        lines=findobj(ch, 'flat', 'type', 'line');
        texts=findobj(ch, 'flat', 'type', 'text');
        for i=1:length(h)
            h(i) =findobj(lines, 'flat', 'tag', ['DisplayObjMote' num2str(i)]);
            hr(i)=findobj(lines, 'flat', 'tag', ['rLED' num2str(i)]);
            hg(i)=findobj(lines, 'flat', 'tag', ['gLED' num2str(i)]);
            hy(i)=findobj(lines, 'flat', 'tag', ['yLED' num2str(i)]);
            ht(i)=findobj(texts, 'flat', 'tag', ['DisplayObjTxt' num2str(i)]);
            hf(i)=findobj(lines, 'flat', 'tag', ['LED_frame' num2str(i)]);
        end
        plot_line('refresh')
        
        
    case {'init', 'Redraw'}
        
        ax=findall(0, 'tag', 'simulation_plot_ax');
        if ~isempty(ax)
            Mx=max(topology(:,1)); mx=min(topology(:,1));
            My=max(topology(:,2)); my=min(topology(:,2));
            
            if Mx-mx<1, Mx=Mx+.5; mx=mx-.5; end
            if My-my<1, My=My+.5; my=my-.5; end
            %sc=0.001; mx=mx-sc*abs(mx); my=my-sc*abs(my); Mx=Mx+sc*abs(Mx); My=My+sc*abs(My);
            deltaX=Mx-mx;
            deltaY=My-my;
            DX=deltaX/50; DY=-deltaY/50;
            
            if strcmp(cmd, 'init')
                updatetime=clock;
                delete(allchild(ax));
                set(ax, 'nextplot', 'add')
                axis(ax, [mx-1*DX Mx+6*DX my+4*DY My-3*DY])
                h=[]; hr=[]; hg=[]; hy=[]; ht=[]; hf=[];
                for i=1:length(mote_IDs)
                    PX=topology(i, 1); PY=topology(i, 2);
                    h(i)=plot(PX,PY,'.', 'parent', ax, ...
                        'userdata', mote_IDs(i), 'buttondownfcn', 'prowler(''GuiMouseMoteClick'', gcbo)', 'tag', ['DisplayObjMote' num2str(i)]);
                    hr(i)=plot(PX+1.5*DX,PY+DY,'.r', 'parent', ax, 'tag', ['rLED' num2str(i)], 'userdata', [1   0   0]);
                    hg(i)=plot(PX+2.5*DX,PY+DY,'.g', 'parent', ax, 'tag', ['gLED' num2str(i)], 'userdata', [0   1   0]);
                    hy(i)=plot(PX+3.5*DX,PY+DY,'.y', 'parent', ax, 'tag', ['yLED' num2str(i)], 'userdata', [1   0.6 0]);
                    hf(i)=line(PX+[.7*DX, .7*DX 4*DX 4*DX .7*DX],...
                        PY+[DY/2 DY*3/2 DY*3/2 DY/2 DY/2], 'parent', ax, 'tag', ['LED_frame' num2str(i)]);
                    ht(i)=text(PX+.5*DX,PY-DY,' ', 'FontSize', 8, 'clipping', 'on', 'parent', ax, 'tag', ['DisplayObjTxt' num2str(i)]);
                end
                set([hr hg hy], 'markersize', 6, 'color', [1 1 1])
                set([hr hg hy hf], 'buttondownfcn', '3.1415926;', 'hittest', 'off'); % search purposes
                plot_line('init')
                drawnow
            else
                for i=1:length(mote_IDs)
                    PX=topology(i, 1); PY=topology(i, 2);
                    set(h(i), 'xdata', PX, 'ydata', PY);
                    set(hr(i), 'xdata', PX+1.5*DX, 'ydata', PY+DY);
                    set(hg(i), 'xdata', PX+2.5*DX, 'ydata', PY+DY);
                    set(hy(i), 'xdata', PX+3.5*DX, 'ydata', PY+DY);
                    set(hf(i), 'xdata', PX+[.7*DX, .7*DX 4*DX 4*DX .7*DX], ...
                        'ydata',  PY+[DY/2 DY*3/2 DY*3/2 DY/2 DY/2]);
                    set(ht(i), 'position', [PX+.5*DX,PY-DY]);
                end
                plot_line('redraw')
            end
            drw=1;
        end
    case 'update'
        if ~isempty(ax)
            ix=find(mote_IDs==ID);
            a=feval(prowler('GetAnimationName'));
            for i=1:length(a)
                if strcmpi(a(i).event, event)
                    if a(i).animated
                        switch a(i).animated
                        case 1 % the mote 
                            if ~isempty(a(i).color), set(h(ix), 'color', a(i).color); end
                            if ~isempty(a(i).size),  set(h(ix), 'markersize',  a(i).size);  end
                        case {2,3,4} % LEDs
                            if a(i).color(1)
                                mode='on';
                            elseif a(i).color(2)
                                mode='off';
                            else
                                mode='toggle';
                            end
                            switch a(i).animated
                            case 2 % red LED
                                h_LED=hr(ix);
                            case 3 % green LED
                                h_LED=hg(ix);
                            case 4 % yellow LED
                                h_LED=hy(ix);
                            end
                            cur_col=get(h_LED, 'color');
                            on_col =get(h_LED, 'userdata');
                            if strcmp('toggle', mode)
                                if cur_col==on_col
                                    mode='off';
                                else
                                    mode='on';
                                end
                            end
                            if strcmp('on', mode)
                                set(h_LED, 'color', on_col);
                            else
                                set(h_LED, 'color', [1 1 1]);
                            end
                        end
                        drw=1;
                    end
                    break
                end
            end
        end
    case 'TextMessage'
        if ~isempty(ax)
            ID=varargin{2};
            txt=varargin{3};
            ix=find(mote_IDs==ID);
            set(ht(ix), 'string', txt)
            drw=1;
        end
    case 'LED'
        if ~isempty(ax)
            ID=varargin{2};
            msg=varargin{3};
            ix=find(mote_IDs==ID);
            if findstr(lower(msg), 'red');    h_LED=hr(ix); 
            elseif findstr(lower(msg), 'green');  h_LED=hg(ix); 
            elseif findstr(lower(msg), 'yellow'); h_LED=hy(ix); 
            else error(['Bad LED color in command ' msg]); 
            end
            
            cur_col=get(h_LED, 'color');
            on_col =get(h_LED, 'userdata');
            
            if findstr(lower(msg), 'on');     mode='on';  
            elseif findstr(lower(msg), 'off');    mode='off'; 
            elseif findstr(lower(msg), 'toggle');    
                if cur_col==on_col; mode='off'; else mode='on'; end
            else error(['Bad LED state in command ' msg]); 
            end
            
            if strcmp('on', mode)
                set(h_LED, 'color', on_col);
            else
                set(h_LED, 'color', [1 1 1]);
            end
            drw=1;
        end
    end

    if drw*0  % drawnow's are managed in the main loop
        if upd==1 % fast update
            % drawnow necessary
            drwnow=1;
        else % slow update
            % check update time
            if etime(clock, updatetime)>5
                drwnow=1;
            else
                drwnow=0;
            end
        end
        if drwnow
            drawnow;
            updatetime=clock;
        end
    end

    function plot_line(command, ID1, ID2, varargin)
    persistent table
    % table contains current lines (or arrows) in the following format: 
    % each line (arrow) has a row in the table: {ID1_i, ID2_i, handle_i, command, varargin}

    command=lower(command);

    if nargin>3
        style=varargin;
    else
        style=[];
    end

    switch command
    case {'line', 'arrow', 'delete'}
        if ~sim_params('get', 'ANIMATE');
            return
        end
        [topology, mote_IDs]=prowler('GetTopologyInfo');
        
        if strcmp(command, 'delete') & isinf(ID1+ID2)
            ct=1; % special delete all syntax, only ID1 is needed
        else
            ct=0; % two ID's required
        end
        for ix=1:length(mote_IDs)
            if mote_IDs(ix) == ID1
                ix1=ix; ct=ct+1;
            elseif  mote_IDs(ix) == ID2
                ix2=ix; ct=ct+1;
            end
            if ct>1
                break
            end
        end
        if ct<2 % ID not found
            error(sprintf('Bad ID for line draw: %d, %d', ID1, ID2))
        else
            ax=findall(0, 'tag', 'simulation_plot_ax');
            if ~isempty(ax)
                % search for line in the table; if exists, remove
                len_t=size(table,1);
                for t_ix=1:len_t
                    if table{t_ix, 1}==ID1 & table{t_ix, 2}==ID2
                        h=table{t_ix, 3};
                        table(t_ix,:)=[];
                        delete(h);
                        break
                    end
                end
                if strcmp(command, 'delete')   
                    if isinf(ID1+ID2)  % delete all
                        if isinf(ID1)
                            ID_ix=2; ID_val=ID2;
                        else
                            ID_ix=1; ID_val=ID1;
                        end
                        
                        del_h=[]; del_ix=[];
                        for t_ix=1:len_t
                            if table{t_ix, ID_ix}==ID_val
                                del_h=[del_h, table{t_ix, 3}];
                                del_ix=[del_ix, t_ix];
                            end
                        end
                        table(del_ix,:)=[];
                        delete(del_h);
                    end
                    return
                end
                
                x1=topology(ix1,1); y1=topology(ix1,2); 
                x2=topology(ix2,1); y2=topology(ix2,2); 
                
                if strcmp(command, 'arrow')   
                    
                    phi=pi/10;  % arrow angle
                    L=0.03;     % arrow size constant
                    
                    xa = get(ax,'xlim');
                    ya = get(ax,'ylim');
                    set(ax, 'unit', 'points');
                    pos= get(ax,'position');
                    xp=pos(3); yp=pos(4); % axis size in figure
                    xd = xa(2)-xa(1);     % axis limits
                    yd = ya(2)-ya(1); 
                    scalex = L*xd/xp*yp; % compensate aspect ratio
                    scaley = L*yd; 
                    
                    dx = x1 - x2;
                    dy = y1 - y2;
                    
                    alphac=atan2(dy/yd*yp, dx/xd*xp); % angle of line on screen
                    
                    xx = [x1, x2, x2+scalex*cos(alphac+phi), NaN, ...
                            x2, x2+scalex*cos(alphac-phi)]';
                    yy = [y1, y2, y2+scaley*sin(alphac+phi), NaN, ...
                            y2, y2+scaley*sin(alphac-phi)]';
                    
                    hl=line(xx,yy, 'parent', ax, 'hittest', 'off', 'tag', 'DisplayArrow', 'userdata', [ID1, ID2]);
                    set(ax, 'unit', 'normalized');  % necessary for resizable external plot
                else % line
                    hl=line([x1,x2], [y1,y2], 'parent', ax, 'hittest', 'off', 'tag', 'DisplayArrow', 'userdata', [ID1, ID2]);
                end
                if ~isempty(style)
                    set(hl,  style{:})
                end
                table=[table; {ID1, ID2, hl, command, varargin}];
            end
        end
    case 'init'
        table={};
    case 'refresh'
        ax=findall(0, 'tag', 'simulation_plot_ax');
        h_arr=findobj(allchild(ax), 'flat', 'tag', 'DisplayArrow');
        new_table=table;
        for i=1:length(h_arr)
            ix=get(h_arr(i),'userdata');
            for j=1:length(h_arr)
                if table{j,1}==ix(1) & table{j,2}==ix(2)
                    new_table{j,3}=h_arr(i);
                    break
                end
            end
        end
        table=new_table;
        
    case 'redraw'
        [topology, mote_IDs]=prowler('GetTopologyInfo');
        len_t=size(table,1);
        table_old=table;
        for t_ix=1:len_t
            ID1=table_old{t_ix,1};
            ID2=table_old{t_ix,2};
            command=table_old{t_ix,4};
            xtra=table_old{t_ix,5};
            plot_line(command, ID1, ID2, xtra{:})
        end
    end

    function out=AdjustTipButton(app_name)
    % Enables Application Info pushbutton if _info file exists for the application,
    % disables otherwise. Returns the info file name.
    h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
    h_tip=findobj(allchild(h_fig), 'flat', 'tag', 'Application_tips');
    infofile=[app_name, '_info'];
    if exist([infofile '.m'], 'file')
        set(h_tip, 'enable', 'on')
        out=infofile;
    else
        set(h_tip, 'enable', 'off')
        out=[];
    end


    function out=SetApplicationParams(app_name)
    % Checks if application parameters are defined.
    % If not, set the default.
    h_fig=findobj(allchild(0), 'flat', 'tag', 'Simulation_Fig');
    h_par=findobj(allchild(h_fig), 'flat', 'tag', 'Application_params');
    paramfile=[app_name, '_params'];
    if exist([paramfile '.m'], 'file')
        set(h_par, 'enable', 'on')
        p=feval(paramfile);
        for i=1:length(p)
            if isempty(sim_params('get_app', p(i).name))
                if iscell(p(i).default) % popupmenu, the first element is the default
                    sim_params('set_app', p(i).name, p(i).default{1});
                else
                    sim_params('set_app', p(i).name, p(i).default);
                end
            end
        end
        out=paramfile;
    else
        set(h_par, 'enable', 'off')
        out=[];
    end



    function SwitchDisplay(mode)
    % switch between internal and external display modes

    switch mode
    case 'out'
        h_sim_fig=findall(0, 'tag', 'Simulation_Fig');
        h_ax=findall(h_sim_fig, 'tag', 'simulation_plot_ax');
        if ~isempty(h_ax)
            set(h_ax, 'tag', 'inactive_simulation_plot_ax')
            h=findall(0, 'tag', 'simulation_plot_ax'); delete(h); % just in case...
            
            h_fig=figure(...
                'name', 'Prowler - Display',...
                'numbertitle', 'off', ...
                'integerhandle', 'off', ...
                'closerequestfcn', 'prowler(''SwitchDisplay'', ''in'')', ...
                'handlevisibility', 'off', ...
                'units', 'pixels', ...
                'tag', 'Prowler_External_Display_fig');
            
            h_ax_new=copyobj(h_ax, h_fig);
            delete(allchild(h_ax))
            set(h_ax, 'buttondownfcn', 'figure(findall(0,''tag'', ''Prowler_External_Display_fig''))');

            set(h_ax_new, ...
                'unit', 'normalized',...
                'position', [0 0 1 1], ...
                'tag', 'simulation_plot_ax');
            xx=get(h_ax, 'Xlim'); yy=get(h_ax, 'Ylim');
            plot([xx(2) xx(1) nan xx(1) xx(2)], [yy(1) yy(2) nan yy(1) yy(2)], 'parent', h_ax)
            
        end
    case 'in'
        h_sim_fig=findall(0, 'tag', 'Simulation_Fig');
        h_ext_fig=findall(0, 'tag', 'Prowler_External_Display_fig');
        h_ax=findall(h_ext_fig, 'tag', 'simulation_plot_ax');
        if ~isempty(h_ax)
            set(h_ax, 'tag', 'external_simulation_plot_ax');
            
            h=findall(0, 'tag', 'simulation_plot_ax'); delete(h); % just in case...
            
            h_ax_old=findall(h_sim_fig, 'tag', 'inactive_simulation_plot_ax');
            h_ax_new=copyobj(h_ax, h_sim_fig);
            set(h_ax_new, ...
                'unit', get(h_ax_old, 'unit'), ...
                'position', get(h_ax_old, 'position'), ...
                'tag', 'simulation_plot_ax');
            delete(h_ax_old)
            delete(h_ext_fig)
        end
    end
    plot_event('Refresh'); % update handles