Difference between revisions of "WCPS: Wireless Cyber-Physical Simulator"

From Cyber-Physical Systems Laboratory
Jump to navigationJump to search
Line 340: Line 340:
 
</source>
 
</source>
  
==Troubleshooting==
+
==Control Modeling in WCPS==
===Changes not showing up===
+
 
 +
==Integration of Wireless Networking and Simulink==
 +
 
 +
==Wireless Networking Traces==
 +
 
 +
==WSC Examples with WCPS==
 +
===Wireless Building Control===
 +
===Wireless Bridge Control===
 +
 
 +
 
 +
===Simulink Models===
 
MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. [[Manual:Purge|Purging the cache]] of affected pages should correct the situation. To perform a mass-purge of all caches at once, [http://www.freebsd.org/cgi/man.cgi?query=touch touch] the <tt>'''LocalSettings.php'''</tt> file or [http://www.mysql.org/doc/refman/5.0/en/truncate.html truncate] the <tt>'''objectcache'''</tt> table in your database (you may have to do both).
 
MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. [[Manual:Purge|Purging the cache]] of affected pages should correct the situation. To perform a mass-purge of all caches at once, [http://www.freebsd.org/cgi/man.cgi?query=touch touch] the <tt>'''LocalSettings.php'''</tt> file or [http://www.mysql.org/doc/refman/5.0/en/truncate.html truncate] the <tt>'''objectcache'''</tt> table in your database (you may have to do both).
  

Revision as of 15:19, 6 February 2013

WCPS: Wireless Cyber-Physical Simulator

Wireless Structural Control (WSC) systems can play a crucial role in protecting civil infrastructure in the events of earth quakes and other natural disasters. Such systems represent an exemplary class of cyber-physical systems that perform close-loop control using real-time sensor data collected through wireless sensor networks. Existing WSC research usually employ wireless sensors installed on small lab structures, which cannot capture realistic delays and data loss in wireless sensor networks deployed on large civil structures and their impacts on structural control. The lack of realistic studies and tools that capture both the cyber (wireless) and physical (structures) aspects of WSC systems represent a hurdle for cyber-physical systems research for civil infrastructure. This paper advances the state of the art of WSC and Cyber-physical System through the following contributions. First, we developed the Wireless Cyber-Physical Simulator (WCPS), an integrated environment that combines realistic simulations of both wireless sensor networks and structures. WCPS integrates Simulink and TOSSIM, a state-of-the-art sensor network simulator featuring a realistic wireless model seeded by signal traces. Second, we performed two realistic case studies each matching a structural model with wireless traces collected from real-world environments. The building study combines a benchmark building model and wireless traces collected from a multi-story building. The bridge study combines the structural model of the Cape Girardeau bridge over the Mississippi River and wireless traces collected from a similar bridge (the Jindo Bridge) in Korea. These case studies shed lights on the challenges of WSC and the limitations of a traditional structural controller under realistic wireless conditions. Finally, we proposed a cyber-physical co-design approach to WSC that integrates a novel holistic scheduling scheme (for sensing, communication and control) and an Optimal Time Delay Controller (OTDC) that substantially improves structural control performance.

Software Setup

As an

Example sidebar code:

File:Example sidebar.png
Sidebar example
* navigation
** mainpage|mainpage
** Special:Recentchanges|Recent changes

MATLAB

The navigation bar can be split into sections, each with a heading of its own. The heading for each section is taken from the first-level list element ("navigation" and "new heading" in the example above).

If this text corresponds to the name of an interface message (an existing page of that title in the MediaWiki namespace), then the text of that page is used as a label; otherwise, the header title is used as-is.

Bug: no sidebar is shown in the Nostalgia skin (bug 10794).

TinyOS

Second-level list elements are links ("mainpage|mainpage" in the example above), where the format is:

** target|link text
target
The link target can be the name of an interface message (page in the MediaWiki namespace) or wiki page, or an external link. In either case, the link can be internal, interwiki, or external. In some cases (such as links with the "&" character), an interface message is necessary. The link target cannot be made dependent on the interface language set in the preferences.
Algorithm followed:
  1. Get the target text.
  2. If there is an existing or default interface message with that name, use the content of that message instead of the target text.
  3. If the output from the previous step is a valid url (beginning with http:// or other url protocol), the link will point to that url.
  4. Else, it will treat it as the link target of a wikilink (linking to that page name or interwiki).
  5. In case it would end up linking to '-', the whole entry is removed from the sidebar (that's useful for removing an entry on all languages by changing the message holding the link).


Examples:
  • "** portal-url|portal" uses the text of MediaWiki:Portal-url (which contains "Project:Community portal").
  • "** Special:Recentchanges|Recent changes" links to Special:Recentchanges, since there is no interface message of that name.
  • "** w:Foo|Some interwiki page" links to w:Foo for the same reason.
  • "** http://www.mediawiki.org|MediaWiki home" links to http://www.mediawiki.org for the same reason.


text
The link text can be the name of an interface message (page in the MediaWiki namespace) or plain text.
  • If the link text is the name of an existing or default interface message, the content of that message will be used. MediaWiki will check for localized versions; for example, if the current language is fr (French) and the link text is the interface message "forum", it will check for "forum/fr" before using "forum".
  • Otherwise, the link text is used as the target as-is.
  • Notice that the link text is not optional as in normal wiki links. If the link text is missing, the item is ignored.
Examples:
  • ** Homepage|mainpage uses MediaWiki:Mainpage (which contains "Cyber-Physical Systems Laboratory").
  • ** Special:Recentchanges|Recent changes uses "Recent changes", since there is no interface message of that name.

PYTHON

By default, the sidebar consists of elements in this order: navigation, search, toolbox, languages. The order can be changed (in MediaWiki 1.13+) by adding special keywords (SEARCH, TOOLBOX and LANGUAGES) to MediaWiki:Sidebar using the heading syntax. For example, the following code moves the search box to the top of the sidebar:

* SEARCH

* navigation
** mainpage|mainpage
** Special:Recentchanges|Recent changed
* new heading
** portal-url|portal
** http://www.mediawiki.org|MediaWiki home

Software Environment Testing

You can translate the strings, which you use, by editing the according pages in the MediaWiki namespace.

Example: The string, which will replace the item named "mainpage", is taken from MediaWiki:Mainpage. To set/change this text for users, who display your wiki in German, you can put the according text on the page MediaWiki:Mainpage/de.

That way you can easily translate these texts through the MediaWiki interface.

For more advanced translation, see Help:Extension:Translate/Unstructured element translation.

Wireless Network Modeling in WCPS

The sidebar can be fully customized by implementing JavaScript or Cascading Style Sheets, or by editing the PHP files directly. Before using these methods, note that:

  • JavaScript is fragile: it will not work for users with JavaScript disabled, and scripts frequently fail in different browsers or skins.
  • Editing the PHP files can easily cause unexpected errors, and your changes will be lost in the next update unless you manually change the new files.

Application Layer

Some pages should sometimes follow the content language, especially for multilingual sites. This can be controlled with the setting $wgForceUIMsgAsContentMsg. Each message overridden in this way must be explicitly given, for example to let the sidebar link to versions given by the content language for the main page and the portal page add the following to LocalSettings.php

code
<source lang="javascript">

$wgForceUIMsgAsContentMsg = array( 'mainpage', 'portal-url' );

</source>

Mac Layer

The toolbox, which appears under the search bar, is a dynamic element and cannot be easily customized without the use of skinning extensions (otherwise it requires programming in PHP.) If you still want to do so, you can copy skins/MonoBook.php, creating a new skin. You can then make a custom skin to generate these links in your preferred fashion.

Another javascript solution is below.

For this solution to work on the entire mediawiki site, this script has to be copied to MediaWiki:Common.js (MediaWiki:Common.js is available for Mediawiki 1.9 +).

For this solution to work only for a specific user, add this script to Special:Mypage/monobook.js (or another js-page, depending on your prefered skin).

Now simply configure which link should appear in which section. You also can remove some links if you want to.

code
<source lang="javascript">

function ModifySidebar(action, section, name, link) {

   try {
       switch (section) {
         case "languages":
           var target = "p-lang";
           break;
         case "toolbox":
           var target = "p-tb";
           break;
         case "navigation":
           var target = "p-navigation";
           break;
         default:
           var target = "p-" + section;
           break;
       }
       if (action == "add") {
           var node = document.getElementById(target)
                              .getElementsByTagName('div')[0]
                              .getElementsByTagName('ul')[0];
           var aNode = document.createElement('a');
           var liNode = document.createElement('li');
           aNode.appendChild(document.createTextNode(name));
           aNode.setAttribute('href', link);
           liNode.appendChild(aNode);
           liNode.className='plainlinks';
           node.appendChild(liNode);
       }
       if (action == "remove") {
           var list = document.getElementById(target)
                              .getElementsByTagName('div')[0]
                              .getElementsByTagName('ul')[0];
           var listelements = list.getElementsByTagName('li');
           for (var i = 0; i < listelements.length; i++) {
               if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                   listelements[i].getElementsByTagName('a')[0].href == link) {
                   list.removeChild(listelements[i]);
               }
           }
       }
   } catch(e) {
     // lets just ignore what's happened
     return;
   }

}

function CustomizeModificationsOfSidebar() {

   //adds Special:CategoryTree to toolbox
   ModifySidebar("add", "toolbox", "CategoryTree", "http://en.wikipedia.org/wiki/Special:CategoryTree");
   //removes Special:Upload from toolbox
   ModifySidebar("remove", "toolbox", "Upload file", "http://en.wikipedia.org/wiki/Special:Upload");

}

addOnloadHook(CustomizeModificationsOfSidebar);

</source>
Usage
function CustomizeModificationsOfSidebar() has to be customized for adding or removing links in specific sections:
ModifySidebar("action", "section", "name", "link");
parameter value
action add to add a link; remove to remove a link
section navigation, toolbox, languages but also any other existing customized section; the given link will be added to or removed from this section
name contains the text of the link
link contains the URL of the link
restricting modifications to specific usergroups

If you want to restrict the modification of the links to a specific usergroup (e.g. bureaucrat), change <source lang="javascript">addOnloadHook(CustomizeModificationsOfSidebar);</source> to <source lang="javascript"> if (isArray(wgUserGroups)) {

   if (wgUserGroups.Contains('bureaucrat')) {
       addOnloadHook(CustomizeModificationsOfSidebar);
   }

} </source> and add <source lang="javascript"> function isObject(obj) {

   return typeof obj == "object" && obj != null;

}

function isArray(obj) {

   return isObject(obj) && obj.constructor.toString().indexOf("Array") != -1;

}

Array.prototype.Contains = function(element,strict) {

    for(i in this) {
         if(this[i] == element && !strict || this[i] === element) return true;
         }
    return false;
}

</source>

For restricting the modifications to IPs instead of a specific usergroup use <source lang="javascript"> if (!isArray(wgUserGroups)) {

       addOnloadHook(CustomizeModificationsOfSidebar);
}

</source>

Physical Layer

If you use the monobook-style and don't want to miss the expandable Menubar from e.g. Vector-Skin, paste the following code in MediaWiki:Common.js of your wiki. <source lang="javascript"> /////////////////////////////////////////////////////// // Codesnippet to make your sidebaritems expandable // // Use this code ONLY for monobook-Style. // ///////////////////////////////////////////////////////

$(document).ready(function(){

 //set the default expanded Items by their headline
 var defaultExpandItems= ['Navigation', 'Orga'];
 //set the basic-name for the cookies, which save the current state of expanding
 var expandCookieName = "disdance_project_wiki_nav_expanded_";
 var maxHeights=[]
 var expandeds=[];
 var labels=[];
 initNav();

});

function initNav(){

   $('#p-logo').css({'position':'relative', 'display':'block'});;
   $('.generated-sidebar h5,#p-tb h5 ').each(function(i){
      
         var id = $(this).parent().attr('id');           
         maxHeights[id]=$(this).next('div').height();
         var str = $(this).html();
         labels[id]=str;     
         
         if ($.cookie(expandCookieName+id)=='false'  ){               
               expandeds[id]=false;
               minimize( $(this));
               
        } else if ($.cookie(expandCookieName+id)=='true'  ){
               expandeds[id]=true;
               maximize( $(this));
       
        } else if (defaultExpandItems.indexOf(str)==-1){
               expandeds[id]=false;
               minimize( $(this));
        } else {
               expandeds[id]=true;
               maximize( $(this));
        }
        $(this).css({'cursor':'pointer'});
        $(this).click(toggleNav);
   });

}

function minimize(target){

   var id=$(target).parent().attr('id');
   //You can change the expires-parameter to save the Cookie longer/shorter than 7 days like in this Code
   $.cookie(expandCookieName+id,'false', { expires: 7});
   var str = labels[id]+"  ►";
   $(target).next('div').animate({'height':'0px'});
   $(target).html(str);    

}

function maximize(target){

   var id=$(target).parent().attr('id');
   //You can change the expires-parameter to save the Cookie longer/shorter than 7 days like in this Code
   $.cookie(expandCookieName+id,'true', { expires: 7});
   var str = labels[id]+"  ▼";
   var  newHeight = maxHeights[id];
   $(target).next('div').animate({'height':newHeight+'px'});
   $(target).html(str);    

}

function toggleNav(e){

   var id=$(e.target).parent().attr('id');
   expandeds[id]=!expandeds[id];
   if(expandeds[id]==true){ 
      maximize(e.target);
   } 
   else{ 
      minimize(e.target);
   }

}

/////////////////////////////////////////////////////// /////////////////////////////////////////////////////// </source>

Control Modeling in WCPS

Integration of Wireless Networking and Simulink

Wireless Networking Traces

WSC Examples with WCPS

Wireless Building Control

Wireless Bridge Control

Simulink Models

MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. Purging the cache of affected pages should correct the situation. To perform a mass-purge of all caches at once, touch the LocalSettings.php file or truncate the objectcache table in your database (you may have to do both).

You also need to have $wgUseDatabaseMessages set to true.

Lowercase link labels

If your links are not being capitalized as intended, try adding spaces around the bar character; for example:

** http://www.example.com/download.php?file=44555 | Download

Sections disappear or show unexpected content

If a section does not display or displays unexpected content, check that the header text isn't the name of an interface message by searching Special:Allmessages. If it is, use a different header text, or create a new interface message and use it.

For example, if you want to use "Sidebar" as header text, create the interface message "MediaWiki:Sidebar-header" containing only "Sidebar". Then, use * sidebar-header as header.

Sections are not displayed if there are no links of the form ** target|link text (e.g. when the target was forgotten).

Broken links after updating Special:Version

This will happen e.g., each time there are newer translations for your site language's sidebar items. One could add new redirect pages each time, but a better solution would be to use one's own sidebar item names instead of trying to keep track of the current MediaWiki translations.

Ancient version of MediaWiki

If you have a pre-release version of 1.5 Beta, or earlier, it is still possible in some cases to edit the sidebar:

See also