Monthly Archives: June 2014

Medical Device Coordination Framework

Patient room - future

As a Research Assistant at SAnToS Lab I am working on Medical Device Coordination Framework. It is a long term research effort. MDCF is an implementation of Integrated Clinical Environment. There is many people involved in it. Not only from my University. There are folks from University of Pennsylvania and some other researchers who cooperate with us. My part of research is focused on code translation. You can call it Model Driven Development. The long-term research goal is to create a AADL/BLESS to SPARK Ada translator for Medical Devices.


AADL stands for Architecture Analysis & Design Language. It is modeling language, which allows to describe hardware and software parts of the system. It can be represented in graphical and textual form.

BLESS stands for Behavioral Language for Embedded Systems with Software. It is an extension to AADL language. AADL can be extended by language annexes. BLESS is one of them. It is designed to prove embedded software/system conformance to specification. In other words: to verify the AADL model.

SPARK is a programming language and static verification technology designed specifically for the development of high integrity software. It is subset of Ada programming language. It contains all features of Ada, except:

  • Pointers
  • Exceptions
  • Aliasing between variables
  • All Concurrency features
  • Side effects in expressions and functions

However, it contains toolset for Software Verification, such as:

  • Examiner – analyze code and ensures that it conforms to the SPARK language; also verify program to some extent using Verification Conditions (VC)
  • Simplifier – simplify Verification Conditions generated by Examiner
  • Proof Checker – prove the Verification Conditions

I blogged about SPARK Ada recently.

Research background

The ultimate goal has a big scope. The goal is to deliver a platform, which allows different medical devices to work together. Moreover, there will be monitored and controlled by centralized system.

We use and create a lot of different technologies. From AADL, BLESS, DML to SPARK Ada, Java, through many other. Most of them are still under development. I work mainly with AADL, BLESS and SPARK Ada. The biggest challenge for me is to understand how AADL models should be mapped to SPARK Ada in real-World. Unfortunately, I cannot find some Open Source examples on github. Companies treat it as their intellectual property, and do not share it. More over, the AADL committee still did not decide how some AADL constructs should be mapped to Software. Thus, my role is to propose it (based on existing work).

There is an AADL to Ada code generator: Ocarina. It is written in Ada and it uses Ada features, which are not in SPARK language. However, it is a good point to start. Another resource I am based on is Aerospace Standard – Architecture Analysis & Design Language (AADL) V2 Programming Language Annex Document. It describe data types translation and base for ports communication.

The essence of AADL models is port-based communication. Usually implemented in publish-subscribe mode. It allows to interaction between different components of the system.

Sample medical device

To create code translator for Medical Devices, I needed some example of Medical Device. One member of our research group, Brian Larson created AADL/BLESS models of Patient-controlled analgesia Infusion Pump. This device, is used to infuse a pain killer. The dose can be controlled by patient. He also created Open PCA Pump Requirements. Document, which describe precisely functionalities of PCA Pump. My role is to develop AADL/BLESS to SPARK Ada translation schemes and translate existing PCA Pump models, to assure that translation makes sense.

PCA Pump

Research plan

There are many issues and problems to solve in this project. One of them is SPARK limitation. Besides excluded features mentioned above, SPARK 2014 does not support multitasking (yet). SPARK 2005 support it in some extent (with Ravenscar profile). Thus I use mainly SPARK 2005.

The plan is as follows:

  • Create AADL/BLESS to SPARK Ada translation schema
  • Manually implement working PCA-Pump prototype on BeagleBoard-xM based on Requirement document to find out possible implementation issues
  • Manually translate AADL/BLESS models to SPARK Ada, reusing code created during implementation
  • Create AADL/BLESS to SPARK Ada translator based on manual translated code

How it goes?

I started working on this project around 1 year ago. Most of the time, I spend on studying AADL, SPARK Ada, BLESS and Ravenscar Profile. I thought, I would accomplish much more. However during the process I faced a lot of problems and I had to Shave the Yak. First challenge was to run SPARK Ada code on BeagleBoard-xM device. In cooperation with Ada Core, we got cross-compiler, which works for its processor. It took around 3 months, because cross-compiler was under development. After around half a year of exploring, I came up with AADL ports translation schema (based on AADL annex document). Simultaneously, I was working on PCA Pump implementation (based on its Requirements Document). Most of it is described in SPARK Ada programming for ARM-based device(BeagleBoard-xM). It allowed me to better understand SPARK Ada development environment and create translation schemes for AADL packages threads. SPARK Ada development is much different than Java, C# or Python. After many hours spent on AADL/BLESS models analysis, I created mapping from BLESS to SPARK Ada.

For now, most of the work is done. Especially, translations schema. I have less than 2 months to finish everything. My plan is to refactor existing PCA Pump implementation and create final mock of code translated from AADL/BLESS models. Additionally I want to add implementation to some ‘translated’ part and apply SPARK Verification tools and AUnit tests. Finally, I will need to describe everything in my Master Thesis.

My thoughts so far…

Development for safety-critical systems is totally different, than creating Web or Mobile applications. My research adventure is very fascinating and allow me to discover new things everyday. It gives me different perspective of Software Development, which will be useful in the future. No matter if I would work for company producing Aircrafts or Space Shuttles. It will be valuable also for Web/Mobile Start-up in Silicon Valley or personal Mobile App. Finally I understand where UML and variety of Software Design Processes can be applied. Programming in SPARK Ada requires deep thinking and understanding about how every small part of the program work. There is no high abstraction layer, where calling some library function will do all work. It allows to understand what is underneath and how powerful languages like C#, Java or Python are.

If you are at the University now, I strongly recommend you to join some Research Group. Or at least talk to some of your professors and ask if you can do some Research-oriented project for him. No matter, if you are Graduate or Undergraduate student. If research topic is out of your comfort zone, then it is even better!

outside comfort zone

Applying for PhD in USA

This post is an overview of PhD application process in USA. Application for Master program is usually very similar, but there are differences, specific for every University. Actually, every University has their own requirements, which are similar among the country.

My very first advice is to start planning application process at least 1.5 year before the semester in which you want to start your program. In most top Universities the PhD programs are starting only in Fall and application deadline is in mid-December, on the previous year (e.g. for Fall 2014 it is December 2013). Almost 1 year ahead! There are also Universities, which are admitting for Spring as well. However deadline is still around 6+ months before program’s start date.

To do list for PhD application

  1. Find Universities/Professors/Research groups you are interested in
  2. Take standardized tests: GRE and TOEFL(*)
  3. Write Statement of Purpose
  4. Get 3 recommendation letters from your Professors
  5. Get your transcript of records
  6. Apply!

Now, let’s look at each of the above tasks in details.

Find Universities/Professors/Research areas you are interested in

This choice depends on many factors. It is worth to apply for some top Universities, some good Universities and one or two you are sure you will be admitted. When you are choosing Universities it is good to check its rank in your major. E.g. Harvard (one of the best Universities in USA) is #22 in Best Computer Engineering Grad Schools ranking, while University of Michigan is #5. Even more important than ranking (which is more useful in case of Undergraduate Programs) are Professors and research ares at the chosen University. This part will take you weeks if you are starting from scratch (you have no idea about that). It is worth to ask your professors for advice in selecting Schools.

My advice is to choose some 1-3 top Universities, 1-3 average (where you have real chance to be admitted) and 1-2 you are almost sure you will be admitted.

Be aware that applying for Grad School is not free. You need to pay non-refundable fee for every University you want to apply. Usually the application fee is around $70-80. However some Universities are expensive, e.g. Stanford: $125. As long as you are not rich (and you are probably not, when you are a student), you need to choose Schools you are really interested in to don’t waste your money.

Take standardized tests: GRE and TOEFL(*)

During Universities/Programs research, you can start preparation and schedule test dates for standardized tests.

95% of good Universities require GRE (Graduate Record Examinations). Preparation for this exam is usually 1 to 6 months depends on your knowledge. It will be easier for people to whom English is a first language. It will be also easier if you are good at math. Reasonable preparation time for this exam is 1-3 months. More details about that you can find here. There are three sections: Verbal Reasoning (130-170 points), Quantitative Reasoning (130-170 points) and Analytical Writing (0-6 points). I know, it is weird that the minimum score in Verbal and Math is 130 🙂 The exam takes around 4 hours in total. You need to wait around 2-3 weeks for results. Cost: ~$200 (depends on country/city where you are taking it).

I think all Universities require TOEFL exam (Test of English as a Foreign Language) if you are international student. There are variety of possibilities to waive it (e.g. if you have US degree, or you are full-time student in USA for more than 2 years), but it depends on the specific University. Test is not very hard, when you can communicate in English without any problems. The challenging part is the fact that it takes more than 4 hours, and you need to stay focused all the time. There are four sections: Reading, Listening, Speaking and Writing (30 points for each, 120 is maximum in total). You need to wait around 2-3 weeks for results. Cost: ~$200.

Every University (and some Departments) has GRE code and TOEFL code. You need to provide this code, to specify where you want your results to be sent. In case of GRE I needed to provide this code at the end of exam (in the examination center). In case of TOEFL: “Score report recipients can be added or deleted through the TOEFL iBT® online registration system until 10 p.m. (local test center time) on the day prior to the test date”. Due to that, it is good to check these codes earlier (and take them to the examination center in case of GRE). When I was taking TOEFL and GRE, I was able to select up to 4 institutions to which they send my results without any additional charge. If you want to apply to more Grad Schools you need to order extra results (which is not free). In my case it was $18 for TOEFL and $25 for GRE (per one copy!).

Statement of Purpose

It is similar to cover letter. In Statement of Purpose you should describe what is your interest and relevant experience, which can be useful during PhD research. There are many online resources how to write statement of purpose. E.g.: here and here. What is very important: you need to tell the truth. Especially about your research interest. Based on SoP (Statement of Purpose) you might be admitted or not by specific professor. Remember that PhD is usually 5-6 years and you probably would like to do stuff you are passionate about. Not some things you have never heard about, and do not have any interest in.

Get recommendations

Graduate Schools require usually 3 recommendation letters. It is good when 2 are from your professors and 1 from somebody you were working with out of your University (e.g. during Internship or in job before/after College). If you do not have person like that it is fine to get recommendation only from your Faculty members. In general professors don’t like you to see their recommendations. It is not a problem, because you just need to provide their e-mails for Graduate School. Then Graduate School (or Department) send a ‘request for recommendation’ directly to them. They need to reply for this email or upload your recommendation online. Additionally you will get an option to ‘Waive right to review recommendation’, which means you won’t see the recommendation. I think there are variety of reasons behind that (e.g. student may not like something in the letter, or when he get very good recommendation he may lose motivation etc.). Anyway, you should not be worried about that if you are a good student.

Get your transcript of records

In case of US University this part is easy. You just request transcripts from University and they know what to do. Even when you are not student anymore. In case of foreign country it might be an issue. It was in my case (Poland), but finally (after many phone calls and e-mails) I got them. Fortunately most of Universities accept unofficial copies. Especially from foreign countries, because they are aware of differences between education systems. However, most of Schools require you to send them paper copy of your transcripts. Additionally they are providing specific address to which you should send them. Usually it is Graduate School, but sometimes it might be department. You need to check this on your own.


To do the final step, which is ‘apply’ you need to register in every University’s Grad School online system. After providing all necessary information and listing your recommenders, you need to pay the application fee. Remember about sending your tests (GRE/TOEFL) results and your transcripts to every School.

Now, let’s look how it goes in practice.

My PhD applications

Finding Universities/Professors/Research areas I am interested in

I am already in Graduate School (in Master program) at Kansas State University. I am GRA (Graduate Research Assistant) in very strong research group: SAnToS lab. Additionally PhD was only an option for me. It means: it wasn’t my only way (get PhD or die) to move my career forward. Another option was to find a job.

Because of that I needed to adjust my recommended strategy (1-3 top + 1-3 average + 1-2 sure Universities). I think my Department is one of average (#85 in Grad Schools ranking) and I had high chances to be admitted (Faculty already knows me, I had experience in their research area etc.). I chose one more average: University of Massachusetts (they work on similar things as I am in my research) and 5 top Universities: Stanford, Carnegie Mellon, MIT, Harvard and University of Pennsylvania.

Taking standardized tests: GRE and TOEFL(*)

I took TOEFL before I started Master Program and I got 86/120. I could use it for my PhD applications because the test was taken less than 2 years ago. In most of Universities TOEFL results don’t expire for 2 years.

I needed to take GRE, because I didn’t take it before. I had to go to Topeka, KS (60 miles from Manhattan, KS where I am currently studying). It was much harder than TOEFL. I learnt some words in English, which I didn’t know even in Polish before. E.g. bigot or ephemeral. Do you know them? My results: 3/6 (Writing), 144/170 (Verbal), 168/170 (Quantitative). Not good in Verbal, but not bad in Quantitative (Math). I thought I have some chances. Especially, because Grad Schools don’t require minimum. They use GRE only as indicator, which means that if you are awesome in different areas, they don’t really care about it. Of course most of people who are awesome in other areas, have also good GRE scores 🙂

Writing Statement of Purpose

It took me a few days. Especially because I adjusted some parts for specific University. The structure of my SoP was as follows:

  • something about me
  • my experience
  • what I want to do
  • why this University

Getting recommendations

I got recommendations from my major professor, one other professor from my research group and my former manager (from the company I was working for before Graduate School).

Getting transcript of records

It was super easy in case of Kansas State University. I just needed to log in into Internet Student Information System (ISIS), request transcript and provide address to which I want them to be sent. Everything for free ($0!) if you are current student.

Unfortunately, it was not that easy in Poland. At Wroclaw University of Economics, I needed to prepare it on my own and lovely Ms. Daga had to check if it conforms to data in the online system. No possibility to print it from the system (sic!). Then somebody needed to pick it up in person. I asked my sister, who picked it up and gave them to me, when I was in Poland for Christmas. At Wroclaw University of Technology it was even harder. They do not have procedure to issue transcripts for former students (sic!). I had only one copy of my diploma supplement (which is similar to Transcript of Records). I copied it, went to the dean’s office and ask for University stamp on it. Again in this situation, one women working there was nice and did it for me in the same day (she needed to review manually 7 copies in total!). I hope that this situation will change soon. Students should be able to request transcripts through online system (not necessary for free) and be able to pick it up or get it sent to chosen place.


Application deadlines of Universities I chose were in the middle of December. E.g. Carnegie Mellon had two deadlines: early in December 4 (fee: $75) and late in December 16 (fee: $125). I sent transcripts after I paid the fee (because I didn’t collect all of them before) and it was fine. The same with recommendations, some of them were sent 5-10 days after deadline. Thus I think the most important part is to send the online application (along with fee). You can send all other documents within some reasonable time (one month?) after deadline.


  • Stanford – REJECTED
  • Carnegie Mellon – REJECTED
  • Harvard – REJECTED
  • University of Pennsylvania – REJECTED
  • University of Massachusetts – REJECTED

Sounds bad, right? Rejected everywhere. However, I chose 5 top Universities and 1 average. Currently I am at the Kansas State University, which is aspiring to TOP 50 Public Research Universities. Additionally, I am already in very good research group: SAnToS lab. Thus, it was only make sense to apply for better Schools.

K-State was on my list of Universities, that “I’m sure I will be admitted”. Finally I didn’t apply for PhD program at Kansas State University, because I got a job offer from company I wanted to work for.

After rejection, I sent e-mail to every University asking about rejection reason. Most of them replied, that they “cannot provide details, because of high number of applications”. Only Stanford gave me outline of reasons:

  • low score in some sections of GRE (50% in Writing, 45% in Verbal), it is good to have around 90% in every section
  • low GPA: my 4.72 in Poland, converted to USA scale is ~3.23; good students in USA have GPS greater than 3.5 (usually close to 4.0)
  • no publications (top Universities like even Undergraduate students with publications)

They also recommended me to enroll for some Graduate Courses via their Non-Degree Option program. Then, after getting good grades (A+) I will have higher chances to be admitted.


PhD studies might be very good experience and adventure. Especially in USA, where you have opportunity and environment to work on technologies of tomorrow. I was lucky to have this chance during my Master studies. I am working for SAnToS Lab. Our main research areas are Formal Methods and Medical Devices. We have access to pre-releases of IDE (GNAT Programming Studio), which are public 6 or more months later. We are working on standards for Medical Devices, which will be (or not) in the Industry after 20 years from now. It is a lot of other cool stuff, which I describe in the other post.

Before you decide pursuing PhD, be aware that it will take 5-6 years (or even more) and you will be around 30 years old when you graduate. During this time you can gain experience in industry or start your own company. Of course you can cancel your PhD studies, but it is better to really think about it before you start application procedure. It also take a lot of time, during which you can applying to some great companies or creating apps.

Applying Pomodoro Technique


Piotr Rabiniak asked question about Pomodoro Technique at .NET Developers Poland facebook group. Lot of people replied, that they are using it. So do I. Usually using my Pomidoro Windows 8 app. I don’t use Pomodoro Technique everyday, but there are two main scenarios, when I find it extremely useful:

  1. At work, when I have many interesting things to check out (e.g. Twitter, Facebook, Blogs, etc.). After first Pomodoro, I am in the flow, focused on work. Then I continue and after 4-6 pomodoros lot of things are done.
  2. At home (after work), when I want to play with some new technology or do some programming. There is also a lot of distractions, but this time it is worse. After I check all tweets, facebook, news, recent developers conferences, it is 10pm. Then I work till midnight or 1am, and do not have time to rest before the next day. For that, I created a rule: I can spend 4 pomodoros after work. No more, no less. It helps a lot! I come back home, eat dinner, start 4 pomodoros around 8pm, and at 10pm I am done. Additionally, even if it wasn’t enough to accomplish everything I wanted, my excitement level for next day is higher.

For me, Pomodoro Technique is not a way for living, but sometimes is extremely helpful. The magic happens, because it is only 25 minutes. It is not a lot, but it is enough to get into the flow. And after that you can have a 5 minutes break. In my case, the hardest thing is start working. After I dive in…everything is easy 🙂

There are many Pomodoro apps. I use one on my iPhone and my Pomidoro app for Windows 8.

Interprocess communication between Python and Java

For my Research work I need to communicate between Python and Java/Scala application.

The first idea was to use WebSockets. It is universal and flexible. Additionally communication is easy. There are many ways to implement it:

Implementation would be easy, but we are using customized version of Python, which is included in GNAT Programming Studio. Some libraries (required for WebSockets) are excluded (because of legal reasons) and we wouldn’t be able to redistribute it along with missing packages. Thus, we decide to implement interprocess communication through pipes.

From Python to Java

The communication is one direction: from Python app to Java app. Every message is one line of text (ultimately: json format). E.g.: “text\r\n”. To close communication, we send message: “x\r\n”.

This is sample Java app, which write received messages to file result.txt:


public class MyClass {
	public static void main(String[] args) {
		try {
			BufferedReader bufferRead = new BufferedReader(new InputStreamReader(;
			PrintWriter writer = new PrintWriter("result.txt", "UTF-8");
			String s = bufferRead.readLine();
			while(s.equals("x")==false) {
				s = bufferRead.readLine();
		} catch(IOException e) {

And here is sample Python app, which sends messages to Java app:


import subprocess

p = subprocess.Popen(["java", "MyClass"], stdin=subprocess.PIPE)
p.stdin.write("First line\r\n")
p.stdin.write("Second line\r\n")
p.stdin.write("x\r\n") # this line will not be printed into the file

From Java to Python

We can also communicate in opposite direction: from Java app to Python app. To do that we just need to change reading to writing in Java app and writing to reading in Python app.

Change in Java app is simple: we just write to standard output.


public class MyClass2 {
	public static void main(String[] args) throws InterruptedException{
		System.out.println("First msg");
		System.out.println("Second msg");

In Python app we need to create stdout pipe and read instead of write:


import subprocess

p = subprocess.Popen(["java", "MyClass2"], stdout=subprocess.PIPE)
line = p.stdout.readline()
while(line != "x\n"):
	print line
	line = p.stdout.readline()

In this scenario, both processes are managed by Python app. You can also do it in opposite direction and invoke Python app from Java app.

MacBook External Display resolution problem

MacBook 3 monitors

Today I wasted 2 hours trying to adjust resolution on external monitor connected to my MacBook.

I work with two external Monitors (Sun 24″). One through miniDP/VGA, second: through USB/DVI.

Yesterday, I connected MacBook to 42″ TV, with miniDP/VGA port. Today I connected it with Sun Monitor as usual and…I got black screen. I tried to change resolution, but…1920×1200, which I am usually working with, was not available. Even more: when I set ‘Best for display’ I got 800×640! Maximum available was 1600×1200, but it was wrong ratio! The Sun 24″ monitor has 16:10 ratio, not 4:3!

I tried deleting preferences, reseting PRAM etc. It didn’t help. Finally I tried to use miniDP/DVI (instead of miniDP/VGA) and I got 1920×1200. Then, when I connected miniDP/VGA again, I got 1920×1200 as well.

What I did wrong? I connected it when MacBook was in sleep mode. That is most likely cause of the issue. Probably MacBook thought it is still connected to 42″ TV. Thus, changing port helped. Probably, if I connect it to another device, it would help as well.

In the past I already had issues when I was disconnecting monitors in sleep mode. Since that time, I was always connecting/disconnecting displays when MacBook was on. Except today 🙂