Beruflich Dokumente
Kultur Dokumente
Project Report
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Certificate of Merit
This is to certify that the under-mentioned officers of O-147 have successfully completed
the project “QNX BASED FLOOD MANAGEMENT SYSYTEM” and have been able
to achieve the desired results as a partial fulfillment of requirements for “L”
specialization course at INS Valsura.
Lt Manjunath R(52174-A))
Lt Ranjith R(52158-R)
Lt Anish Rajan(52160-W)
The project report compiled by them is an indication of the successful completion of the
project under my guidance.
(P K Roy)
Lieutenant Commander
Project Guide
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
ACKNOWLEDGEMENT
We sincerely acknowledge the invaluable guidance and help of Lt Cdr P K Roy, without
whom this project would not have been completed. His presence throughout the day and
also in off working hours helped us tide over many difficult situations.
In the end we would like to express our gratitude to the staff of Faculty of
Training Projects and also to all the people who have been associated with our project
directly or indirectly, specifically for provision of resources and have contributed to its
successful completion.
Lt Manjunath R(52174-A)
Lt Ranjith R(52158-R)
Lt Anish rajan(52160-W)
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
PREFACE
Over a period of time it has been observed that the available system for fire
detection is fast, however, the reaction time in carrying out any action is very large. An
operator manning the DCHQ is required to have absolute knowledge of not only the
whereabouts of the ship’s equipments and of course but also what actions to be taken.
Kill cards are the easiest access to any information he can gather and this most of the
time takes a large amount of time.
The primary requirement of a ships firefighting system is faster response,
minimum latency and a reliable system The idea of Automated Fire and flood Detection
and management System was evolved thus.
Here we have developed a strap on system that can be directly interfaced to the
existing fire detection system onboard. The input from the signals that come to the LED’s
on the Main Control Panel is tapped out to be input to the data acquisition modules
(ADAM4051). These analog signals are converted to digital signal given to the computer
via the RS232 protocol.
The software has been designed around a real time platform keeping in mind that
in case of a fire due to explosion every micro-second counts. Hence a Real time
Operating System (RTOS) is the only way ahead which can solve the concurrent
evolutions in real time with minimum system latency.
The project has been designed based on the Delhi class of ships and fed with all
the data of this ship. The database has been made in MS Access. It can display all the
essential details in case of fire or flood at the click of a mouse. The operator can remotely
perform actions like crash stop ventilation, sound an alarm etc
This system has a large number of advantages such as instant compartment
indication, easy data access; instant instructions to the fire fighters, LAN based remote
control etc.
The project can be further extended to control gas tight integrity of ships
remotely.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
1. CONTENTS
Bibliography
Appendices
AFSM Software Version 1.00 Source Code
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Introduction
1. The purpose of Automated Firefighting System is to quickly detect and prompt the
fire in its incipient stage to enable its control as early as possible, thus saving
extensive damage. In a conventional Fire Alarm System onboard a ship fire in a
compartment is sensed by the fire sensors located in the compartments. These give
signals in the form of glowing LED’s against the compartment number. The further
actions rest with the operator who has to go through the Kill Cards to initiate the
necessary actions. This leads to considerable amount of time loss.
2. The application we have developed is a strap on system that can be directly interfaced
to the existing fire detection system onboard. The input from the fire sensors is given
as input to the Data Acquisition modules. These Data Acquisition modules feed the
digital signals to a computer operating on real time platform viz QNX via RS 232
protocol. The system incorporates features in which the operator gets an instant
indication of the area of fire. The operator can further take actions like sounding an
alarm, crash stop ventilation etc. even the kill cards of all compartments are at his
disposal on a click of mouse.
4. The purpose of Automatic Fire and flood Detection System is to detect the fire
and flood in its incipient stage to enable its control using local fire extinguishers located
nearby, thus saving extensive damage due to fire. A conventional Fire Alarm System
onboard a ship basically consists of the following:
An alarm is generated by the detectors/sensors, which actuated due to fire and thus
generates an audio visual alarm on the Main Control Panel. The system also consists of
various optional Auxiliary Equipment and Accessories such as Repeater Control Panels,
Zonal Local Control Panels, Mimic Panes, Manual Call Points, and Response Indicators.
Electronic Hooters, Electronic Hooters with Flasher Unit etc., including various
accessories such as detector mounting boxes, shock mounts, equipment fixing hardware
etc. for installation of various system components. All the equipment such as Control
Panels, Fire detectors, and Auxiliary equipment are interconnected by means of Electrical
Wiring.
5. The project has been designed based on the Delhi class of ship and fed with all the
data accordingly. The operator gets an instant indication of the compartment in which the
fire takes place. It can display all the essential details of the concerned compartment at
the click of a mouse. It provides recommendations to the operator regarding actions to be
taken. The operator can remotely perform actions like crash stop ventilation, sound an
alarm etc. Further more the system can also be controlled/viewed remotely from a remote
location over the ships existing internal network.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
2
Overview
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
1. The objective of the project undertaken by our syndicate was to integrate and design a
flood management system with the present fire fighting mate system which is
reliable, fast and required minimum re-engineering when installing onboard ships
2. Our first step was evaluation of the problem and finding a suitable platform to
develop the system keeping in mind the equipments deployed in the field.
3. We also had to study the compatibility of the data Acquisition module with the
environment so that present and future needs could be met.
5. Next we had to study the hardware control with the environment. We started with the
black box concept in which we used two PC’s to communicate with each other via the
hardware. For the initial checks we used both the PC’s on windows platform. We then
graduated to communication with QNX as one of the platform, windows being the
other. Finally we established communication with both PC’s working on QNX
platforms.
6. Once the hardware compatibility was achieved with the QNX environment we had to
develop a Human-Machine Interface Application. We worked in the Integrated
Development Environment and used Photon Application Builder for the same.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
The services provided by an RTOS make many computing problems easier to solve,
particularly when multiple activities compete for a system’s resources. Consider, for
instance, a system where users expect immediate response to input. With an RTOS, a
developer can guarantee that operations initiated by the user will execute in preference to
other system activities, unless a more important activity must execute first.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
For most GPOSs, the OS kernel is not preemptible. Consequently, a high-priority user
thread can never preempt a kernel call, but must instead wait for the entire call to
complete – even if the call was invoked by the lowest-priority process in the system.
In an RTOS, on the other hand, kernel operations are preemptible.
Fig 2.1
2.2.4 OS customization
An RTOS based on a microkernel design can make the job of OS customization
fundamentally easier to achieve. In a microkernel RTOS, only a small core of
fundamental OS services (such as signals, timers, and scheduling) reside in the kernel
itself. All other components (such as drivers, file systems, protocol stacks, and
applications) run outside the kernel as separate, memory-protected processes (Figure
2.1). As a result, developing custom drivers and other application-specific OS
extensions does not require specialized kernel debuggers.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
2. Some environments call for more rigorous resource management and scheduling than
others. Realtime applications, for instance, depend on the OS to handle multiple
events and to ensure that the system responds to those events within predictable time
limits.
3. QNX is ideal for embedded realtime applications. It can be scaled to very small sizes
and provides multitasking, threads, priority-driven preemptive scheduling, and fast
context-switching—all essential ingredients of an embedded realtime system.
Moreover, QNX delivers these capabilities with a POSIX-standard API; there’s no
need to forgo standards in order to achieve a small OS.
4. QNX is also remarkably flexible. It can customize the OS to meet the needs of their
applications. From a “bare-bones” configuration of a microkernel with a few small
modules to a full-blown network-wide system equipped to serve hundreds of users,
QNX lets us set up our system to use only those resources we require to tackle the job
at hand.
5. QNX achieves its unique degree of efficiency, modularity, and simplicity through two
fundamental principles:
• microkernel architecture
• message-based interprocess communication
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
3
Hardware Description
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
4055
4520
4051
As in figure we used three ADAM 4051, one ADAM 4055 and one ADAM 4520
modules. After getting the signal from the fire detection sensor, Data acquisition module
sends the signal to the console panel which houses the system software.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
3.1.4 Console
Any terminal that can output and ASCII format over either RS 232 or RS 485 can be
connected as a console. When only RS 232 is available, an ADAM RS 232/485
Converter is required to transform the signals to the correct RS 485 protocol.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
console
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
To avoid communication conflicts when several devices try to send data at the same
time, all actions are instigated by the console. The basic form is a command/response
protocol with the console initiating the sequence. When modules are not transmitting
they are in listen mode. The console issues a command to a module with a specified
address and waits a certain amount of time for the module to respond. If no response
arrives, a timeout aborts the sequence and returns control to the console.
ADAM modules can connect to and communicate with all computers and terminals.
They use RS-485 transmission standards, and communicate with ASCII format
commands. The command set for every module type consists of approximately ten
different commands. The command set for input modules is larger because it
incorporates alarm functions. All communications to and from the module are
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
3.1.9 Applications
Four smoke detectors are suitable for installation within the closed spaces. The
quantity of detectors is based on the individual requirement. These detectors give an
alarm when pre determined level of smoke density is reached within the detector
chamber head. The signal on the MCP is given by rise in detector current from 20
micro amps. approx. to 15 to 20 milli-amp., when the detector actuates. These
detectors are more sensitive to smaller particles of smoke. They respond much ‘faster
for smoke particle size between 10 microns and .01 microns. They are also more
sensitive for flaming fires.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Photoelectric smoke detectors are suitable for installation within the closed spaces.
The quantity of detectors is based on the individual requirement. These detectors give
an alarm when predetermined level of smoke density is reached within the detector
head. Fire Alarm on the panel is given by change in current from 35 micro amps. to
15 milli amps, when actuated. These detectors are more sensitive to larger particles of
smoke. They typically respond to smoke particle sizes above 1 micron approx. They
respond much faster to smoldering fire.
The photoelectric detector comprises of an infrared LED light source and silicon
photo diode used as ‘receiving’ element. Normally, the receiving element receives no
light from the pulsating light source. When smoke enters the detector, the light is
scattered on to the receiving element. This element then determines the amount of
smoke in the detector head by measuring the amount of scattered light it receives. If
the amount of scattered light exceeds a certain preset level for a number of successive
pulses, a fire signal is transmitted. This method greatly reduces the incidences of false
alarms.
UV Flame detectors are suitable for installation within the closed spaces. The
quantity of detectors is based on the individual requirement. These detectors give an
alarm when it receives ultra violet light radiated by a flame for pre-determined time.
The signal on the panel is given by change in current from approximately 200 micro
amps. to 20 milli amp when actuated.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Ultra violet Flame detectors have a UV-tron, which monitors the minute ultra violet
light contained in flames. The detector employs a ‘counter’ circuit to overcome
unwanted triggering, due to .cosmic radiation or lighting. The UV-tron tube consists
of anode and cathode which are positioned face to face’. The tube is filled with
‘argon’ gas. A high voltage is applied between the two electrodes. With sufficient
radiation of UV rays from the flame, the cathode of UV-tron emits photo electrons in
large quantity. When the current flowing through the tube sufficiently increases due
to “avalanche” of electrons, UV-tron repeatedly produces short pulses. The electronic
circuit analyses these pulses and gives an alarm when predetermined number of
pulses are counted in unit time. It is essential to have “line of sight’ between the
flame and the detector, for the detector to give an alarm.
When fire is noticed by persons available in the vicinity of the fire, the call point
nearest to the site of fire can be actuated manually by breaking the glass with the help
of hammer attached to it. Actuation of the call point initiates an alarm on the MCP.
An alarm is created on the MOP by change in current from ‘no current’ to 15
milliAmp. Current when actuated. The call points are installed in parallel to the fire
detectors in the same loop.
When the glass of the manual call point is broken, the push button, which s kept
depressed by the glass, is pushed forward (comes-out), As the push button is spring
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
loaded, it immediately pushes the switch out. With this action, ‘red LED’ on the call
point glows, indicating initiation of alarm on the MCP.
2.6.7.1 Use of Electronic hooter is to give an external alarm within the zone of fire, in
the event of fire. The Electronic hooter receives 24V DC supply from the MCP, when
an alarm is initiated in respective zone by fire detector or manual call point.
The audio alarm units are stand-alone, self oscillating type hooters which work on 24
supplies received from fire alarm control panel. Electronic hooter consists of an
oscillator circuit, amplifier circuit and a loud speaker all assembled into a suitable
housing.
When Hooter receives 24 VDC from the Main Control Panel, oscillator circuit
produces pulsed waveform oscillations. This waveform is modulated by a modulator
circuit on the PCB, due to which siren type audio alarm is heard through the speaker.
-
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
This detector contains two sampling ionization chambers – outer and inner. While
smoke or invisible gases can infiltrate the outer chamber easily, the inner chamber is
considered to be ‘virtually’ closed. Both the chambers are ionized by a small
Americium 241 radio-active source and very small current flows in the chamber
circuit.
The presence of visible smoke or invisible gases alters the current flow in the outer
chamber and causes a change in the voltage ratio between the two chambers. This
difference is then amplified by the electronic circuitry and transmitted to the fire
alarm control unit to which it is connected. The compartment simulator which houses
the smoke sensor is shown in figure.
The operator console is more or less a PC which works on QNX platform and houses the
application software. The Data Acquisition Module is connected to the console through
Fig 3.5 Compartment Simulator
the RS-232 protocol i.e. COM1.
In case of fire in any compartment, software will get the signal from the Data Acquisition
module and consequently the red indication will be shown on the console panel. The
console panel operator can take the necessary actions just by clicking the mouse.
INS Valsura
Fig 3.6ASFM
ASFM Console
Console
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
5 is ADAM – 4055. it is used for giving output to the 4 relays based on the input it gets
from ADAM – 4520.
6, 7 and 8 are ADAM – 4051. Each has 16 I/O lines and are connected to each of the
groups I, II and III of the application. Line DI6 of module 7 is connected to the
compartment simulator. Whenever fire is simulated in the simulator it sets the DI6 line
high.
9 is ADAM – 4520. It is RS 232/RS 485 converter. It accepts inputs from the console in
RS 232 format and converts in RS 485 format and distributes to the other ADAM
modules in the network.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
10 is the operator console. It operates on QNX platform and the application runs on it.
11 is the power supply unit. 3 power supply units are used one each for ADAM modules,
relays and the compartment simulator.
12 is the compartment simulator. It houses the smoke sensors. It is used for simulating
fire.
13 and 14 are the lights and alarm units used as indication to represent fire.
12 11
13 14
PS PS PS
Light Hooter +
_
Fan 1 Fan 2
1 2 3 4
10
Gnd
5 9
DI6
Data +
Data - Vs
Dgnd
6 7 8
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
4
Software Version 1.00 Flow
chart
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Change color
indication to
Is any bit =1
Green and display
‘NORMAL’
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Start
Loop runs every 100ms
Change color
indication to
Is the bit =1 Green against the
assigned
compartment
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Start
Change color
Is the line high? indication to
Green
Stop
The above program will switch on the alarm. Alarm and Ventilation fans can be
switched ON/OFF in a similar way by changing the code to be sent. (See appendices)
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
5
Potential and Outlook
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
The aim of the project has been to develop a reliable fire fighting and flood
management system for use onboard Indian Naval Ships. This ASFM system also
provides the users of this system with all the useful data in case of an emergency scenario
instantaneously and also provides the user at a remote position with the controls required
to take effective and decisive action immediately.
The future scope of this project is multi fold.
Firstly, it could be actually implemented in its existing form onboard Indian
Naval Ships. This project has been designed for the Delhi Class of ships. Also since the
system has been designed as a strap on system it could be implemented without any
major changes to the ship or the existing set up on the ship.
Secondly, this ASFM system could be implemented on a touch screen. This
would make the system a little more expensive but it would save on the time required by
the user to react in case an emergency arises. It would also eliminate the need for a
keyboard and a mouse and the overall operation of the system become more user
friendly.
And finally, once all these additional units get incorporated into the ASFM
system, the system will be performing many operations simultaneously. In such a
scenario various tasks could be assigned priorities over the others e.g actions for certain
important compartments could be given higher priority etc. Thus scheduling could be
incorporated in the system to give priorities to certain processes. This would make the
system more reliable.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
5.2 Conclusion
The platform that we used for the project is one of the latest platforms on which
most of the latest weapon systems and modern equipment are based. We have used it
because of the many advantages it offers including reliability, stability, future
compatibility, faster speed among other things.
We have achieved the aim of constructing an ASFM system which is capable of
being installed onboard ships with the least amount of re- engineering involved. And this
system will greatly enhance the fire fighting capability of the ships.
For the construction of this project we have relied on in-house components which
have been salvaged from the spares present in the Faculty of Training Projects. This has
reduced the financial implication of our project to a great extent. But there has been a
great amount of hardware issues that had to be sorted out so as to get the ADAM Module
to interact with the system working on a QNX platform and also for the transfer of data
from the sensors and fan to the ADAM Module.
The prototype version of the software created by us also includes a test module to
detect and alert the user in case of any know defects. This software also facilitates the
control of the system over a network.
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Bibliography
1. http://www.qnx.com
2. http://www.advantech.com
3. ADAM-4000 User’s manual
4. IDE Users guide
5. Photon microGUI Programmer's Guide
6. http://www.google.com
7. http://www.openqnx.com
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Appendix A
ADAM-4051
• Channel: 16 (4-channel/group)
• Optical Isolation: 2500 VDC
• Opto-isolator response time: 25 .s
• Over-voltage Protect: 70 VDC
• ESD (Electro Static Discharge): 2000 VDC
• LED Indicator: On: Active; Off: Non-active
• Input Voltage: Logic level 1: 10 ~ 50 V
Logic level 0: 3 V
• Power consumption: 1W
• I/O Connector Type: 13-pin plug-terminal*2
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
ADAM-4055
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
/* Standard headers */
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <hw/inout.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/neutrino.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
int
rd( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
int fd;
int numRead=0;
int a1[6];
int i=0; /* counter */
int j=1; /* counter */
int flag =0;
int a2[6];
int d[16]; /* store the BCD vslues */
int x;
int z;
char b[7]={NULL};
char b1[7]={NULL}; /* buffer to store input */
char wr[]={"$026\r"}; /* buffer to store code to write to com1
*/
PtWidget_t *this_window;
/* open com1 */
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
while(fd!=-1)
{
memset(b1, 0, sizeof(b1));
i=0;
while (i<6)
{
if (a1[i]==48)
a2[i]=0;
else
if (a1[i]==49)
a2[i]=1;
else
if (a1[i]==50)
a2[i]=2;
else
if (a1[i]==51)
a2[i]=3;
else
if (a1[i]==52)
a2[i]=4;
else
if (a1[i]==53)
a2[i]=5;
else
if (a1[i]==54)
a2[i]=6;
else
if (a1[i]==55)
a2[i]=7;
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
else
if (a1[i]==56)
a2[i]=8;
else
if (a1[i]==57)
a2[i]=9;
else
if (a1[i]==65)
a2[i]=10;
else
if (a1[i]==66)
a2[i]=11;
else
if (a1[i]==67)
a2[i]=12;
else
if (a1[i]==68)
a2[i]=13;
else
if (a1[i]==69)
a2[i]=14;
else
if (a1[i]==70)
a2[i]=15;
i++;
z=x%2;
x=x/2;
d[i]=z;
}
x= a2[1];
for (i=4 ;i<8 ;i++)
{
z=x%2;
x=x/2;
d[i]=z;
if (flag==1)
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
x= a2[2];
for (i=8 ;i<12 ;i++)
{
z=x%2;
x=x/2;
d[i]=z;
if (d[i] == 1)
{
flag=1;
}
}
if (flag==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_ind2 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
flag=0;
x= a2[3];
for (i=12 ;i<16 ;i++)
{
z=x%2;
x=x/2;
d[i]=z;
if (d[i] == 1)
{
flag=1;
}
}
if (flag==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_ind1 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
flag=0;
for(i=0;i<16;i++)
{
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
if (d[i] == 1)
{
flag=1;
}
}
if (flag==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_clr3 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
PtSetResource(
ApGetWidgetPtr( this_window, ABN_list ),
Pt_ARG_TEXT_STRING, "FIRE", 0);
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_clr3 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
PtSetResource(
ApGetWidgetPtr( this_window, ABN_list ),
Pt_ARG_TEXT_STRING, "NORMAL", 0);
}
/* close com1 */
close(fd);
return 0;
return( Pt_CONTINUE );
}
}
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
/* Standard headers */
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <hw/inout.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/neutrino.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
int
rd_gp1( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
int fd;
int numRead=0;
int a1[6];
int i=0; /* counter */
int j=1; /* counter */
int flag =0;
int a2[6];
int d[16]; /* store the BCD vslues */
int x;
int z;
char b[7]={NULL};
char b1[7]={NULL}; /* buffer to store input */
char wr[]={"$026\r"}; /* buffer to store code to write to com1
*/
PtWidget_t *this_window;
/* open com1 */
fd = open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY );
delay(10); /* set delay */
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
while(fd!=-1)
{
memset(b1, 0, sizeof(b1));
i=0;
while (i<6)
{
if (a1[i]==48)
a2[i]=0;
else
if (a1[i]==49)
a2[i]=1;
else
if (a1[i]==50)
a2[i]=2;
else
if (a1[i]==51)
a2[i]=3;
else
if (a1[i]==52)
a2[i]=4;
else
if (a1[i]==53)
a2[i]=5;
else
if (a1[i]==54)
a2[i]=6;
else
if (a1[i]==55)
a2[i]=7;
else
if (a1[i]==56)
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
a2[i]=8;
else
if (a1[i]==57)
a2[i]=9;
else
if (a1[i]==65)
a2[i]=10;
else
if (a1[i]==66)
a2[i]=11;
else
if (a1[i]==67)
a2[i]=12;
else
if (a1[i]==68)
a2[i]=13;
else
if (a1[i]==69)
a2[i]=14;
else
if (a1[i]==70)
a2[i]=15;
i++;
z=x%2;
x=x/2;
d[i]=z;
}
x= a2[1];
for (i=4 ;i<8 ;i++)
{
z=x%2;
x=x/2;
d[i]=z;
}
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_b ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[1]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_d ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_d ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[2]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_d1 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_d1 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[3]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[4]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_b ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_b ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
if (d[5]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_d ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_d ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[6]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_d00 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_d00 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[7]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_dk0 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_dk0 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[8]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_dkd ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_dkd ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[9]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d1 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d1 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[10]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d21 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d21 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[11]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d3 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_3_d3 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[12]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_4_d2 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_4_d2 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[13]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_e ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_1_e ),
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[14]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_e00 ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_2_e00 ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
if (d[15]==1)
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_4_e ),
Pt_ARG_FILL_COLOR, Pg_RED, 0 );
}
else
{
PtSetResource(
ApGetWidgetPtr( this_window, ABN_4_e ),
Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
}
close(fd);
return 0;
return( Pt_CONTINUE );
}
}
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
Switching ON Fan
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
int
alarm_code( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
char buffer[]={"#041400\r"};
int fd;
/* open com1 */
fd=open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY );
/* write #041401\r to com1. This sets the 14th line of 4th module
high. \r is for carriage return */
write(fd, buffer, sizeof(buffer));
/* close com1 */
close (fd);
return 0;
return( Pt_CONTINUE );
INS Valsura
QNX BASED FIRE AND FLOOD MANGEMENT SYSTEM
INS Valsura