Tuesday, September 12, 2017

Internet of Things (IoT) - Next Stage of Information Revolution

The term "Internet of Things" was first coined by Kevin Ashton, cofounder and executive director of the Auto-ID Center at MIT in 1999.

The "Internet of Things (IoT)" is the next stage of the Information Revolution. 

What is IoT (Internet of Things)?

IoT refers to the connection of devices (other than computers, smartphones and tablets) to the Internet via embedded sensors. It allows devices to talk to us and talk to each other. So, IoT can also be defined as a network of internet-connected devices able to collect and exchange data using embedded sensors. 

A thing, in the "Internet of Things", can be a person with a heart monitor implant, a farm animal with a bio-chip transponder, an automobile that has built-in sensors to alert the driver when tire pressure is low or any other natural or man-made object (almost anything else you can think of) that can be assigned an IP address and provided with the ability to transfer data over a network with the help of embedded sensors. 

Earlier the data was created by people on the internet, but now the data will be created by the things (living or non-living) without any human intervention.

IoT Devices

Any stand-alone internet-connected device that can be monitored and/or controlled from anywhere. It should have embedded sensors and on/off switch. It should have the ability to represent itself digitally means it can be assigned an IP address and have the ability to collect and transfer data over a network without manual assistance or intervention. 

Due to the limited address space of IPv4 (which allows for 4.3 billion unique addresses), IoT devices will have to use the next generation of the Internet protocol (IPv6) to scale to the extremely large address space required.

Examples of IoT Devices: Smartwatch, TV,  Refrigerators, Washing Machines, Kitchen Appliances, Thermostats, Cars, Switches, Lights, Blood Pressure and Heart Rate Monitors, Smart grids, Virtual Power Plants, Intelligent Transportation and anything you can think of.

Basically, if your fridge or TV has an Internet connection, then it becomes an IoT device.

If your coffee maker connects to an app on your smartphone that allows you to begin brewing with a tap on your screen, that coffee maker becomes part of the Internet of Things.

As per IoT, Anything that can be connected, will be connected. Connect everything in this world. The Ultimate Goal of IOT is to Automate Human Life. In this way, IoT creates a relationship among people-people, people-things, and things-things.

Applications of IoT

Wearables (like Smartwatches to track health and exercise progress, sleep patterns, send text messages and calls).

Smart Home (hundreds of products in the market that users can control even with their voices).

Smart Cities (solves traffic congestion issues, smart parking, reduces noise, crime, and pollution).

Connected Cars (to assist drivers and reduce accidents).

Internet of Things Devices & Examples

Amazon Echo - Smart Home: The Amazon Echo works through its voice assistant, Alexa, which users can talk to in order to perform a variety of functions. Users can tell Alexa to play music, provide a weather report, get sports scores, order an Uber, and more.

Fitbit One - Wearables: The Fitbit One tracks your steps, floors climbed, calories burned, and sleep quality. The device also wirelessly syncs with computers and smartphones in order to transmit your fitness data in understandable charts to monitor your progress.

Barcelona - Smart Cities: The Spanish city is one of the foremost smart cities in the world after it implemented several IoT initiatives that have helped enhance smart parking and the environment.

AT&T - Connected Car: AT&T added 1.3 million cars to its network in the second quarter of 2016, bringing the total number of cars it connects to 9.5 million. Drivers don't have to subscribe or pay a monthly fee for data in order for AT&T to count them as subscribers.

Other articles on IoT:

Real World Examples of IoT (Internet of Things) - How will IoT change our lives?

Monday, March 14, 2016

Oracle Forms Debugging: Using the “DEBUG_MESSAGES=YES” runtime option - Handling "Please Acknowledge" message

Oracle Forms Debugging: Using the “DEBUG_MESSAGES=YES” runtime option - Handling "Please Acknowledge" message

“DEBUG_MESSAGES=YES” is a “quick and dirty” technique for pinpointing code problems. This causes a message to automatically display to let you know each trigger as it executes. Once you encounter the runtime error, you will know the last trigger that fired and should be able to trace through the code from that point. For anyone that was around in the SQL*Forms 3.0 days, this was the default behavior when running a form in debug mode.

To use this option from the Form Builder, check the “debug_messages” option on the runtime tab after choosing Tools -> preferences from the menu. From the command line, simply add the “debug_messages=yes” option. 

If you are using an icon in Windows to start your form, add the option to the shortcut command. It would look something like this for Windows platforms:

c:\orant\bin\ifrun60.exe module=myform userid=scott/tiger debug_messages=yes

On Unix:
f60runm module=myform userid=scott/tiger debug_messages=yes

The major disadvantage of using this technique is that you have to acknowledge every message as each trigger executes, which can be very annoying. You will keep getting "Please acknowledge message" prompt each time whenever a new trigger is encountered. Although it shows the triggers that fire, it does not show program units that execute, and there is no way to display the values of variables. It can also cause the same focus problems and program flow interruption that you see with the “MESSAGE” built-in. However, this method is useful if you have no idea which trigger is causing the problem; once you have narrowed down the scope, other troubleshooting techniques would be more appropriate.

Monday, February 29, 2016

Oracle Forms Exception Handling: NO_DATA_FOUND, TOO_MANY_ROWS and OTHERS

Oracle Forms Exception Handling: NO_DATA_FOUND, TOO_MANY_ROWS and OTHERS

EXCEPTION block in PLSQL Oracle Forms is used to track the exceptions. Following is the PLSQL code snippet which uses NO_DATA_FOUND, TOO_MANY_ROWS and OTHERS exceptions. If the SQL SELECT query does not return any data, NO_DATA_FOUND exception is fired. If the SQL SELECT query returns more than one row where it was expected to return only one row, TOO_MANY_ROWS exception can be used to track this kind of exception. If you are not sure what kind of exception can the code throw, use OTHERS exception.

DECLARE
  DEPARTMENT_NAME VARCHAR(60);
BEGIN
  SELECT DEPTNAME INTO DEPARTMENT_NAME FROM DEPT WHERE DEPTNO = 20;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    MESSAGE('No data found');
  WHEN TOO_MANY_ROWS THEN
    MESSAGE('More than one row found');
  WHEN OTHERS THEN
    NULL; -- don't do anything and just return from the procedure
END;

Difference between WHEN-VALIDATE-ITEM and KEY-NEXT-ITEM triggers

Difference between WHEN-VALIDATE-ITEM and KEY-NEXT-ITEM triggers

WHEN-VALIDATE-ITEM and KEY-NEXT-ITEM triggers are very close to each other and create a lot of confusion. Following are three differences between them to clear the picture a little bit.

1. Whenever the user changes the value in the item and tries to move out of that item using ENTER or TAB or MOUSE, WHEN-VALIDATE-ITEM trigger is fired. But, in case of KEY-NEXT-ITEM trigger, if user moves out using MOUSE, it will not fire. So, the validation written on this trigger will not fire. Better use, WHEN-VALIDATE-ITEM trigger in this case as it also works with MOUSE.

2. KEY-NEXT-ITEM trigger fires before the WHEN-VALIDATE-ITEM trigger.

3. KEY-NEXT-ITEM trigger will fire every time you move to the next field from that field but WHEN-VALIDATE-ITEM will fire only when you have acutally made any changes to that item. If you have made no changes in the item, it will not fire when you move out this item.

Personally, I prefer to use WHEN-VALIDATE-ITEM trigger in many situations.

Sunday, February 28, 2016

Oracle Forms Tutorials: WHEN-VALIDATE-ITEM trigger

Oracle Forms Tutorials: WHEN-VALIDATE-ITEM trigger

Consider that you have an oracle form on which there is a datablock which uses EMP table. EMP table has a column called SALARY. Now there is a contraint on the SALARY column that it should be greater than or equal to $1000. Your requirement is that whenever any user fills salary in the Oracle Forms ITEM (say ITEM_SALARY) and tabs out from that item, a validation should fire and if the value filled is not valid, it should give you an error message and does not let the cursor go to the other item. In these situations WHEN-VALIDATE-ITEM trigger is used. Following is the PLSQL code you should write on the WHEN-VALIDATE-ITEM trigger of the ITEM_SALARY item.

IF :ITEM_SALARY < 1000 THEN
    MESSAGE('ERROR: Salary must be at least $1000 or more.');
    RAISE FORM_TRIGGER_FAILURE; -- To keep the cursor in the item
END IF;

You should also go through this video on YOUTUBE by Edward Honour.

In this video, he tries to pick the department name when the user enters the department number. If department number does not exist in the database, he shows the error message and does not let the cursor to go to the other item using FORM_TRIGGER_FAILURE trigger. He has used NO_DATA_FOUND exception for showing the error message. Following is the code used in this video:

BEGIN
SELECT DEPT_NAME INTO :BLOCKNAME.ITEMNAME FROM DEPT WHERE        DEPT_NO = :BLOCKNAME.ITEMNAME2;
EXCEPTION
WHEN NO_DATA_FOUND THEN
MESSAGE('Invalid Department Number');
RAISE FORM_TRIGGER_FAILURE;
END

5 Things you should never discuss your manager

5 Things you should never discuss your manager

An employee should be fair and transparent with his manager, but few revelations can spoil your bonding with your manager. Try never ever talking about these things to your manager:

1. Your doubt on manager' decisions - At times, you may want to raise questions on his judgement. Do yourself a favour - give it a pass. You may not know what business pressures he/she is living through.

2. Snooping on manager's life - Every employee wants to check what his or her manager is doing in social life. Don't blow your cover by admitting to doing it unashamed.

3. Office gossip - Never share office hearsay with your manager without checking its truthfulness. Sharing something random that you heard in the cafeteria and reacting to it may get him or her thinking that you are not mature or trustworthy.

4. Your personal secrets - Your life and its constant struggles are for you to handle. Pouring it all out in front of your manager will put you in a vulnerable position.

5. Your expectations from the manager - The manager is mandated to put forward his/her expectations from you. But it does not mean you to go and tell the manager how you evaluate his/her skill sets!

Friday, September 5, 2014

Difference between Free and FreeAndNil in Delphi: What to use when?

Difference between Free and FreeAndNil in Delphi: What to use when?

Free and FreeAndNil are the main concepts of memory management in Delphi. FreeAndNil is a function declared in the SysUtils unit and was introduced in Delphi 5. Below is the implementation of FreeAndNil:

procedure FreeAndNil(var Obj);
var
  Temp: TObject;
begin
  Temp := TObject(Obj);
  Pointer(Obj) := nil;
  Temp.Free;
end;

Difference between Free and FreeAndNil: 

FreeAndNil first sets the object reference to nil and then frees the object. 

When to use FreeAndNil instead of Free?

If you want a rational answer, the question to ask is, why would you want to set an object reference to nil once you’re done with it?  And there’s only one good reason to ever do that: If you want to reuse the variable later.  There are some times when you’ll have an object that may or may not be initialized. If it’s not, then the variable will be nil, and if you find it’s nil, then you create it before using it.  This is a pretty common pattern.  It’s called “lazy creation”.  But every once in a while, you want to use lazy creation on an object, then destroy it and create it again. This is when FreeAndNil comes in handy.

Use FreeAndNil for Defensive Programming

You can compare FreeAndNil with seat (safety) belts in cars: if you application runs normally - then FreeAndNil won’t be useful. But if your code mess up with something - then FreeAndNil (as seat belts too) will protect you from consequences. By clearing the reference, FreeAndNil will help you to catch your wrong access immediately. Without it (i.e. by using Free only), your code may continue to run (even without raising an exception) and will give the wrong results or damage global state. It is quite dangerous situation and may lead to corrupt your data too. By not setting it to nil (in case of Free)- you're lying to the compiler. You're telling that there is allocated memory at this location, and the truth is that it isn't. And lying to machine just isn't good. FreeAndNil is very strict in these situation will immediately give you Access Violation error which I think is good thing and you can fix the problem on the spot because you know the problem!! Compare this with case, when your code silently produce wrong results! By always using FreeAndNil you’ll make your code bullet-proof for modifications.

Example of FreeAndNil

var
  myList : TList;
begin
  try
    myList := TList.Create;
    ....
    ....
  finally
    FreeAndNil(myList);
  end;
end;