ANEXO D CÓDIGO DE LA APLICACIÓN. El contenido de los archivos de código fuente almacenados en el directorio Nodo desconocido es el siguiente:
|
|
- Angel Snow
- 5 years ago
- Views:
Transcription
1 ANEXO D CÓDIGO DE LA APLICACIÓN El contenido de los archivos de código fuente almacenados en el directorio Nodo desconocido es el siguiente: APPLICATIONDEFINITIONS.H #ifndef APPLICATIONDEFINITIONS_H #define APPLICATIONDEFINITIONS_H enum { SEND_INTERVAL_MS = 1000 ; //Interval for sending messages by //unknown node in milliseconds #endif MAKEFILE COMPONENT=SendingMoteAppC include $(MAKERULES) 90
2 MOBILEMESSAGES.H #ifndef MOBILEMESSAGES_H #define MOBILEMESSAGES_H enum { AM_RSSIMSG = 10 ; //AM identifier for communication typedef nx_struct RssiDat { nx_int16_t rssi; nx_int16_t node_id; nx_int16_t floor; nx_int16_t voltage; RssiDat; #endif SENDINGMOTEAPPC.NC #include "MobileMessages.h" configuration SendingMoteAppC { implementation { components ActiveMessageC, MainC; components new AMSenderC(AM_RSSIMSG); components new TimerMilliC() as SendTimer; components LedsC; components SendingMoteC as App; App.Boot -> MainC; App.SendTimer -> SendTimer; App.RssiMsgSend -> AMSenderC; App.RadioControl -> ActiveMessageC; App.Packet -> ActiveMessageC; App.Leds -> LedsC; SENDINGMOTEC.NC 91
3 #include "ApplicationDefinitions.h" #include "MobileMessages.h" module SendingMoteC { uses interface Boot; uses interface Timer<TMilli> as SendTimer; uses interface AMSend as RssiMsgSend; uses interface SplitControl as RadioControl; uses interface Packet; uses interface Leds; implementation { message_t msg; bool busy = FALSE; //Standard message for communication //busy saves the transceiver state ********** Boot Events ********************* event void Boot.booted() { call RadioControl.start(); ********** RadioControl Events ********************* event void RadioControl.startDone(error_t result) { if (result == SUCCESS) { call SendTimer.startPeriodic(SEND_INTERVAL_MS); else { call RadioControl.start(); event void RadioControl.stopDone(error_t result) { ********** Timer Event ********************* event void SendTimer.fired() { if (!busy) { if (call RssiMsgSend.send(AM_BROADCAST_ADDR, &msg, sizeof(rssidat)) == SUCCESS) { call Leds.led0Toggle(); busy = TRUE; ********** RssiMsgSend Event ********************* event void RssiMsgSend.sendDone(message_t *m, error_t error) { if (&msg == m) { call Leds.led0Toggle(); busy = FALSE; 92
4 El contenido de los archivos de código fuente almacenados en el directorio Nodos baliza es el siguiente: RSSIDEMOMESSAGES.H #ifndef RSSIDEMOMESSAGES_H #define RSSIDEMOMESSAGES_H enum { AM_RSSIMSG = 10 ; //AM identifier for communication typedef nx_struct RssiMsg { nx_int16_t rssi; nx_int16_t node_id; nx_int16_t floor; nx_int16_t voltage; RssiMsg; #endif MAKEFILE COMPONENT=GetRssiAppC BUILD_EXTRA_DEPS += GetRssi.class CLEAN_EXTRA = *.class GetRssiMsg.java CFLAGS += -I/usr/lib/gcc/avr/4.1.2/include CFLAGS += -I/usr/avr/include GetRssi.class: $(wildcard *.java) GetRssiMsg.java javac *.java GetRssiMsg.java: mig java -target=null $(CFLAGS) -java-classname=getrssimsg RssiDemoMessages.h RssiMsg -o $@ include $(MAKERULES) GETRSSIAPPC.NC #include "RssiDemoMessages.h" #include "message.h" 93
5 configuration GetRssiAppC { implementation { components new AMReceiverC(AM_RSSIMSG); components new AMSenderC(AM_RSSIMSG); components ActiveMessageC; components LedsC; components MainC; components CC2420ControlC; components GetRssiC as App; components CC2420ActiveMessageC; components new VoltageC(); App.ReadVoltage -> VoltageC; App -> CC2420ActiveMessageC.CC2420Packet; App.Receive -> AMReceiverC; App.AMSend -> AMSenderC; App.Packet -> ActiveMessageC; App.Leds -> LedsC; App.Boot -> MainC; App.AMControl -> ActiveMessageC; App.ReadRssi -> CC2420ControlC.ReadRssi; GETRSSIC.NC #include "RssiDemoMessages.h" module GetRssiC { uses interface Boot; uses interface SplitControl as AMControl; uses interface Receive; uses interface AMSend; uses interface Packet; uses interface Leds; uses interface CC2420Packet; uses interface Read<uint16_t> as ReadRssi; uses interface Read<uint16_t> as ReadVoltage; implementation { ******** Global Variables ****************** message_t pkt; //Standard message for communication bool locked = FALSE; //locked saves the transceiver state static int16_t power[4]; //Array for containing the received power static int16_t powerfloor[4]; //Array for containing the //floor power int16_t averagepower = 0; //it saves the average of the //values in power array int16_t averagepowerfloor = 0; //it saves the average of the //values in powerfloor array int16_t j = 0, i = 0; static int16_t voltagevalue; //Battery level in the node 94
6 int16_t getrssi(message_t *msg); ********** Boot Events ********************* event void Boot.booted() { call AMControl.start(); call Leds.set(7); ********** AMControl Events ***************** event void AMControl.startDone(error_t err) { event void AMControl.stopDone(error_t err) { *************** Receive Events *************************** event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) { if (len == sizeof(rssimsg)) { RssiMsg* load = (RssiMsg*)(call Packet.getPayload(&pkt, sizeof(rssimsg))); call Leds.led0Toggle(); power[i] = getrssi(msg); call ReadRssi.read(); i++; if (i == 4) { call ReadVoltage.read(); atomic { averagepower = (power[0] + power[1] + power[2] + power[3]) / 4; averagepowerfloor = (powerfloor[0] + powerfloor[1] + powerfloor[2] + powerfloor[3]) / 4; load -> rssi = averagepower; load -> node_id = TOS_NODE_ID; load -> floor = averagepowerfloor; load -> voltage = voltagevalue; i = 0; averagepower = 0; averagepowerfloor = 0; if (!locked) { if (call AMSend.send(0, &pkt, sizeof(rssimsg)) == SUCCESS) { locked = TRUE; call Leds.led1Toggle(); return msg; *************** AMSend Events *************************** event void AMSend.sendDone(message_t* message, error_t err) { if (&pkt == message) { locked = FALSE; 95
7 ************ GetRssi Function *************************** int16_t getrssi(message_t *msg) { return (int16_t) call CC2420Packet.getRssi(msg); ************** ReadRssi Events ************************ event void ReadRssi.readDone(error_t result, uint16_t val ) { powerfloor[i] = val; *********** ReadVoltage Events ************************ event void ReadVoltage.readDone(error_t result, uint16_t val) { voltagevalue = val; GETRSSI.JAVA /* * This is a modified version of TestSerial.java, from * apps/tests/testserial * from TinyOS 2.x ( * Localization application using RSSI * Jose Carlos Reyes Guerrero Miguel Villagran Marin December * import java.io.*; import java.util.*; import net.tinyos.message.*; import net.tinyos.packet.*; import net.tinyos.util.*; class Management { * GetDate returns actual time public String GetDate() { Calendar date = Calendar.getInstance(); int hour, minutes, seconds; String time; hour = date.get(calendar.hour_of_day); minutes = date.get(calendar.minute); seconds = date.get(calendar.second); time = hour + ":" + minutes + ":" + seconds; return time; 96
8 * txtfile creates a text file and saves a string into it. * text - the string to be written into the file overwrite - specifies if the text must overwrite * previous text in the file (false) or simply it has to * be added to the file (true) public void txtfile(string text, boolean overwrite) { FileWriter txtfile; String filename = "localization.txt"; boolean option = overwrite; try { txtfile = new FileWriter(fileName, option); txtfile.write(text); txtfile.close(); catch (IOException e) { System.out.println("Failed to open file"); * send executes a linux command * order - command to be executed public void send (string[] order) { Runtime r = Runtime.getRuntime(); Process p = null; String[] bashorder = order; try { p = r.exec(bashorder); catch (Exception e) { System.out.println("Failed to send "); public class GetRssi implements MessageListener { final static int ZONES = 5; //Number of zones in the network final static int NODES = 5; //Number of nodes in the network final int MESAGGES_ = 100; //Number of received messages to //send an alarm final static int CALIBRATION_ = 200; //Number of received //messages to send a calibration final static int MIN_CHANGES = 2; //Minimum number of zone //changes to send a calibration final double NIVEL_BATERIA = 2.7; //Maximum battery level to //send a low battery private MoteIF moteif; Matrix obtained in calibration process * static int calibrationmatrix[][] = {{-81,-68,-16,-69,-85, {-65,-15,-68,-59,-62, {-19,-62,-79,-60,-55, {-50,-72,-79,-77,-20, {-65,-58,-74,-15,-80; static int[] powerarray = new int[nodes]; //powerarray contains //the last power received by each static node 97
9 static int[] comparisonarray = new int[zones]; //The index of its //minimum element indicates the zone where the unknown node is static int previouszone; static int receivedmessages; static int zonechanges; static int messageszones; String command[] = new String[3]; //It specifies the linux //command to be executed public GetRssi(MoteIF moteif) { this.moteif = moteif; this.moteif.registerlistener(new GetRssiMsg(), this); public void messagereceived(int to, Message message) { double batteryvolts; int min; int actualzone = 1; String sentence; String hour; int[][] subtractarray = new int[zones][nodes]; Management document = new Management(); GetRssiMsg msg = (GetRssiMsg) message; receivedmessages++; if (msg.get_node_id()!= 0) { //If the message is not from //the unknown node powerarray[msg.get_node_id() - 1] = msg.get_rssi(); for (int i = 0; i < ZONES; i++) { for (int j = 0; j < NODES; j++) { subtractarray[i][j] = powerarray[j] calibrationmatrix[i][j]; for (int m = 0; m < ZONES; m++) { for (int n = 0; n < NODES; n++) { comparisonarray[m] += subtractarray[m][n] * subtractarray[m][n]; min = comparisonarray[0]; for (int g = 0; g < ZONES; g++) { if (min >= comparisonarray[g]) { min = comparisonarray[g]; actualzone = g + 1; if ((actualzone == previouszone) && (receivedmessages >= MESAGGES_ )) { hour = document.getdate(); sentence = "ZONE: " + actualzone + "\t" + hour + "\n"; document.txtfile(sentence, true); command[0] = "sh"; command[1] = "-c"; command[2] = "cat localization.txt mailx -s WSN_ALARM direcciondestino@gmail.com"; document.send (command); receivedmessages = 0; else if (actualzone!= previouszone) { 98
10 hour = document.getdate(); sentence = "ZONE: " + actualzone + "\t" + hour + "\n"; document.txtfile(sentence, false); receivedmessages = 0; System.out.println("You are in ZONE: " + actualzone + "\t" + receivedmessages); Arrays.fill(comparisonArray, 0); batteryvolts = (double)((1.223 * 1024)/(msg.get_voltage())); if (batteryvolts <= NIVEL_BATERIA) { command[0] = "sh"; command[1] = "-c"; command[2] = "echo NODE " + msg.get_node_id() + " HAS LOW BATTERY" + " mailx -s BATTERY_ALARM direcciondestino@gmail.com"; document.send (command); messageszones++; if (actualzone!= previouszone) { zonechanges++; if ((zonechanges >= MIN_CHANGES) && (messageszones <= CALIBRATION_ )) { command[0] = "sh"; command[1] = "-c"; command[2] = "echo NEW CALIBRATION IS REQUIRED" + " mailx -s CALIBRATION_ALARM direcciondestino@gmail.com"; document.send (command); zonechanges = 0; messageszones = 0; if (messageszones >= CALIBRATION_ ) { zonechanges = 0; messageszones = 0; previouszone = actualzone; private static void usage() { System.err.println("usage: GetRssi [-comm <source>]"); public static void main(string[] args) throws Exception { String source = null; if (args.length == 2) { if (!args[0].equals("-comm")) { usage(); System.exit(1); source = args[1]; else if (args.length!= 0) { usage(); System.exit(1); PhoenixSource phoenix; 99
11 if (source == null) { phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); else { phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); MoteIF mif = new MoteIF(phoenix); GetRssi serial = new GetRssi(mif); Por último, se muestra a continuación el archivo GetRssi.java necesario en el proceso de calibración: GETRSSI.JAVA /* * This is a modified version of TestSerial.java, from * apps/tests/testserial * from TinyOS 2.x ( * This code shows received power by all nodes to calibrate * the environment * Jose Carlos Reyes Guerrero Miguel Villagran Marin December * import java.io.ioexception; import java.lang.math; import net.tinyos.message.*; import net.tinyos.packet.*; import net.tinyos.util.*; public class GetRssi implements MessageListener { final static int NODES = 5; //Number of nodes in the network final static int SAMPLES = 10; //Number of samples to calculate //the average of the received power final static int MAX_MESSAGES = 100; //Maximum received messages //to stop the calibration process private static int receivedmessages; //Total number of messages //received private static int samplednodes; //Number of nodes whose average //received power has been calculated private static int[] arraypower = new int[nodes]; //arraypower //contains the total amount of received power by each node private static int[] nodemessages = new int[nodes]; //nodemessages //contains the number of messages received from each node 100
12 private static int[] calibration = new int[nodes]; //calibration //array for the room private MoteIF moteif; public GetRssi(MoteIF moteif) { this.moteif = moteif; this.moteif.registerlistener(new GetRssiMsg(), this); public void messagereceived(int to, Message message) { double rssi_dbm; //power received by static nodes in dbm double rssi_mw; double floor_dbm; double floor_mw; //floor power received by //static nodes in milliwats double power_dbm; //the net received power double power_mw; GetRssiMsg msg = (GetRssiMsg) message; rssi_dbm = (double)(msg.get_rssi()) - 45; //obtain power[dbm] //= obtain power - 45 floor_dbm = (double)(-msg.get_floor()) - 45; floor_mw = Math.pow(10, floor_dbm / 10); rssi_mw = Math.pow(10, rssi_dbm / 10); power_mw = rssi_mw - floor_mw; power_dbm = 10 * Math.log10(power_mW); if (msg.get_node_id()!= 0) { //if it is not a message from //the unknown node arraypower[msg.get_node_id()-1] += power_dbm; nodemessages[msg.get_node_id()-1]++; receivedmessages++; if (nodemessages[msg.get_node_id()-1] == SAMPLES) { calibration[msg.get_node_id()-1] = arraypower[msg.get_node_id()-1] / SAMPLES; samplednodes++; if (samplednodes == NODES) { //if all the nodes //have been sampled System.out.print("vector de calibracion: [ "); for (int j : calibration) System.out.print(j + " "); System.out.println("]"); else if (receivedmessages >= MAX_MESSAGES) { //if no power //is received from any node for (int i = 0; i < NODES; i++) { if (calibration[i] == 0) calibration[i] = -90; System.out.print("vector de calibracion: [ "); for (int j : calibration) System.out.print(j + " "); System.out.println("]"); private static void usage() { System.err.println("usage: GetRssi [-comm <source>]"); public static void main(string[] args) throws Exception { 101
13 String source = null; if (args.length == 2) { if (!args[0].equals("-comm")) { usage(); System.exit(1); source = args[1]; else if (args.length!= 0) { usage(); System.exit(1); PhoenixSource phoenix; if (source == null) { phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); else { phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); MoteIF mif = new MoteIF(phoenix); GetRssi serial = new GetRssi(mif); El código fuente almacenado en el directorio BaseStation no se muestra ya que está disponible en el sistema operativo TinyOS. 102
Wireless Systems Laboratory 4 November 2013
Wireless Systems Laboratory 4 November 2013 A. Cammarano, A.Capossele, D. Spenza Contacts Cammarano: Capossele: Spenza: cammarano@di.uniroma1.it capossele@di.uniroma1.it spenza@di.uniroma1.it Tel: 06-49918430
More informationPolitecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM (and Cooja)
Politecnico di Milano Advanced Network Technologies Laboratory Internet of Things TinyOS Programming and TOSSIM (and Cooja) 20 April 2015 Agenda o Playing with TinyOS n Programming and components n Blink
More informationPolitecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM
Politecnico di Milano Advanced Network Technologies Laboratory Internet of Things TinyOS Programming and TOSSIM 11 April 2011 Agenda Playing with TinyOS Programming and components Blink Application Using
More informationTinyOS Lesson 6 Topology Control
TinyOS Lesson 6 Topology Control Object To learn how to adjust the power level when sending the data, and retrieve the RSSI and LQI values from the receiver. Use the program named RssiSend to transmit
More informationPolitecnico di Milano Advanced Network Technologies Laboratory. Internet of Things. TinyOS Programming and TOSSIM (and Cooja)
Politecnico di Milano Advanced Network Technologies Laboratory Internet of Things TinyOS Programming and TOSSIM (and Cooja) 19 March 2018 Agenda Playing with TinyOS Programming and components Blink Application
More informationPolitecnico di Milano Advanced Network Technologies Laboratory. TinyOS
Politecnico di Milano Advanced Network Technologies Laboratory TinyOS Politecnico di Milano Advanced Network Technologies Laboratory A Bit of Context on WSNs Technology, Applications and Sensor Nodes WSN
More informationInternship at Sentilla. Chris Merlin March 08 - June 08
Internship at Sentilla Chris Merlin March 08 - June 08 Overview The Sentilla Co. and The Product The smallest platform to carry a JVM Particularities of Coding in Java Application Engineering Sentilla
More informationMobile and Ubiquitous Computing TinyOS application example. Niki Trigoni
Mobile and Ubiquitous Computing TinyOS application example Niki Trigoni www.dcs.bbk.ac.uk/~niki niki@dcs.bbk.ac.uk Application Consider an application with the following functionality: The gateway node
More informationComplete Network Embedded System
Wireless Embedded Systems and Networking Foundations of IP-based Ubiquitous Sensor Networks TinyOS 2.0 Design and Application Services David E. Culler University of California, Berkeley Arch Rock Corp.
More informationEnabling Networked Sensors
Politecnico di Milano Advanced Network Technologies Laboratory Enabling Networked Sensors A Primer on TinyOS Ing. Matteo Cesana Office: DEI 3 Floor Room 335 Email: cesana@elet.polimi.it Phone: 0223993695
More informationIntroduction to TinyOS
Fakultät Informatik Institut für Systemarchitektur Professur Rechnernetze Introduction to TinyOS Jianjun Wen 21.04.2016 Outline Hardware Platforms Introduction to TinyOS Environment Setup Project of This
More informationTiming ListOperations
Timing ListOperations Michael Brockway November 13, 2017 These slides are to give you a quick start with timing operations in Java and with making sensible use of the command-line. Java on a command-line
More informationWSN Programming. Introduction. Olaf Landsiedel
WSN Programming Introduction Olaf Landsiedel Programming WSNs What do we need to write software for WSNs? (or: for any system, like your laptop, cell phone?) Programming language With compiler, etc. OS
More informationWSN Programming. Introduction. Olaf Landsiedel. Programming WSNs. ! What do we need to write software for WSNs?! Programming language
WSN Programming Introduction Lecture 2 Olaf Landsiedel Programming WSNs! What do we need to write software for WSNs?! Programming language " With compiler, etc.! OS / runtime libraries " Access to system
More informationINDOOR LOCALIZATION IN WIRELESS SENSOR NETWORK USING FINGERPRINTING METHOD
UNIVERSITÀ DEGLI STUDI DI PADOVA Facoltà di Ingegneria Corso di Laurea Magistrale in Ingegneria delle Telecomunicazioni Tesi di Laurea INDOOR LOCALIZATION IN WIRELESS SENSOR NETWORK USING FINGERPRINTING
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Published: December 23, 2013, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationJAVA EXAMPLES - SOLVING DEADLOCK
JAVA EXAMPLES - SOLVING DEADLOCK http://www.tutorialspoint.com/javaexamples/thread_deadlock.htm Copyright tutorialspoint.com Problem Description: How to solve deadlock using thread? Solution: Following
More informationPASS4TEST IT 인증시험덤프전문사이트
PASS4TEST IT 인증시험덤프전문사이트 http://www.pass4test.net 일년동안무료업데이트 Exam : 1z0-809 Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-809 Exam's Question and Answers 1 from
More informationWireless Sensor Networks
Wireless Sensor Networks Interface Lecturer: Junseok KIM http://usn.konkuk.ac.kr/~jskim Blink Example If a uses a interface, it can call the interface s commands and must implement handlers for the interface
More informationi219 Software Design Methodology 8. Dynamic modeling 1 Kazuhiro Ogata (JAIST) Outline of lecture
i219 Software Design Methodology 8. Dynamic modeling 1 Kazuhiro Ogata (JAIST) Outline of lecture 2 Use case Use case diagram State (machine) diagram Sequence diagram Class diagram of vending machine Vending
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: September 17, 2012, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationGetting started with Java
Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationProgramming with the SCA BB Service Configuration API
CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: November 8, 2010, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration
More informationTinyOS 2.x. Hongwei Zhang
TinyOS 2.x Hongwei Zhang http://www.cs.wayne.edu/~hzhang Adapted from the IPSN 09 tutorial by Stephen Dawson-Haggerty, Omprakash Gnawali, David Gay, Philip Levis, Răzvan Musăloiu-E., Kevin Klues, and John
More information16-Dec-10. Consider the following method:
Boaz Kantor Introduction to Computer Science IDC Herzliya Exception is a class. Java comes with many, we can write our own. The Exception objects, along with some Java-specific structures, allow us to
More informationInput-Output and Exception Handling
Software and Programming I Input-Output and Exception Handling Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Outline Reading and writing text files Exceptions The try block catch and finally
More informationApéndice A. Código fuente de aplicación desarrollada para probar. implementación de IPv6
Apéndice A Código fuente de aplicación desarrollada para probar implementación de IPv6 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.net.*; import java.util.enumeration;
More information1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean
Practice Final Quiz 1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean 2 If you wanted to divide two numbers precisely, which
More informationA sample print out is: is is -11 key entered was: w
Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void
More informationTinyOS Tutorial. Greg Hackmann CSE 521S Fall 2010
TinyOS Tutorial Greg Hackmann CSE 521S Fall 2010 Outline Installing TinyOS and Building Your First App Hardware Primer Basic nesc Syntax Advanced nesc Syntax Network Communication Sensor Data Acquisition
More informationPropedéutico de Programación
Propedéutico de Programación Coordinación de Ciencias Computacionales Semana 4, Segunda Parte Dra. Pilar Gómez Gil Versión 1. 24.06.08 http://ccc.inaoep.mx/~pgomez/cursos/programacion/ Chapter 3 ADT Unsorted
More informationInput from Files. Buffered Reader
Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads
More informationPRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES
PRÁCTICO 1: MODELOS ESTÁTICOS INGENIERÍA INVERSA DIAGRAMAS DE CLASES Una parte importante dentro del proceso de re-ingeniería de un sistema es la ingeniería inversa del mismo, es decir, la obtención de
More information2018/2/5 话费券企业客户接入文档 语雀
1 2 2 1 2 1 1 138999999999 2 1 2 https:lark.alipay.com/kaidi.hwf/hsz6gg/ppesyh#2.4-%e4%bc%81%e4%b8%9a%e5%ae%a2%e6%88%b7%e6%8e%a5%e6%94%b6%e5%85%85%e5 1/8 2 1 3 static IAcsClient client = null; public static
More informationCOE318 Lecture Notes Week 10 (Nov 7, 2011)
COE318 Software Systems Lecture Notes: Week 10 1 of 5 COE318 Lecture Notes Week 10 (Nov 7, 2011) Topics More about exceptions References Head First Java: Chapter 11 (Risky Behavior) The Java Tutorial:
More informationVendor: Oracle. Exam Code: 1Z Exam Name: Java SE 8 Programmer. Version: Demo
Vendor: Oracle Exam Code: 1Z0-808 Exam Name: Java SE 8 Programmer Version: Demo DEMO QUESTION 1 Which of the following data types will allow the following code snippet to compile? A. long B. double C.
More informationBirkbeck (University of London) Software and Programming 1 In-class Test Mar 2018
Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment
More informationFDK API Manual for Java. FDK API Manual for Java. June FN Pricing
FDK API Manual for Java June 2015 FN Pricing Contents Overview... 1 System Environments... 1 Installation files... 1 Runtime Environments... 1 Sample codes... 1 CCallFdk... 8 static void Initialize(String
More informationpublic static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));
Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:
More information/* Copyright 2012 Robert C. Ilardi
/ Copyright 2012 Robert C. Ilardi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
More informationI gave this assignment in my Internet and Intranet Protocols and Applications course:
Producing Production Quality Software Lecture 1b: Examples of Bad Code Prof. Arthur P. Goldberg Fall, 2004 Summary I show some examples of bad code and discuss how they fail to meet the Software Quality
More informationUsing CSP to Model and Analyze TinyOS Applications
2009 16th Annual IEEE International Conference and Workshop on the Engineering of Computer Based Systems Using CSP to Model and Analyze TinyOS Applications Allan I. McInnes Electrical and Computer Engineering
More informationCrash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++
Crash Course in Java Netprog: Java Intro 1 Why Java? Network Programming in Java is very different than in C/C++ much more language support error handling no pointers! (garbage collection) Threads are
More informationInternet Technology 2/7/2013
Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server
More informationJava Networking (sockets)
Java Networking (sockets) Rui Moreira Links: http://java.sun.com/docs/books/tutorial/networking/toc.html#sockets http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets_p.html Networking Computers
More informationJava in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure.
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
More informationCS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide
CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092
More informationCN208 Introduction to Computer Programming
CN208 Introduction to Computer Programming Lecture #11 Streams (Continued) Pimarn Apipattanamontre Email: pimarn@pimarn.com 1 The Object Class The Object class is the direct or indirect superclass of every
More informationSNMP traps (simple network management protocol)
SNMP traps (simple network management protocol) Nasser M. Abbasi Nov 25, 2000 page compiled on June 29, 2015 at 3:16am Contents 1 Processing on SNMP messages 2 2 Parsing an SNMP v1 UDP pkt 3 3 Program
More information1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to
More informationExceptions and Working with Files
Exceptions and Working with Files Creating your own Exceptions. You have a Party class that creates parties. It contains two fields, the name of the host and the number of guests. But you don t want to
More informationAssignment 1. Due date February 6, 2007 at 11pm. It must be submitted using submit command.
Assignment 1 Due date February 6, 2007 at 11pm. It must be submitted using submit command. Note: submit 4213 a1 . Read the manpages ("man submit") for more details on the submit command. It is
More informationChapter 2 Applications and
Chapter 2 Applications and Layered Architectures Sockets Socket API API (Application Programming Interface) Provides a standard set of functions that can be called by applications Berkeley UNIX Sockets
More informationCSPP : Introduction to Object-Oriented Programming
CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text
More informationName:... ID:... class A { public A() { System.out.println( "The default constructor of A is invoked"); } }
KSU/CCIS/CS CSC 113 Final exam - Fall 12-13 Time allowed: 3:00 Name:... ID:... EXECRICE 1 (15 marks) 1.1 Write the output of the following program. Output (6 Marks): class A public A() System.out.println(
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationExample Program. public class ComputeArea {
COMMENTS While most people think of computer programs as a tool for telling computers what to do, programs are actually much more than that. Computer programs are written in human readable language for
More informationJava Exception. Wang Yang
Java Exception Wang Yang wyang@njnet.edu.cn Last Chapter Review A Notion of Exception Java Exceptions Exception Handling How to Use Exception User-defined Exceptions Last Chapter Review Last Chapter Review
More informationC16b: Exception Handling
CISC 3120 C16b: Exception Handling Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/28/2018 CUNY Brooklyn College 1 Outline Exceptions Catch and handle exceptions (try/catch)
More informationLab 1 : Java Sockets
Lab 1 : Java Sockets 1. Goals In this lab you will work with a low-level mechanism for distributed communication. You will discover that Java sockets do not provide: - location transparency - naming transparency
More informationAP Computer Science A
AP Computer Science A 2nd Quarter Notes Table of Contents - section links - Click on the date or topic below to jump to that section Date: 11/9/2017 Aim: Binary Numbers (lesson 14) Number Systems Date:
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More information*Java has included a feature that simplifies the creation of
Java has included a feature that simplifies the creation of methods that need to take a variable number of arguments. This feature is called as varargs (short for variable-length arguments). A method that
More informationRecitation: Loop Jul 7, 2008
Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for
More informationA Virtual Machine-Based Programming Environment for Rapid Sensor Application Development
A Virtual Machine-Based Programming Environment for Rapid Sensor Application Development Jui-Nan Lin and Jiun-Long Huang Department of Computer Science National Chiao Tung University Hsinchu, Taiwan, ROC
More informationLearning the Java Language. 2.1 Object-Oriented Programming
Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states
More informationICU 58 SpoofChecker API Changes
ICU 58 SpoofChecker API Changes This is a proposal for changes to the SpoofChecker API in Java and C++. The changes are intended to reflect the most recent version of UTS 39. SpoofChecker API Changes,
More information830512@itri.org.tw import java.net.socket; import java.net.serversocket; import java.io.ioexception; /* ---------- Java Server ---------- */ public class Nets static Socket thesocket; static ServerThread
More informationI/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O
I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationFollowing is the general form of a typical decision making structure found in most of the programming languages:
Decision Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined
More informationExceptions Handling Errors using Exceptions
Java Programming in Java Exceptions Handling Errors using Exceptions Exceptions Exception = Exceptional Event Exceptions are: objects, derived from java.lang.throwable. Throwable Objects: Errors (Java
More informationHomework 3 Huffman Coding. Due Thursday October 11
Homework 3 Huffman Coding Due Thursday October 11 Huffman Coding Implement Huffman Encoding and Decoding and the classes shown on the following slides. You will also need to use Java s stack class HuffmanEncode
More informationText User Interfaces. Keyboard IO plus
Text User Interfaces Keyboard IO plus User Interface and Model Model: objects that solve problem at hand. User interface: interacts with user getting input from user giving output to user reporting on
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming
COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network
More informationPROGRAMACIÓN ORIENTADA A OBJETOS
PROGRAMACIÓN ORIENTADA A OBJETOS TEMA8: Excepciones y Entrada/Salida Manel Guerrero Tipos de Excepciones Checked Exception: The classes that extend Throwable class except RuntimeException and Error are
More informationIT 313 Advanced Application Development Midterm Exam
Page 1 of 9 February 12, 2019 IT 313 Advanced Application Development Midterm Exam Name Part A. Multiple Choice Questions. Circle the letter of the correct answer for each question. Optional: supply a
More informationCSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7. Question 1. (2 points) What is the difference between a stream and a file?
CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7 Question 1. (2 points) What is the difference between a stream and a file? A stream is an abstraction representing the flow of data from one place to
More informationCSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name
CSC 1051 Algorithms and Data Structures I Final Examination May 12, 2017 Name Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces provided.
More information1. An operation in which an overall value is computed incrementally, often using a loop.
Practice Exam 2 Part I: Vocabulary (10 points) Write the terms defined by the statements below. 1. An operation in which an overall value is computed incrementally, often using a loop. 2. The < (less than)
More informationJAVA - FILE CLASS. The File object represents the actual file/directory on the disk. Below given is the list of constructors to create a File object
http://www.tutorialspoint.com/java/java_file_class.htm JAVA - FILE CLASS Copyright tutorialspoint.com Java File class represents the files and directory pathnames in an abstract manner. This class is used
More informationSistemas Distribuídos com Redes de Sensores. Noemi Rodriguez
2012 TinyOS SO para motes com recursos limitados aplicação única bateria deve ter vida longa memória muito limitada Exemplo: micaz Atmel ATmega128: microcontrolador de 8 bits 4K memória RAM 128K memória
More informationCompSci 125 Lecture 02
Assignments CompSci 125 Lecture 02 Java and Java Programming with Eclipse! Homework:! http://coen.boisestate.edu/jconrad/compsci-125-homework! hw1 due Jan 28 (MW), 29 (TuTh)! Programming:! http://coen.boisestate.edu/jconrad/cs125-programming-assignments!
More information#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;
1. Short answer questions: (a) Compare the typical contents of a module s header file to the contents of a module s implementation file. Which of these files defines the interface between a module and
More informationCSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus
CSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment implements a collection of distributed Java Space servers, which exercises
More information7.17: Here is a typical Java solution:
7.17: Here is a typical Java solution: A job queue (of an operating system) is implemented as a two-way linked list. New items are added to the rear of the queue and old items are removed from the front
More informationLecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8
Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How
More informationIntroduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/
Introduction to Java https://sites.google.com/site/niharranjanroy/ 1 The Java Programming Language According to sun Microsystems java is a 1. Simple 2. Object Oriented 3. Distributed 4. Multithreaded 5.
More informationCS 340 Homework Alternative 6. Due 11:59 PM Wednesday December 12
CS 340 Homework Alternative 6 Due 11:59 PM Wednesday December 12 Alternative Homework 6 Implement the Dijkstra class and the BinaryHeap class shown on the following slide. The Dijkstra class already includes
More informationInternet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 2004
Internet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 00 Summary I show some examples of bad code and discuss how they fail to meet the Software Quality
More informationpublic static boolean isoutside(int min, int max, int value)
See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static
More informationProgrammi di utilità
Programmi di utilità La classe SystemData per il calcolo dei tempi e della occupazione di memoria Per calcolare i tempi e la occupazione di memoria è necessario interagire con il sistema operativo, questo
More informationFull file at
Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as
More informationMenu Driven Systems. While loops, menus and the switch statement. Mairead Meagher Dr. Siobhán Drohan. Produced by:
Menu Driven Systems While loops, menus and the switch statement Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list while loops recap
More informationName EID. (calc (parse '{+ {with {x {+ 5 5}} {with {y {- x 3}} {+ y y} } } z } ) )
CS 345 Spring 2010 Midterm Exam Name EID 1. [4 Points] Circle the binding instances in the following expression: (calc (parse '+ with x + 5 5 with y - x 3 + y y z ) ) 2. [7 Points] Using the following
More information(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between
More informationCOMP 110 Programming Exercise: Simulation of the Game of Craps
COMP 110 Programming Exercise: Simulation of the Game of Craps Craps is a game of chance played by rolling two dice for a series of rolls and placing bets on the outcomes. The background on probability,
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More information