Encyclopedia Knowledge

January 24, 2007

[asterisk] Asterisk Internal Architecture Overview

Filed under: VOIP News — encyclopedia @ 1:22 am

Asterisk Internal Architecture Overview

This page tries to present an overview of the Asterisk core.

The information here is based on my study of the Asterisk source at a point (May 2005) where I was a relative newcomer to Asterisk, and needed this information in order to program a new channel driver. Corrections and additions welcome!

Channels

Call processing in Asterisk is centered around channel drivers. Many channel drivers are included with Asterisk in the channels/ subdirectory; other channel drivers are available separately. Channel drivers handle all the protocol-specific details of ISDN, SIP, and other telephony protocols and interface them to Asterisk.
Some channel drivers (like chan_local and chan_agent) work as “proxy channels” and do not directly interface to real protocols or hardware.

A channel driver is a shared object (.so) file that is loaded dynamically into Asterisk as a module. Modules are usually loaded automatically from modules.conf, but may also be loaded/unloaded explicitly from the CLI with the load and unload commands. Use show channeltypes to list all loaded channel drivers.

A channel driver must export the functions load_module(), unload_module(), usecount(), description(), and key(). Since Asterisk applications are also modules, the example skeleton application in apps/app_skel.c may be useful to get started with channel drivers.

The main task of the module part of the channel driver is to have the load_module() entry point call ast_channel_register() with a pointer to its struct ast_channel_tech. This is what makes the channel driver available in Asterisk.

Channel Technology Descriptor

The struct ast_channel_tech is the channel technology descriptor and defines the complete behaviour of the channel driver. It includes

  • The type name used to reference the channel (eg. `SIP’); this is used as the part before the slash in Dial(SIP/xxx).
  • Textual description.
  • Set of audio formats supported (ULAW, GSM, …).
  • Callback functions called by Asterisk to initiate and manage calls to and from the channel.

The requester callback is used to reserve a single channel from the driver (some channels like an E1 PRI interface has a limited number of channels available). It calls ast_channel_alloc() to allocate a new struct ast_channel and returns it. It also fills in the tech_pvt field with a pointer to a channel private structure that holds driver-specific data. All other operations on the channel reference the struct ast_channel. The requester callback does not block waiting for I/O. Called by ast_request().

The call callback initiates outgoing calls on the channel. It may block on I/O waiting to get the call established, but it does not wait for the remote end to answer (that is indicated by returning an AST_CONTROL_ANSWER control frame from the read callback). Called by ast_call().

The main call processing happens in the read and write callbacks. A channel does not have a specific OS thread associated with it (though a driver is free to create one for it if necessary). Instead the driver registers one or more file descriptors in the fds field of struct ast_channel. When data becomes available on any of the file descriptors, the read callback is called (via ast_read() to read the data and return an appropriate frame. This includes incoming audio data, but also control frames indicating things like remote answer or hangup; see frame.h for possible frame types. The driver may also inject frames outside of the read callback using ast_queue_frame() or ast_queue_control() (this may require calling ast_channel_alloc(1) to reserve an “alert pipe” if not using zaptel(?)). The write callback is called periodically by Asterisk (via ast_write()) to pass outgoing voice frames to the channel.

Getting things moving

The is no central “main loop” or kernel thread in Asterisk. Instead, processing is distributed among a number of threads, mainly of two kinds:

  • Dialplan threads, started by ast_pbx_start() to run a single instance/session of the dial plan. Such a thread may control multiple active channels at once, for example when forwarding a call with the Dial or Queue applications.
  • Channel driver monitor threads. Most channel drivers have a single monitor thread that listens for incoming calls. When a call arrives it is passed to ast_pbx_start() to start executing the dialplan.

When a thread is in control of one or more active channels, it must continously call ast_read() and ast_write() on these channels to keep the voice and control frames flowing. Again, there is no central loop in the code where this happens, instead custom read/write loops are used in each instance as appropriate. For example wait_for_answer() in the Dial application, ast_generic_bridge in channel.c to connect two channels during a conversation, and ast_waitstream() in file.c. The ast_waitfor*() family of functions are used in these loops to wait until input is available on a channel, at which point ast_read() is called on that channel (maybe passing the data on to ast_write() on another channel).

Conclusion

The overall flow of control in Asterisk is as follows:

  • Channel drivers monitor threads listen for incoming calls and starts dialplan threads for each new call with ast_pbx_start().
  • Dialplan threads run applications as specified by the dialplan.
  • Application commands process voice and control frames in processing loops alternating calls to ast_waitfor*() and ast_read()/ast_write(); and initiate new outgoing calls with ast_request() and ast_call().

January 23, 2007

[asterisk] Channels in Asterisk

Filed under: VOIP News — encyclopedia @ 8:27 am

Implementing a Channel ======================
* What is a channel?
A channel is a unit which brings in a call to the Asterisk PBX.  A channel could be connected to a real telephone (like the Internet Phone Jack) or to a logical call (like an Internet phone call).  Asterisk makes no distinction between “FXO” and “FXS” style channels (that is, it doesn’t distinguish between telephone lines and telephones).
Every call is placed or received on a distinct channel.  Asterisk uses a channel driver (typically named chan_xxx.so) to support each type of hardware.
* What do I need to create a channel?
In order to support a new piece of hardware you need to write a channel driver.  The easiest way to do so is to look at an existing channel driver and model your own code after it.
* What’s the general architecture?
Typically, a channel reads a configuration file on startup which tells it something about the hardware it’s going to be servicing.  Then, it launches a thread which monitors all the idle channels (See the chan_modem or the chan_ixj for an example of this).  When a “RING” or equivalent is detected, the monitoring thread should allocate a channel structure and assign all the callbacks to it (see ixj_new, for example), and then call ast_pbx_start on that channel.  ast_pbx_start will launch a new thread to handle the channel as long as the call is up, so once pbx_start has successfully been run, the monitor should no longer monitor that channel. The PBX thread will use the channel, reading, writing, calling, etc., and multiplexing that channel with others using select() on the channel’s file descriptor (if your channel doesn’t have an associated file descriptor, you’ll need to emulate one somehow, perhaps along the lines of what the translator API does with its channel.
When the PBX is finished with the line, it will hang up the line, at which point it the hardware should again be monitored by the monitoring thread.
————— For more information, please consult the Asterisk Developer’s Documentation on http://www.asterisk.org

[jap] Dictionary & kanji stroke

Filed under: Japanese(日本語) — encyclopedia @ 4:05 am

http://japanese.about.com/blkod_rs.htm

http://www.saiga-jp.com/kanji_dictionary.html

http://www.rikai.com/perl/KanjiMap.pl?kanji=%BE%AD

tudiennhatviet.com/

http://www.thejapanesepage.com/kanji/index.php

January 17, 2007

[tourism] Ho Chi Minh City

Filed under: Travel Tips — encyclopedia @ 2:50 pm

http://travel.nytimes.com/2005/04/24/travel/24going.html?ex=1169182800&en=2a1773534540aed3&ei=5070

Saigon kitsch on display.
By MATT GROSS
Published: April 24, 2005

Why Go Now

Skip to next paragraph

Enlarge This Image

The New York Times

Map of Ho Chi Minh City. Numbers in the article correspond to numbers on the map.

Correction: May 1, 2005, Sunday: A map on April 24 with the “Going To” column, about Ho Chi Minh City, misspelled the term for Street in three instances. It is Duong, not Doung.

Because 30 years after the end of the Vietnam War, Ho Chi Minh City (formerly Saigon) is finally growing up. With a prettified, gentrifying downtown, an array of international hotels and now direct flights from the United States via United, it has never been easier to visit. What’s more – and this may shock anyone who was mobbed by postcard vendors or stalked by optimistic cyclo drivers back in the mid-90’s – there has been an overall relaxing of the city’s aggressively capitalist nature.

Which is not to say that Saigon – as everyone from your maître d’hôtel to your moto driver calls it – has slowed down. Compared with the stately elegance of Hanoi’s French colonial streets and cafes, this city of six million remains brasher, more outgoing, more energetic – a New York City to Hanoi’s Washington. Eating, drinking and shopping are not just primary pastimes but full-time pursuits, and the streets are packed with 100 cc Hondas ferrying housewives and hip teens alike from cafe to market to nightclub. The constant noise and activity, plus frothy, hard-to-identify smells (grilled pork chops? diesel exhaust? durian?), can overwhelm even the residents, but just think to yourself: It’s like Manhattan with mopeds. And like New York, the city offers the chance to get lost in the bustle, and to emerge from it with your own personal map of the best back-alley banh mi sandwiches, the most secluded rooftop swimming pools and the perfect glass of iced coffee.

Where to Stay

Central Ho Chi Minh City has been fully colonized by luxury hotels – among them the riverfront Legend Hotel Saigon, (1) 2A-4A Duong Ton Duc Thang, District 1, (84-8) 823-3333; www. legendsaigon.com, and the pale yellow Colonial-style Park

Hyatt (2) (www.park.hyatt.com), which is set to open this summer – all fighting for space with the survivors of the city’s earlier incarnations as both Pearl of the Orient and combat headquarters: the Rex Hotel, (3) 141 Duong Nguyen Hue, D. 1, (84-8) 829-2185, www.rexhotelvietnam.com, the former war correspondents’ hangout, which is expanding to occupy an entire city block, and the Hotel Majestic, (4) 1 Duong Dong Khoi, D. 1, (84-8) 829-5517, www.majesticsaigon.com.vn, which has managed to hold onto a brand of Graham Greene-era glamour that once attracted guests like François Mitterrand and Catherine Deneuve. Prices for double occupancy start at $120 at the Legend (river view for $130); $80 at the Rex and $77 at the Majestic.

No one has yet transformed an old French villa into a bed-and-breakfast, but the out-of-the-way Saigon Boutique Hotel, (5) 57 Duong Pham Viet Chanh, D. 1, saigonboutiquehotel.com, (84-8) 833-0540, is trying hard to live up to its name. Not all rooms have windows, and the lobby Wi-Fi didn’t work when I was there, but the cost of a room starts at a relative bargain $20 a night. And friendly, understanding employees, along with breakfast (yogurt, fresh passion fruit juice, airy baguettes) on the top-floor garden patio, make up for those kinks.

(Rates do not include tax and are subject to change based on season and availability.)

Where to Eat

Food is everywhere in Saigon, and the street is the place to eat well – if you know how. Quan An Ngon, (6) 138 Duong Nam Ky Khoi Nghia, D.1, (84-8) 825-7179, is a good first-night stop to acquaint yourself with curbside delicacies. A kind of prototypical Spice Market, Ngon serves restaurant-quality renditions of street food, from rice porridge with fried eel to banh xeo, a rice-flour crepe stuffed with pork, bean sprouts and shrimp – and you can watch it all being made at the open-air stalls.

But Saigonese know when to leave the street for dinner. One sign of the city’s increasing sophistication is the low-key success of Thuan Tuan, (7) 67-71 Duong Hoang Sa, Dakao Ward, D. 1, (84-8) 910-1080, a multilevel restaurant facing a cleaned-up canal and serving spécialités méchouis – roast leg of lamb, French onion soup, Russian salad and couscous- to a 99 percent Vietnamese clientele. Likewise, weekends find office parties and families alike cramming the Hoa Vien Brauhaus, (8) 28 bis Duong Mac Dinh Chi, D. 1, (84-8) 829-0585, www

.hoavener.com, a brass-and-burnished-wood Czech brewpub where you can order both a sausage-and-cheese platter and cha gio (fried spring rolls), not to mention four-liter beakers of the homemade pilsner.

The classiest meal in town, however, is still at Le Bordeaux, (9) F7-F8, Duong D2, Binh Thanh District, (84-8) 899-9831, a decade-old temple of French gastronomy that remains the best (but by no means the only) place to gorge yourself on foie gras, scallop ravioli and Norwegian salmon, and spend upwards of $50 a person, without wine.

For dessert on a sultry night, there’s only one choice: Fanny Ice Cream, (10) 29-31 Duong Ton That Thiep, (84-8) 821-1633, makes fine classic flavors as well as only-in-Vietnam scoops like custard apple, durian and young rice.

What to Do During the Day

Soon after the sun rises, tropical heat and motorbike smog descend upon the city – minor inconveniences for office workers ensconced in air-conditioned towers, but a pressing dilemma for visitors. Seek refuge at Spa Tropic, (11) 187B Duong Hai Ba Trung, D. 3, (84-8) 822-8895, spatropic.com, a Zenned-out renovated villa redolent of spicy lemongrass, or rise above the chaos at the rooftop swimming pools at the Diamond

Plaza, (12) 34 Duong Le Duan, 14th floor, (84-8) 825-7750, or the Sofitel, (13) 17 Duong Le Duan, 18th floor, (84-8) 824-1555, sofitel.com. The former is quieter and has the better view, from the tree-shrouded Reunification Hall (formerly Ngo Dinh Diem’s Presidential Palace) to the gray haze that encircles the city. But at the Sofitel you can order a glass of Sancerre or head downstairs for power yoga.

Art lovers won’t find a developed scene like Hanoi’s, but the Duc Minh Private Museum, (14) 31C Duong Le Quy Don, D. 3, (84-8) 933-0498,and the Apricot Gallery, (15) 5052 Duong Mac Thi Buoi, D. 1, (84-8) 822-7962, apricot-artvietnam.com, showcase established figures like Bui Xuan Phai and Le Thiet Cuong as well as up-and-comers like Nguyen Nguyen and Dang Xuan Hoa. The city’s other museums are forgoable, but the War Remnants Museum, 16 28 Duong Vo Van Tan, D. 3, (84-8) 930-6325, never fails to provoke conflicted feelings. The exhibits of wartime photography and propaganda are moving into a somber new gray-slate building, scheduled to open this month at the same site.

How to Get Around

No one walks, cyclos are slow, and motorbike taxis, though ubiquitous and swift, are a pain if you’ve got more than two. But full-size taxis are not only cheap (generally starting at 75 cents, no ride in District 1 should top $3.20) but air-conditioned. Vinasun, (84-8) 827-2727, and Saigon Taxi, (84-8) 823-2323, offer the most comfortable rides.

Skip to next paragraph

Chang W. Lee/The New York Times

A plane at the War Remnants Museum, which houses weapons, artifacts and photographs from the Vietnam War.

What to Do at Night

When the sun drops, the city really wakes up. Start with cocktails at Level 23, (17) the Sheraton’s top-floor bar, 88 Duong Dong Khoi, D. 1, (84-8) 827 2828, whose view of a neon-lighted panorama is worth the first-world tab. Before you hit the clubs and bars, visit the city’s best venue for live music, Yoko, (18) 22A Duong Nguyen Thi Dieu Street, D. 3, (84-8) 933-0577, a relaxed hangout for cosmopolitan youth, where local jazz singers croon Clapton and bands like the all-girl Passion rock out on Pretenders covers.

For the raw experience of a Saigon club, there’s Truong Mua Rung, (19) a k a Rain Forest Disco, 5-15 Duong Ho Huan Nghiep, D. 1; (84-8) 825-7783. Expect MTV-educated dancers, bottle service and uncritically exuberant tunes. Next month a new club is set to be added to the mix: Lush (20) (2 Duong Ly Tu Trong, D. 1), a New York ready, anime-themed club run by the San Franciscan owner of the sleek, sweaty, gay-friendly Lost in Saigon, (21) 169 Duong Pham Ngu Lao, D. 1, (84-8) 837-5185.

Where to Shop

The clutter of T-shirts, fake Rolex watches and pork shoulder at big markets like Ben Thanh will madden all save the hard core, and the fashion shops on Dong Khoi, long the city’s high-end strip, give new meaning to the oft-heard local phrase “same-same.”

But a handful of individualists on Ton That Thiep deserve your hard-earned dong. The fanciest is Gaya, (22) 39 Duong Ton That Thiep, D. 1, (84-8) 914-3769, gaya

vietnam.com, which stocks the retro-Deco furniture and lamps of Quasar Khanh and the elegant couture of the French-Cambodian Romyda Keth. Sô Cô La, (23) 45 Duong Ton That Thiep, D. 1, (84-8) 823-1279, is Gaya’s girly alternative, full of cheap handbags and skirts in bright orange, red and pink. Dogma Gallery, (24) 43 Duong Ton That Thiep, D. 1, (84-8) 821-8272, specializes in propaganda posters – one declares, “The American Invaders and their puppets will suffer the Fate of those who went before” – available in reproductions on canvas, or on T-shirts and coffee mugs.

Hip Vietnamese, meanwhile, head to boutique-lined Duong Nguyen Trai, at the heart of which is Zen Plaza, (25) 54-56 Duong Nguyen Trai, D. 1, (84-8) 925-0339, zenplaza

.com. The ground-floor shop in this gaudy mall has flirty, ruffled dresses from designers like Trong Nguyen and Thanh Long. Men, unfortunately, will find little to get excited about unless they adore Pierre Cardin; the fashion-forward should plan a day trip to Bangkok.

Your First Time or 10th

The mosque (26) on Duong Dong Du, in the heart of the city, is another peaceful refuge, and it serves a great lunch: Malaysian-style curries (beef, fish, goat, veggie) along with fragrant yellow rice, spicy potatoes, green beans and rôti. Wash it down with a glass of iced tea, have a sweet, tiny banana for dessert and plan on becoming a regular; 66 Duong Dong Du, D. 1, (84-8) 823-2159.

Where to Stay Wired

While Internet cafes abound in practically every alleyway, most are grungy, few wireless. Bambu Cafe, (27) 96 Duong Nam Ky Khoi Nghia, (84-8) 827-9984, however, is cute enough for young Japanese tourists, with inexpensive set lunches and possibly the only functioning Wi-Fi in District 1.

How to Get There

Though no airline has nonstop flights to Ho Chi Minh City from the United States, most major airlines offer single- or multiple-stop flights, with a code share. (United is the only U.S. airline that can fly its own planes into Vietnam.) As of mid-April, American, Continental, Northwest and United offered single-stop weekend departures for late May, with fares from about $1,000.

[stock] Du doan gia ca chung khoan

Filed under: Stock Market — encyclopedia @ 5:04 am

http://www.pcworld.com.vn/pcworld/magazine_a.asp?t=mzdetail&atcl_id=5f5e5d5e565a56

Người chơi chứng khoán luôn muốn dự báo giá cả chứng khoán trong tương lai, với xác suất là bao nhiêu thì giá cổ phiếu sẽ tăng với mức XXX %. Cũng có nhu cầu tương tự đối với tỷ giá USD, EURO hay giá của mặt hàng nào đó. Nói chung là dự báo xu hướng của giá và khả năng (xác suất) của từng xu hướng. Bạn có thể sử dụng trực giác hoặc kinh nghiệm để phán đoán tuy nhiên để lượng hoá một cách cụ thể và có cơ sở khoa học bạn cần lập cơ sở dữ liệu và hàm tính toán, ở đây tôi đề xuất dùng MS Excel vì phần mềm này có các hàm tính xác suất và thống kê rất tuyệt.

PHƯƠNG PHÁP LUẬN

Cơ sở phương pháp luận ở đây chính là lý thuyết về quá trình Wiener được trình bày trong cuốn “Nguyên lý tài chính kế toán của thị trường chứng khoán” (NXB Chính trị Quốc gia, năm 2000) của tác giả Vương Hoàng Quân và Ngô Phương Chí.

Giả sử giá cả tuân theo quy luật chuẩn thì vận động của nó theo thời gian là một quá trình Wiener bao gồm 2 thành phần: một thành phần theo quán tính và một thành phần ngẫu nhiên. Đặc điểm của thành phần ngẫu nhiên, gọi là z, là mỗi khi nó chuyển động tới một giá trị nhất định nó sẽ còn quay trở lại giá trị đó nhiều lần trong bất kỳ một khoảng thời gian xác lập nào.

Sự vận động của giá theo quá trình Wiener trong khoảng thời gian T được biểu diễn bằng công thức sau:

St

Giá ở thời gian t

So

Giá ở thời gian o

μ

Trung bình của “naturelogarithm” (Ln) trong khoảng thời gian T

σ

Phương sai của “naturelogarithm” (Ln) trong khoảng thời gian T

z

Đại lượng ngẫu nhiên

Giá cả kỳ vọng sau thời gian T là:

Phương sai của giá cả sau thời gian T là:

a) Xu hướng tăng giá (St>Y)

Ta muốn xác định xác suất để bất đẳng thức St>Y luôn đúng

(N là viết tắt của hàm phân bổ xác suất luỹ kế chuẩn hoá)

Để xác định kỳ vọng giá cổ phiếu với điều kiện ràng buộc là giá cổ phiếu St>Y. Trước hết định nghĩa đại lượng q như sau:

mà St>Y

nên

Tức là

b) Xu hướng giảm giá (St

Lập luận tương tự:

Với

TẠO HÀM

a) Dữ liệu

Bạn tạo 1 cơ sở dữ liệu gồm 4 trường như trong hình, từ A2:D11.

• Trường thứ nhất là mô tả các mốc thời gian mà tại đó thông tin giá cả được thu thập, sắp xếp theo thứ tự tăng dần, mức tăng (timeStep) là như nhau.

• Trường thứ hai là giá cả theo từng mốc thời gian. Nếu các mốc thời gian không tăng theo quy luật timeStep thì bạn phải nội suy để đảm bảo tính chính xác.

• Trường thứ ba là giá cả tại mốc thời gian sau chia cho giá cả mốc trước, ví dụ C3=B3/B2

• Trường thứ tư là naturelogarithm của trường thứ ba

(Dữ liệu càng chi tiết thì dự báo càng chính xác)

b) Các hàm

Bạn tạo một module trong một workbook rồi nhập tại mục khai báo:

Option Explicit

Const exp = 2.71828182845904

Sau đó bạn tạo các hàm sau:

1. Function NotConsistentTimeStep(ByRef timeRange As Range, timeStep As Long) As Boolean

Hàm này để kiểm tra các mốc thời gian có tăng theo quy luật timeStep không, tham số mRange chính là cơ sở dữ liệu của chúng ta từ A2:D11, tham số timeStep là mức tăng của các mốc thời gian.

Public Function NotConsistentTimeStep (ByRef timeRange As Range, timeStep As Long) As Boolean

On Error GoTo loi:

Dim i As Long

For i = 2 To timeRange.Rows.Count

If timeRange.Cells(i, 1).Value – timeRange.Cells(i – 1, 1).Value <> timeStep Then

NotConsistentTimeStep = True

Exit Function

End If

Next i

NotConsistentTimeStep = False

Exit Function

loi:

NotConsistentTimeStep = True

End Function

2. Function ProbaLow (mRange As Range, X_val As Double, forcast As Long, timeStep As Long) As Double

Hàm này trả về xác suất với điều kiện giá cả sau forcast ngày nữa kể từ mốc thời gian cuối cùng sẽ nhỏ hơn X_val. Trở về -3 nếu mRange có số cột khác 4; -2 nếu forcast <=0; -1 nếu các mốc thời gian tăng không theo quy luật timeStep.

Public Function ProbaLow(mRange As Range, X_val As Double, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double Trung binh cua cot ln(Pt/Pt-1)

Dim ln_std As Double do lech chuan cua cot ln(Pt/Pt-1)

Dim t_Range As Range tham chieu toi CSDL thoi gian

Dim ln_Range As Range tham chieu cot CSDL ln(Pt/Pt-1)

Dim t_forcast As Double Quy doi forcast theo chieu dai cua cot thoi gian

Dim So As Double Gia ca tai moc thoi gian cuoi cung

Dim a As Double Tinh trung gian

Dim ret As Double Gia tri tro ve cua ham

If mRange.Columns.Count <> 4 Then

ProbaLow = -3

Exit Function

End If

If forcast <= 0 Then

ProbaLow = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

ProbaLow = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

a = -(Application.WorksheetFunction.Ln(So / X_val) + ln_ave * t_forcast) / ln_std * t_forcast ^ (1 / 2)

ret = Application.WorksheetFunction.NormSDist(a)

ProbaLow = ret

End Function

3.Function AverageLow(mRange As Range, X_val As Double, forcast As Long, timeStep As Long) As Double

Hàm này trả về trung bình của giá với điều kiện giá cả sau forcast ngày nữa kể từ mốc thời gian cuối cùng sẽ nhỏ hơn X_val. Trở về -3 nếu mRange có số cột khác 4; -2 nếu forcast <=0; -1 nếu các mốc thời gian tăng không theo quy luật timeStep.

Public Function AverageLow(mRange As Range, X_val As Double, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double Trung binh cua cot ln(Pt/Pt-1)

Dim ln_std As Double do lech chuan cua cot ln(Pt/Pt-1)

Dim t_Range As Range tham chieu toi CSDL thoi gian

Dim ln_Range As Range tham chieu cot CSDL ln(Pt/Pt-1)

Dim t_forcast As Double Quy doi forcast theo chieu dai cua cot thoi gian

Dim So As Double Gia ca tai ngay cuoi cung tai Cot thoi gian

Dim a As Double Gia tri tro ve cua ham

Dim ret As Double

If mRange.Columns.Count <> 4 Then

AverageLow = -3

Exit Function

End If

If forcast <= 0 Then

AverageLow = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

AverageLow = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

a = ((Application.WorksheetFunction.Ln(So / X_val) + ln_ave * t_forcast) / ln_std * t_forcast ^ (1 / 2)) + ln_std * t_forcast ^ (1 / 2)

ret = So * exp ^ (t_forcast * (ln_ave + (ln_std ^ 2) / 2))

ret = ret * (1 – Application.WorksheetFunction.NormSDist(a))

ret = ret / Application.WorksheetFunction.NormSDist(-a + ln_std * t_forcast ^ (1 / 2))

AverageLow = ret

End Function

4. Function ProbaHight(mRange As Range, Y_val As Double, forcast As Long, timeStep As Long) As Double

Hàm này trả về xác suất với điều kiện giá cả sau forcast ngày nữa kể từ mốc thời gian cuối cùng sẽ lớn hơn Y_val. Trở về -3 nếu mRange có số cột khác 4;-2 nếu forcast <=0; -1 nếu các mốc thời gian tăng không theo quy luật timeStep.

Public Function ProbaHight(mRange As Range, Y_val As Double, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double Trung binh cua cot ln(Pt/Pt-1)

Dim ln_std As Double do lech chuan cua cot ln(Pt/Pt-1)

Dim t_Range As Range tham chieu toi CSDL thoi gian

Dim ln_Range As Range tham chieu cot CSDL ln(Pt/Pt-1)

Dim t_forcast As Double Quy doi forcast theo chieu dai cua cot thoi gian

Dim So As Double Gia ca tai ngay cuoi cung tai Cot thoi gian

Dim a As Double

Dim ret As Double

If mRange.Columns.Count <> 4 Then

ProbaHight = -3

Exit Function

End If

If forcast <= 0 Then

ProbaHight = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

ProbaHight = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

a = -(Application.WorksheetFunction.Ln(So / Y_val) + ln_ave * t_forcast) / ln_std * t_forcast ^ (1 / 2)

ret = 1 – Application.WorksheetFunction.NormSDist(a)

ProbaHight = ret

End Function

5. Function AverageHight(mRange As Range, Y_val As Double, forcast As Long, timeStep As Long) As Double

Hàm này trả về trung bình của giá với điều kiện giá cả sau forcast ngày nữa kể từ mốc thời gian cuối cùng sẽ lớn hơn Y_val. Trở về -3 nếu mRange có số cột khác 4; -2 nếu forcast <=0; -1 nếu các mốc thời gian tăng không theo quy luật timeStep.

Public Function AverageHight(mRange As Range, Y_val As Double, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double Trung binh cua cot ln(Pt/Pt-1)

Dim ln_std As Double do lech chuan cua cot ln(Pt/Pt-1)

Dim t_Range As Range tham chieu toi CSDL thoi gian

Dim ln_Range As Range

Dim t_forcast As Double

Dim So As Double

Dim a As Double

Dim ret As Double

If mRange.Columns.Count <> 4 Then

AverageHight = -3

Exit Function

End If

If forcast <= 0 Then

AverageHight = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

AverageHight = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

a = ((Application.WorksheetFunction.Ln(So / Y_val) + ln_ave * t_forcast) / ln_std * t_forcast ^ (1 / 2)) + ln_std * t_forcast ^ (1 / 2)

ret = So * exp ^ (t_forcast * (ln_ave + (ln_std ^ 2) / 2))

ret = ret * Application.WorksheetFunction.NormSDist(a)

ret = ret / (1 – Application.WorksheetFunction.NormSDist(-a + ln_std * t_forcast ^ (1 / 2)))

AverageHight = ret

End Function

6. Function AverageValue(mRange As Range, forcast As Long, timeStep As Long) As Double

Hàm này trả về trung bình của giá sau forcast ngày nữa kể từ mốc thời gian cuối cùng. Trở về -3 nếu mRange có số cột khác 4;-2 nếu forcast <=0-1 nếu các mốc thời gian tăng không theo quy luật timeStep.

Public Function AverageValue(mRange As Range, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double

Dim ln_std As Double

Dim t_Range As Range

Dim ln_Range As Range

Dim t_forcast As Double

Dim So As Double

Dim a As Double

Dim ret As Double

If mRange.Columns.Count <> 4 Then

AverageValue = -3

Exit Function

End If

If forcast <= 0 Then

AverageValue = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

AverageValue = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

ret = So * exp ^ (t_forcast * (ln_ave + (ln_std ^ 2) / 2))

AverageValue = ret

End Function

7. Function StDevValue(mRange As Range, forcast As Long, timeStep As Long) As Double

Hàm này trả về độ lệch chuẩn của giá sau forcast ngày nữa kể từ mốc thời gian cuối cùng. Trở về -3 nếu mRange có số cột khác 4;-2 nếu forcast <=0; -1 nếu trường thời gian tăng không theo quy luật timeStep.

Public Function StDevValue(mRange As Range, forcast As Long, timeStep As Long) As Double

Dim ln_ave As Double

Dim ln_std As Double

Dim t_Range As Range

Dim ln_Range As Range

Dim t_forcast As Double

Dim So As Double

Dim a As Double

Dim ret As Double Tro ve phuong sai

If mRange.Columns.Count <> 4 Then

StDevValue = -3

Exit Function

End If

If forcast <= 0 Then

StDevValue = -2

Exit Function

End If

Dim mRow As Long

mRow = mRange.Rows.Count

Set t_Range = mRange.Range(Cells(1, 1), Cells(mRow, 1))

If NotConsistentTimeStep(t_Range, timeStep) Then

StDevValue = -1

Exit Function

End If

Set ln_Range = mRange.Range(Cells(2, 4), Cells(mRow, 4))

So = mRange.Cells(mRow, 2).Value

ln_ave = Application.WorksheetFunction.Average(ln_Range)

ln_std = Application.WorksheetFunction.StDev(ln_Range)

t_forcast = forcast / (t_Range.Cells(mRow, 1).Value – t_Range.Cells(1, 1).Value)

ret = So * exp ^ (2 * t_forcast * (ln_ave + (ln_std ^ 2) / 2))

ret = ret * exp ^ (t_forcast * ln_std ^ 2)

StDevValue = ret ^ (1 / 2)

End Function

Sử dụng

Trong ví dụ minh hoạ có cơ sở dữ liệu từ A2:D11, tham số forcast tại ô D12 là 120, tham số timeStep tại ô D13 là 30 thì sau 120 ngày kể từ ngày 29/08/05 (ô A11):

• Giá trị trung bình của giá tại ô D14 có công thức =AverageValue($A$2:$D$11;$D$12;$D$13)

• Độ lệch chuẩn của giá tại ô D15 có công thức =StDevValue(A2:D11;D12;D13)

• Dự đoán cho mức giá 12.100 như tại ô A18:

- Công thức xác suất P(Pt<12.100) tại B18 =ProbaLow($A$2:$D$11;A18;$D$12;$D$13);

- Công thức trung bình E(Pt |Pt<12.100) tại C18 =AverageLow($A$2:$D$11;A18;$D$12;$D$13)

- Công thức xác suất P(Pt>12.100) tại D18 =ProbaHight($A$2:$D$11;A18;$D$12;$D$13)

- Công thức trung bình E(Pt |Pt>12.100) tại E18 =AverageHight($A$2:$D$11;A18;$D$12;$D$13).

• Dự đoán cho xác suất mức giá trong khoảng X1 và X0 được tính là

P(Xo
X1)

Ví dụ với Xo=12.100 tại ô A18 và X1=12.200 tại ô A19 thì P(12.100
<12.200) là=”1-ProbaLow(A2:D11;A18;D12;D13)-ProbaHight(A2:D11;A19;D12;D13)
• Dự đoán cho trung bình mức giá trong khoảng X1 và X0 được tính là

E(Xo
X1)*P(Pt>X1))] / P(Xo

Ví dụ với Xo=12.100 tại ô A18 và X1=12.200 tại ô A19 thì E(12.100
<12.200) là=”(AverageValue(A2:D11;D12;D13)-AverageLow(A2:D11;A18;D12;D13)*ProbaLow(A2:D11;A18;D12;D13)-AverageHight(A2:D11;A19;D12;D13)*ProbaHight(A2:D11;A19;D12;D13))/F19
Lưu ý:

Khi dự đoán giá cả trung bình (kỳ vọng) với các điều kiện giá cả lớn hơn hay nhỏ hơn hoặc trong khoảng nào đó thì các mức này nên trong khoảng trung bình của giá cả (toàn cục) 2 lần độ lệch chuẩn của giá cả.

Nguyễn Văn Thắng

Công ty Kiểm Toán Quốc Tế Việt Nam
E-mail:
thang_via@yahoo.com

[symbian] Phat trien ung dung tren SYMBIAN

Filed under: C Programming — encyclopedia @ 5:03 am

http://www.pcworld.com.vn/pcworld/magazine_a.asp?t=mzdetail&atcl_id=5f5e5d5f5a565c

Hiện có một số công cụ phát triển ứng dụng trên Symbian như Visual Studio C++ 6 .0, CodeWarrior Development Studio, Borland C++ BuilderX, Nokia Development Suite (NDS) và thành viên mới nhất là Carbide C++ Express 1.0. Trong đó NDS và Carbide do chính Nokia phát triển (Nokia hiện nắm quyền chi phối Symbian OS).

Khác với các công cụ Visual C++ và Code Warrior đều phải trả tiền bản quyền khi sử dụng, NDS thực chất chỉ là plug-in trên Visual Studio .NET (cái này cũng có bản quyền), Carbide Express hoàn toàn miễn phí và là một môi trường phát triển ứng dụng hoàn chỉnh (IDE) được xây dựng dựa trên IDE rất quen thuộc đó là Eclipse, có công cụ mô phỏng và hỗ trợ bẫy lỗi (debug) trực tiếp trên PC trước khi triển khai ứng dụng.

Tải về và cài đặt

Bạn vào trang web www.forum.nokia.com/carbide để tải Carbide cũng như các SDK (Software Development Kit) dành cho dòng điện thoại S60, S80 và S90, hay vào http://developer.uiq.com để tải SDK dành cho dòng Symbian UIQ. File cài đặt có dung lượng khoảng 84 MB, khi cài đặt xong sẽ chiếm khoảng 160 MB trên ổ cứng.

Mặc dù tài liệu cho biết Carbide hỗ trợ tốt S60 SDK 2nd , nhưng không hiểu sao khi dùng SDK này, Carbide không làm việc đúng. Tốt hơn bạn nên dùng SDK S60 2nd phiên bản FP 2 hay FP3 hay SDK S60 3rd MR.

Bạn cũng cần cài đặt ActivePerl version 5.6.1.x (miễn phí). Điều này là cần thiết cho việc “build” các project trong Carbide.

Bộ cài đặt Carbide được đóng gói bằng trình InstallShield, cho phép dễ dàng cài đặt trên PC. Carbide.c++ Express được thiết kế để chạy trên Windows XP SP2, tuy nhiên tôi cài trên cả Windows Server 2K3 và Windows 2K Pro đều chạy tốt.

Lưu ý: khi cài trên phiên bản hệ điều hành khác Windows XP SP2, chúng ta sẽ thấy hộp thoại cảnh báo, bạn chỉ việc nhấn OK để đóng lại và tiếp tục quá trình cài đặt.

Sử dụng

GUI đầu tiên khi bạn vào Carbide là màn hình Welcome, bạn đóng nó bằng cách nhấn dấu X trên tab vì hiện giờ chưa cần đến. Giao diện Carbide như hình.

Carbide hỗ trợ nhiều wizard, giúp tạo ra một bộ khung cho project mới, rất tiện lợi cho người mới làm quen với lập trình trên Symbian.

Bây giờ chúng ta hãy cùng tạo ra một S60 Project đơn giản để xem Carbide “làm ăn” như thế nào.

Trước hết chúng ta kiểm tra xem Carbide có nhận diện ra các SDK mà chúng ta đã cài trước đây không. Vào menu Window/ References.

Chọn Carbide.c++, chọn tiếp SDK Preferences, bạn sẽ thấy Carbide tự động nhận ra các SDK đã được cài đặt. Những SDK không được hỗ trợ sẽ được hiển thị bằng màu đỏ. Nếu Carbide không nhận ra các SDK đã được cài đặt, bạn nhấn nút Rescan để Carbide tự tìm các SDK đã được cài đặt trên máy.

Carbide có một nhược điểm là nếu bạn chọn đường dẫn đến thư mục Workspace có khoảng trắng, Carbide khi build sẽ báo lỗi. Do thư mục Workspace mặc định của Carbide có chứa khoảng trắng nên bạn bắt buộc phải thay đổi. Chọn menu File/Switch Workspace để thay đổi Workspace.

Bây giờ là lúc chúng ta tạo một Project mới. Chọn menu File/New/Project, hộp thoại New Project xuất hiện cho phép chúng ta chọn loại project muốn tạo.

Chọn S60 Project, nhấn Next, đặt tên cho Project. Nhấn Next tiếp.

Tiếp tục nhấn Next.

Ở đây có vài điều cần giải thích. Như bạn thấy, trong Carbide ứng với một project bất kỳ đều có 3 lựa chọn:

- S60 2.8 Emulator Debug: cho phép bẫy lỗi trên PC trước khi cài ứng dụng trên thiết bị thật.

- S60 2.8 Phone (ARMI) Release: dùng để tạo ứng dụng cho thiết bị sử dụng CPU 32 bit.

- S60 2.8 Phone (Thumb) Release: dùng để tạo ứng dụng cho thiết bị sử dụng CPU 16 bit.

Chọn SDK phù hợp với ứng dụng mà bạn muốn viết, sau đó nhấn Finish để Carbide tự động tạo cho chúng ta 1 bộ khung ứng dụng như hình sau:

Sau đây là những công dụng của các thư mục chính:

- Includes: chứa file header của Symbian cần để build ứng dụng.

- Src: chứa file nguồn (.cpp).

- Inc: chứa file header (.h).

- Data: chứa file tài nguyên (.rss).

- Sis: chứa file đóng gói (.pkg). Nếu bạn chọn build ở chế độ release thì đây cũng chính là thư mục sẽ chứa file .sis.

- Aif (Application Information): chứa file .aif (hầu như bạn không cần phải đụng đến file này).

Bây giờ chọn menu Project/Build All. Carbide sẽ giúp ta build project này.

Bạn mở cửa sổ Problems xem có lỗi nào không (nếu không thấy cửa sổ Problems, bạn vào menu Window/Show View/Problems), thường bạn sẽ nhìn thấy Carbide hiển thị một lỗi “CTags not install or not in path”, bạn đừng quan tâm đến nó, đây chỉ là “lỗi” của Carbide.

Chuẩn bị chạy ứng dụng đầu tiên của chúng ta trên Emulator xem sao. Chọn menu Run/Run, nhấn New để tạo mới phiên debug nếu bạn không thấy tên project của mình hiện ra trong danh sách bên trái.

Và nhấn Run để chạy ứng dụng này trên Emulator.

Cuộn màn hình cho tới khi thấy ứng dụng của mình; chạy ứng dụng bằng nút trên Emulator như các phím trên ĐTDĐ.

Sau khi kiểm tra ứng dụng chạy hoàn hảo trên Emulator, bước tiếp theo là tạo ra file .sis để cài lên thiết bị thật. Muốn vậy chúng ta cần chọn lại cấu hình build cho bản release. Ví dụ để build cho máy Nokia 6600 (dùng CPU 32 bit), chúng ta chọn ARMI Release. Thực hiện như sau:

- Mở Build Configuration, chú ý hình chữ i, kế bên có nút tam giác, nhấn vào đó để đổi chế độ build. Chọn option S60.2.8 Phone (ARMI) Release.

- Sau đó chọn menu Project/Build project. Nếu thành công bạn sẽ thấy file .sis được đặt trong thư mục sis của project.

Lưu ý: khi chuyển từ chế độ debug sang các chế độ build khác và ngược lại, bạn nên dùng chức năng Clean (menu Project/Clean) để xóa các file trung gian. Quá trình clean không xóa file sis.

Bạn dùng Bluetooth hay đầu đọc thẻ nhớ, chép file này vào thiết bị, cài đặt và chạy thử. Ứng dụng của bạn sẽ chạy y như trên Emulator.

Vài điều khó chịu…

- Thứ nhất là tốc độ khởi động Emulator, Carbide mất trung bình khoảng 1 phút cho việc nạp và hiển thị Emulator (CPU 3GHz HT, RAM 512 MB).

- Thứ hai, tốc độ “chấm và xổ” (hỗ trợ coding) trong Carbide hơi chậm. Bạn có thể hiệu chỉnh thời gian chờ khi hiển thị “xổ”, tuy nhiên không cải thiện mấy (vào menu Window/Preference/, chọn C/C++/Editor/Code Assist và giảm thời gian delay trong mục Auto Activation).

- Quá trình build hơi chậm, dù chỉ xóa 1 dòng trống, khi build vẫn mất chút ít thời gian.

- Khai báo hằng chuỗi bằng cách dùng macro __LIT bị Carbide gán lỗi warning.

- Cửa sổ Problems thỉnh thoảng hiển thị lỗi không đúng, đôi khi bạn cần phải xem qua cửa sổ Console để xác định lỗi của project. Ví dụ khi bạn build bản release, nếu bạn quên khai báo file thư viện lib, việc build sẽ không thành công, vì vậy Carbide không tạo được file .sis, nhưng hiển thị trên cửa sổ Problems lại là một lỗi khác (“file not found” chẳng hạn chứ không phải là “undefined xxx symbol…” như bạn mong đợi đâu).

- Cửa sổ Build Configuration đôi khi không hiển thị được. Nhưng đừng lo, bạn chỉ việc đóng Carbide rồi mở lại, và thế là vấn đề được giải quyết.

- Đôi khi menu Project/Build bị disabled mặc dù bạn đã thay đổi vài dòng code, bạn phải chuyển qua cửa sổ con khác thì menu Project/Build mới enabled. Nhưng đừng lo, bạn có thể dùng luôn Build All (khi dùng chức năng này chỉ nên mở 1 project trong workspace thôi).

- Một điều hơi khó chịu nữa: NDS Nokia cho phép tạo ra các resource (text query dialog, number query dialog,…) theo kiểu wizard chỉ bằng vài nhấn chuột, nhưng với Carbide thì bạn phải gõ bằng tay. Thật bất tiện.

Những thiếu sót trên chỉ là chuyện nhỏ, có thể giải quyết bằng chính kinh nghiệm sử dụng của bạn và nó không ảnh hưởng nhiều đến quá trình xây dựng ứng dụng. Và Carbide vẫn là lựa chọn sáng giá cho việc phát triển ứng dụng trên Symbian OS.

Hiện nay Nokia cũng đã cho ra mắt 2 bản Carbide thương mại là Carbide.c++ Developer Edition và Carbide.c++ Professional Edition. Với 2 bản thương mại này, bạn có thể debug trên thiết bị thật, hỗ trợ triển khai ứng dụng nhanh.

Nguyễn Hoài Phong
Email:
phongnguyenh@cybersoft-vn.com

———————————————–
Tài liệu tham khảo:
• www.forum.nokia.com
• www.newlc.com
• http://en.wikipedia.org/wiki/Symbian_OS
• http://www.symbian.com
• Carbide cpp Introductory white paper V1.0
Symbian White Paper Rev 3.0

January 16, 2007

[winsock] Winsock API

Filed under: C Programming — encyclopedia @ 8:59 am

http://www.echip.com.vn/echiproot/weblh/sdpm/2002/lvtn/atlantisnet/phan1_2.html

January 12, 2007

Al-Qaeda ‘rebuilding’ in Pakistan

Filed under: Politic News — encyclopedia @ 5:03 pm

The head of US spying operations says the leaders of al-Qaeda have found a secure hideout in Pakistan from where they are rebuilding their strength.

>>Người đứng đầu hoạt động tình báo của Hoa Kỳ cho biết lãnh đạo mạng lưới al-Qaeda đã tạo dựng được một căn cứ an toàn ở Pakistan và đang tiến hành công việc tái thiết tổ chức này ở đó.

National Intelligence Director John Negroponte said al-Qaeda was strengthening its ties across the Middle East, North Africa and Europe.

>>Giám đốc Cơ quan Tình báo Quốc gia John Negroponte nói al-Qaeda đang tự khôi phục tại Trung Đông, Bắc Phi và châu Âu.

Pakistan rejected the comments, which are the most specific on the issue yet.

This week, the US carried out air strikes in Somalia targeting what it believed to be members of al-Qaeda.

>>Chính phủ Pakistan chưa đưa ra bình luận nào.

Hồi đầu tuần, Mỹ đã tổ chức không tạc Somalia, nhằm vào các nhân vật mà họ cho là thành viên của al-Qaeda.

The BBC’s James Westhead in Washington says that until now the US has not been so specific about where it believes al-Qaeda’s leaders are hiding.

Such a claim will be embarrassing for Pakistani President Pervez Musharraf, who Mr Negroponte described as a key partner in America’s war on terror, our correspondent says.

Afghanistan has welcomed the comments. President Hamid Karzai’s chief-of-staff, Jawed Ludin, told the BBC that Afghanistan had long maintained that the Islamic militants operated from within Pakistan, and that Mr Negroponte’s statement was refreshing in its honesty. ‘Secure hide-out’

Mr Negroponte told a Senate committee that al-Qaeda was still the militant organisation that “poses the greatest threat to US interests”.

“They are cultivating stronger operational connections and relationships that radiate outward from their leaders’ secure hideout in Pakistan to affiliates throughout the Middle East, North Africa and Europe,” he said.

>>Ông Negroponte phát biểu trước một ủy ban của Thượng viện rằng al-Qaeda vẫn mang tính chất một tổ chức dân quân và là đe dọa về mặt an ninh của Hoa Kỳ.

Ông cũng nói tổ chức này đang ngày càng củng cố hoạt động và quan hệ từ căn cứ địa ở Pakistan.

We have captured or killed numerous senior al-Qaeda operatives, but al-Qaeda’s core elements are resilient

John Negroponte

“We have captured or killed numerous senior al-Qaeda operatives, but al-Qaeda’s core elements are resilient. They continue to plot attacks against our homeland and other targets with the objective of inflicting mass casualties,” Mr Negroponte added.

He did not say where in Pakistan the group’s leadership was hiding, or refer to its chief, Osama Bin Laden, or his second-in-command, Ayman al-Zawahiri, who are wanted for masterminding the 11 September attacks on Washington and New York.

New job

But the unusually forthright statement by Mr Negroponte appears to be the first time the US has publicly singled out Pakistan, one of its key allies, as the current home of al-Qaeda’s high command.

Previously, officials had spoken more vaguely about the group having bases in the mountainous border area between Pakistan and Afghanistan.

John Negroponte

Mr Negroponte is soon to take up a new role at the state department

>>Al-Qaeda đang củng cố hoạt động tại Pakistan.

 

Lãnh đạo tình báo Mỹ John Negropont

“Pakistan is our partner in the war on terror and has captured several al-Qaeda leaders. However, it is also a major source of Islamic extremism,” Mr Negroponte said in written testimony submitted to the Senate committee.

Pakistani foreign office spokeswoman Tasneem Aslam rejected the comments.

“Pakistan does not provide a secure hideout to al-Qaeda or any terrorist group,” she said. “In fact the only country that has been instrumental in breaking the back of al-Qaeda is Pakistan.”

Pakistani Interior Minister Aftab Sherpao also played down Mr Negroponte’s comments as “too general”, saying that Pakistan responded to specific information about al-Qaeda members and claiming that the movement was totally marginalised.

Difficult border
Vùng biên bất ổn

The head of the US Defence Intelligence Agency, Lt-Gen Michael Maples, said Pakistan’s border with Afghanistan remained a haven for al-Qaeda and other militants.

>>Trưởng cơ quan quân báo của Hoa Kỳ, trung tướng Michael Maples, thì nói vùng biên giới giữa Pakistan và Afghanistan vẫn là nơi mà al-Qaeda và các tổ chức dân quân khác hoành hành.

The tribal areas on the border are thought to be where al-Qaeda leader Bin Laden and his deputy Zawahiri could be hiding.

>>Khu vùng biên do các bộ tộc chiếm cứ này cũng được cho là nơi mà thủ lĩnh al-Qaeda Osama Bin Laden và người phó là Ayman al-Zawahiri đang ẩn náu.

Pakistan and Afghanistan share a 1,400-mile (2,250km) mountainous border which is extremely difficult to patrol.

Taleban and al-Qaeda fighters are thought to be operating on both sides.

>>Pakistan và Afghanistan cùng có chung 2.250km biên giới miền núi, khu vực rất khó tiến hành tuần tra.

Chiến binh Taleban và al-Qaeda được tin là hoạt động ở cả hai bên.

The two countries regularly exchange charge and counter-charge over who is to blame for the violence.

Recently, Pakistan reiterated its intention to fence and mine sections of the troubled border.

>>Hai nước này đã thường xuyên chỉ trích lẫn nhau về tình trạng bạo lực.

Gần đây, Pakistan đã nhắc lại ý định lập hàng rào và gài mìn tại một số khu đường biên.

Kabul particularly opposes the idea of mining stretches of the frontier, saying it will endanger civilian lives.

An Islamist insurgency spearheaded by the resurgent Taleban militia is at its strongest in the southern Afghan provinces bordering Pakistan.

>>Kabul đặc biệt phản đối kế hoạch đặt mìn vì cho rằng điều này sẽ gây ảnh hưởng tính mạng của dân thường.

Một phong trào kháng chiến Hồi giáo do dân quân Taleban dẫn đầu đang hoạt động mạnh tại các tỉnh miền Nam Afghanistan kế cận Pakistan.

Mr Negroponte took charge of the 16 US intelligence agencies in April 2005, but is shortly due to move to the state department where he will become Condoleezza Rice’s deputy.

President George W Bush last week named retired Navy Vice Admiral Michael McConnell as the new US national intelligence director.

Mr Negroponte made the claims about Pakistan in his annual assessment of worldwide threats against the US and its interests.

[Ast-Java] Manager API Package Overview

Filed under: VOIP News — encyclopedia @ 1:49 am

Các interfaces quan trọng của Asterisk-Java’s Manager API package là ManagerConnection, ManagerEventHandler và AsteriskManager.

In contrast to AGI communication between the Asterisk server and your application is not initiated by Asterisk when using the Manager API but has to be initiated by you. Asterisk-Java provides the ManagerConnection interface that is well suited for this purpose. Its responsibility is to establish a TCP/IP connection to Asterisk (and reestablish that connection in case of a restart of Asterisk or a network failure), to enable its clients to send ManagerActions and receive the corresponding ManagerResponses and to dispatch events received from Asterisk.

Once you are connected to Asterisk you can not only actively send ManagerActions but you will also receive MangerEvents from Asterisk. ManagerEvents usually inform your application about state changes that occur within your Asterisk server, for example due to a user dialing an extension or hanging up the phone. To recieve these events you can implement the ManagerEventHandler interface and register your handler with the corresponding ManagerConnection.

Instances of the MangerConnection interface are usually obtained from the ManagerConnectionFactory unless you are using an IoC container. Asterisk-Java provides a default implementation of the ManagerConnection interface called DefaultManagerConnection.

Finally there is the AsteriskManager interface that provides a higher level abstraction on top of the ManagerConnection. It keeps track of Asterisk’s state by listening to all state changing events and provides support for domain objects like Channel, Call and Queue that make it easier for your application to interact with Asterisk without diving into details.
Asterisk-Java provides a default implementation of the AsteriskManager interface called DefaultAsteriskManager that is initialized by passing a ManagerConnection.
You can use both interfaces at the same time thus using the abstracted AsteriskManager where it is sufficient and going back to ManagerConnection where needed. If you choose to do so be sure to initialize the AsteriskManager before you register any of your own ManagerEventHandlers.

Please note that the AsteriskManager interface is still in an early state and the functionality exposed through it is rather limited. This interface will certainly change in the future so be aware of that when using it.

January 7, 2007

[tralvel] Malaysia 4 day tour

Filed under: Personal Interests, Travel Tips — encyclopedia @ 5:16 am

twintowers.jpg

Tháp đôi Petronas Twin Towers – Kuala Lumpur

batu-cave.jpg
Động Batu – Batu Cave – Kuala Lumpur

Older Posts »

Blog at WordPress.com.