Sunday, September 13, 2015

Android reload database on resume or restart.

This scenario happens when , say we have two activities A and B.
From A we go to B and update the database. Then when we comeback at A
we notice that the A is not updated.
We have to implement the OnRestart in A, so that when the BACK button is pressed our
database is reloaded.

      @Override
    public void onRestart()
    {
        super.onRestart();
        finish();
        startActivity(getIntent());
    }

  


You can also try OnResume too



     @Override
    public void onResume() {
        super.onResume();  // Always call the superclass method first
        finish();
        startActivity(getIntent());

    }

  

This is just a trick, hope it paved your way out. 

Wednesday, September 9, 2015

Modulo Operator in Structured Text

 If you are reading this post, I am sure that you have other programming language background and have to fire the %  operator in your IF ELSE condition.
 But rather the equivalent operator for structured text you should use is MOD operator.
So instead of writing
 IF ( ( myVar % 10 ) == 0 ) THEN

 You should

IF ( ( myVar MOD 10 ) = 0 ) THEN

I hope that you are going to continue peaceful your journey to your project in automation.

Happy coding day !!

 

Wednesday, September 2, 2015

First PLC experience of a Computer Science Student

It has been a couple of months that I have been involved in PLC. I am computer science graduate used to mainly Soft-Programming. So far I have done essentially high level programming with languages such as java, C/C++ , PHP, Python and more.
After many hesitations I have decided to take an offer involving Hardware programming.
It has been my first time dealing with this complex type of programming. I have been really surprised by lack of documentation online on this important area of industrial automation. The few I even got were not free. If you are reading this post I am sure that you faced a similar scenario.  My intention starting this series of posts is to share with you whatever experiences and resources I assume useful, therefore giving back my contributions to this evolving community. I will be glad to know that whatever I share here is useful to my readers. The next post is coming soon, please feel free to drop a line of comment.