Thursday 28 November 2013

Tìm hiểu thêm về acquy & ups

SOURCE: http://www.powerload.vn/news/detail/acquy,-accu,-binh-dien-30.html




Chào các bạn,
Sau đây là một số thuật ngữ được dùng nhiều trong acquy và ups.
Dung lượng của acquy (accu) là lượng điện (điện tích) mà accu đó sau khi đã được nạp đầy sẽ phát ra được trước khi hiệu điện thế giảm xuống đến mức ngừng. Mức ngừng là mức mà không nên để acquy phát điện tiếp, nếu cứ để acquy phát điện ở dưới mức ngừng thì sẽ giảm tuổi thọ, thậm chí có thể làm acquy hỏng ngay. Đó là trường hợp dùng nhiều acquy mắc nối tiếp nhau khi 1 hay nhiều acquy trong dãy đó đã phát hết điện mà những cái khác chưa hết điện và ta tiếp tục dùng thì cái hết điện trước sẽ bị đảo cực và hỏng hoàn toàn. Với acquy acid chì thì mức ngừng là 1,67V cho mỗi ngăn (cell) (10V đối với acquy 12VDC)
Coulomb là đơn vị đo điện tích. Đại lượng điện tích không phụ thuộc vào điện thế của acquy. 1 Coulomb = 1 Ampere * 1 sec: như vậy cũng có thể dùng Ampere * second để chỉ đại lượng điện tích. Tụ điện (Capacitor) cũng có chức năng như acquy. Đơn vị đo điện dung của tụ điện là Farad, lấy từ tên nhà khoa học Michael Faraday. 1 Farad = 1 Coulomb / 1 Volt.
Đơn vị đo điện tích acquy thường dùng trong thực tế là Ah (Ampere * hour).
Thông số điện tích của acquy do nhà sản xuất công bố thường được tính khi phát điện với dòng điện nhỏ trong 20 giờ (20Hr). Ví dụ acquy 100Ah sẽ phát được dòng điện 5A trong 20 giờ. Khi dòng điện phát ra càng lớn thì thời gian phát điện càng ngắn. Các bạn nên xem bảng thông số kỹ thuật chi tiết của sản phẩm do nhà máy công bố trước khi chọn mua hàng. Tại trang www.powerload.vn, các sản phẩm hầu hết được đính kèm file .pdf thông số kỹ thuật trong phần "chi tiết sản phẩm" ngay bên dưới hình ảnh của sản phẩm khi xem chi tiết.
Sau đây là câu chuyện có thật, xin được chia sẽ:
Có một bác nọ mua một UPS dùng điện áp charge là 12VDC và một chiếc acquy 12V-65Ah để dùng cho một chú laptop IBM T61. Sau khi xả tải (dùng điện acquy để cấp nguồn cho con T61 (75w) được hơn 6 giờ. Bác ấy gọi điện cho em thắc mắc: "tại sao pin của laptop bé tí tẹo (nằm gọn trong lòng bàn tay) mà xài được 3 giờ, trong khi cái acquy nặng 23 cân chỉ xài được có 6 giờ là thế nào?".
Điện thế của acquy là DC (một chiều), trong khi điện lưới là AC (xoay chiều). UPS phải dùng inverter để chuyển đổi điện từ 12VDC lên 220VAC rồi mới cấp cho adaptor của máy laptop. Chắc là bác ấy lấy điện tích của acquy đó (65Ah) chia cho dòng điện cấp cho máy tính T61 (khoảng 3.4A) = 19 giờ.

Cách tính công suất UPS và dung lượng acquy

SOURCE: http://www.powerload.vn/news/detail/cach-tinh-cong-suat-ups,-dung-luong-acquy-29.html


Chào các bạn,
Mùa này có thể nói là mùa "nóng". Thiếu điện, trong nhà nóng, trong người cũng nóng. Đi mua UPS, móc túi một đống tiền ... cũng gây nóng.
Nói thế nhưng việc cần thì phải làm.
Mọi thứ quanh ta đang nóng, bê nhầm con ups về nhà lại dùng không được như ý mình muốn thì ... buzz!
Để tránh cho mọi thứ nổ tung, thiết nghĩ, chúng ta cùng tìm tòi một tí về cách thức tính công suất để chọn ups và thời gian lưu điện cần đủ cho nhu cầu của mình để chọn dung lượng acquy (có thể tham khảo các viết liên quan trong mục "kiến thức tiêu dùng").
Để bắt đầu, chúng ta phải xác định được những cái gì mình cần dùng qua ups khi điện lưới bị cắt. Nếu ở gia đình thì quạt, thắp sáng, tủ lạnh, ... Lưu ý là mọi thiết bị điện, điện tử, ... đều được nhà sản xuất ghi rõ công suất tiêu thụ điện và được in hoặc dán đâu đó trên thiết bị. Có thể là ghi bằng chỉ số watts (w), có thể ghi bằng V-A (để quy đổi thành watts từ V-A, chỉ việc lấy số V nhân với số A là được). Công suất ghi trên thiết bị là công suất tối đa mà thiết bị đó có thể đạt đến, thường được gọi là công suất đỉnh hoặc công suất danh định (nominal). Thực tế trong điều kiện hoạt động bình thường thì ít khi nào thiết bị đạt đến 100% công suất tối đa của nó. Công suất tiêu thụ thực tế là công suất khi thiết bị hoạt động ở chế độ bình thường. Ví dụ, nguồn máy tính ghi là 350W. Đây là công suất tối đa của nguồn có thể đáp ứng. Tuy nhiên, với một chiếc máy tính thông thường đủ các bộ phận chuẩn dùng màn hình LCD 15" thì công suất tiêu thụ thực tế của máy tính này khoảng 150w-200w.
Công suất UPS thường được ghi bằng VA. Lấy chỉ số VA này nhân với hệ số công suất (Power Factor) của ups (PF=0.6, 0.7, 0.8, 0.9, 1) sẽ cho ra chỉ số Watts. PF của từng loại, hiệu UPS, Inverter khác nhau có thể sẽ khác nhau, dao động từ 0.6 đến 1 (PF càng gần với 1 càng tốt). Khi chọn mua UPS hoặc Inverter, chúng ta nên chọn loại có công suất gấp đôi so với tổng công suất mình cần dùng. Giả sử bạn dùng cho văn phòng hoặc gia đình với tổng các thiết bị đầu cuối vào khoảng 1000W, thì phải chọn ups có công suất tải đến 2000W, nếu tài chính không cho phép thì cũng phải gồng cho được con ups có công suất tải 1500W.
Sau khi đã xác định được công suất tiêu thụ cần thiết để chọn ups, chúng ta phải tính đến thời gian lưu điện mà ups cần phải đáp ứng - chọn dung lượng acquy (Ah). Acquy dân dụng thường có điện áp là 12V, công suất cao nhất của dòng acquy 12V này thường chỉ dừng lại ở con số 200Ah (xem thêm bài viết về acquy). Có thể xác định dung lượng acquy bằng cách
Ah = (T*W) / (V*PF)              Hoặc xác định Thời gian tải bằng cách T = (Ah * V * PF) / W
trong đó
Ah là dung lượng của acquy
T là thời gian (giờ) cần dùng khi mất điện
W là tổng công suất các thiết bị gắn vào UPS
V là điện áp charge của UPS
PF là hệ số công suất của UPS
Ví dụ: Tôi cần dùng 2 chiếc quạt treo tường (70W/cai), 2 bóng đèn neon 1,2M (40W/cai), 02 máy tính xách tay (65W-110W), Một cái modem, và 1 cái Switch, 1 cái tổng đài điện thoại 3 CO (40W), một chiếc máy fax nhiệt (260W) trong thời gian liên tục 8 giờ cho một ngày mất điện.
Theo đó. ta tính tổng công suất các thiết bị: (70*2) + (40*2) + (65*2) + 10 + 10 + 40 + 260 = 630Watts
Với công suất này, phải chọn ups có công suất gấp đôi tức là 630w * 2 = 1260W. Nếu UPS có hệ số công suất là 0.6 thì mình cần phải trang bị ups tương đương 2000VA (2000*0.6=1200W). UPS phải có dòng charge (A) đủ lớn để charge cho hệ thống acquy. Theo tiêu chuẩn, dòng charge của UPS phải đáp ứng là 1/10 so với dung lượng của acquy (nếu acquy là 100Ah thì dòng charge cần đáp ứng là 10A). Nếu UPS được chọn có điện áp charge cho hệ thống acquy là 48VDC (tương đương với việc gắn 4 cái acquy 12V mắc nối tiếp nhau), và có hệ số công suất là 0.7 thì chúng ta có thể ráp vào công thức trên như sau:
Ah = (T*W) / (V*PF) = (8 giờ * 630 W) / (48 VDC * 0.7 PF) = 150

Như vậy, cần phải dùng 4 cái acquy 12V-150Ah đế đáp ứng cho tải 630W trong thời gian 8 giờ.

Friday 22 November 2013

Asterisk queues.conf



Source: http://www.syednetworks.com/asterisk-queues-conf

In Asterisk queues.con file is where we define queues and the way that how to handle the callers.
• Reasonable queuing support within Asterisk
• Queues can have static or dynamic members
• Members can be channels, or Agents
• Automatic distribution of calls based on queue strategy
Here is queues.conf options are available:
In Asterisk queues.con file is where we define queues and the way that how to handle the callers.
• Reasonable queuing support within Asterisk
• Queues can have static or dynamic members
• Members can be channels, or Agents
• Automatic distribution of calls based on queue strategy
Here is queues.conf options are available:
persistentmembers = yes, so that when you restart Asterisk the agents will be automatically readded into their recorded queues. By default the option is set to yes.
Each queue is a separate section. For example, a snake in the [support]. The following parameters are available:
musiconhold In musiconhold.conf file defined category of music queue. We choose the top-scale Category default:
musiconhold = default
announce
you can specify an announcement, which to be played to the agents, when they answer the incoming call. Usually this option is used to inform the agents, which queue exactly, they will answer. This is made for agents which are set in more than one queue.
; announce = Technical-support
If you use this option, make sure that file technical-support.gsm should be availabe in the sound directory the default path of sound directory is /var/lib/asterisk/sounds.
Strategy
Determines how and what’s the order of the agents when a call comes to this queue:
ringall
All available agent should ring until one responds. (Default)
roundrobin
ring the each available agent one by one.
leastrecent
Call the agent who is longest idle in available agents
fewestcalls
ring the agent with fewest completed calls from this queue.
Random
Select the agent randomly from this queue.
rrmemory
Round-robin with memory. Starts the series in which, after the last call to the series.
In Asterisk 1.6 will probably be the roundrobin procedure is forfeited and rrmemory in roundrobin renamed.
It should be noted that agents, for which a lower penalty (penalty) has been established agent who always preferred a higher penalty.
Strategy = ringall
The setting depends on your circumstances: ringall may be annoying, while others cause additional waiting time for the caller, if agents not connected to the phone.
Level
Sets the time (in seconds), in which calls should be answered. Only for statistical analysis interesting ( “How many calls were made within the service time of x seconds answered?”).
Service = 60
Context
Here can be a context where you want to send the caller, if the caller presses the key (the one you want the caller to be pressed) the extension will be dialed from the mentioned queue.
context = support-context – so we could adjust it
Timeout
Determines how long (in seconds) a phone ringing, until we are not as busy (timeout).
timeout = 15
retry
Determines how long (in seconds) to wait before all agents phoned again.
retry = 5
weight
Weight of queue – when compared to other queues, higher weights get preference
weight = 0
wrapuptime
how long before sending agent another call
We let our agents a little breather to a sip of water to drink:
wrapuptime = 10
maxlen
Maximum number of the callers in the queue (default: 0 for unlimited).
maxlen = 0
announce-frequency
Certainly, at what intervals (in seconds) the callers their position in the queue and / or the estimated waiting time will be announced (0 for nothing i.e. announce-frequency = 0 means off).
announce-frequency = 90
announce-holdtime
Whether the estimated waiting time in the announcements for the position would be called. Possible values are yes (yes), no (no) or once (only once).
announce-holdtime = Yes
Round-announce-seconds
Rounding steps of seconds. With the setting of 0, only minutes, not seconds announced. Other possible values are: 0, 1, 5, 10, 15, 20 and 30 [72] (At 30, for example, would an estimated waiting time from 2:34 to 2:30 rounded.)
announce-round-seconds = 0
Language blocks
The following parameters are, what language blocks for the announcements of the position and waiting periods. I.d.R changes are not necessary:
queue-youarenext = queue-youarenext; “You are now first in line.”
queue-thereare = queue-thereare; “There are” …
queue-callswaiting = queue-callswaiting … “Calls waiting.”
queue-holdtime = queue-holdtime; “The current est. holdtime is” …
queue-minutes = queue-minutes … “Minutes”
queue-seconds = queue-seconds … “Seconds”
queue-thankyou = queue-thankyou, “Thank you for your patience.”
queue-lessthan = queue-less-than … “less than” …
queue-reporthold = queue-reporthold; “hold time” …
periodic-announce = queue-periodic-announce, “All reps busy, wait for next”
If these parameters are not specified (out), these default values.
periodic-announce-frequency
Certainly, at what intervals (in seconds) the callers the periodic announcement (periodic-announce, “There are all employees in an interview, please wait.”) To be announced.
periodic-announce-frequency = 60
Monitor format
The indication of this parameter turns the recording of interviews (as with the monitor () Application) and determines the recording format. (For auskommentiertem monitor-format recordings are not made.) Enter here gsm, wav (large files) or wav49.
If you want records the call in the gsm format uncomment this line, please note the call will be recorded when agent answeres the call:
; monitor-format = gsm
By default, the files (one-in-and out) to $ UNIQUEID) (named. You can change if necessary, by using the dial plan before the queue () call Set (MONITOR_FILENAME = filename). We take the example but no change.
Join Monitor
Combine the two by a call recording files generated …- …- in and out to a file. Values: yes or no
Monitor-join = Yes
joinempty
Determines whether callers in a queue without agents indicated.
Yes
Callers can be placed in a loop without agents or by non-agents available for classification purposes.
No.
Callers can not in a loop without agents indicated.
strict
Callers can not in a loop without agents indicated (but in a snake with only non-available agents).
Non-available should not be confused with the conversation (busy). An agent is not available when he is assigned to the snake, but not actually registered in the system (see also “member”). Caution: Static defined members (see “member”) are always available!
If a caller not to be a snake, the queue () application quits, and the Dial plan will continue.
joinempty = no, we want our callers are not unnecessarily wait
leavewhenempty
It will determines whether as soon as all the agents out the call will not go to this queue. Possible values as joinempty. After leaving the queue, the dial plan.
leavewhenempty = strict; callers are not unnecessarily wait
eventwhencalled
If a (yes | no), whether etc. the following events for the Manager interface is used: Called Agent, Agent dump, Agent Connect, Agent Complete.
eventwhencalled = Yes
eventmemberstatus
If a (yes | no), whether members queue status events in the produce manager interface (can be many).
eventmemberstatus = No
reportholdtime
Sets (yes | no), whether to the agent the waiting time of the caller will be announced before it entertained the caller. (Taste issue)
reportholdtime = No
memberdelay
Where, how long (in seconds) the caller hears silence before he connected with an agent.
memberdelay = 1
timeoutrestart
Determines whether the response time of an agent in a busy or overloaded pipe signal is reset. Can be useful for agents who have the right to reject a call.
timeoutrestart = Yes
autopause
Autopause will pause a queue member if they fail to answer a call.
ringinuse
Determines whether such agent phoned to be known of which is that they are in conversation. The channel so far the only driver, the status transmitted is SIP.
ringinuse = No
Member
It is possible to intervene directly in the queues.conf agents in the form of static
member => Technology Resource [, Malus]
– Also e.g. member => Zap / 2 – them (may be used several times, see queues.conf). But this can result in problems with joinempty and leavewhenempty, since these agents always be available, even if it is in fact not at their apparatus. It also has the disadvantage that always finds an agent is assigned to an apparatus and not from another apparatus from register.
We therefore prefer to use dynamic form and arrange queue support in the form:
member => Agent / AgentenNr
two agents 1001 and 1002 to:
member => Agent/1001
member => Agent/1002

Wednesday 20 November 2013

Clean up Asterisk sample config files

sed '/^;/d' manager.conf.sample | sed '/^[ \t]/d' | sed '/^$/d' > manager.conf

Wednesday 13 November 2013

Using Wget to download entire website:


use following command to download the website:

wget -r -Nc -mk http://bacutin.blogspot.com/
-r  Turn on recursive retrieving
-N  Turn on time-stamping
-m  Create a mirror
-k  Convert the link

Sunday 3 November 2013

A skeletal model for the client-proxy-server system

A skeletal model for the client-proxy-server system

Client

The client should do the following things:
  1. Read the file that's going to get sent
    • open(), fp.read() etc.
  2. Create a socket and establish a TCP connection to the proxy
    • socket.socket(), proxysock.connect() with SOCK_STREAM
  3. Send the file data stored into a variable in step 1 to the proxy
    • proxysock.sendall()
  4. Wait for an answer
    • proxysock.recv()
  5. Close the connection
    • proxysock.close()

Proxy

The proxy, being basically both a kind of a server and a client, should do the following things:
  1. Create a listening socket, wait for incoming connections from the client, accept and store the handle of an incoming connection
    • socket.socket(), proxyserversock.bind(), proxyserversock.listen(), proxyserversock.accept()
  2. Read the data from the incoming connection
    • clientsock.recv()
  3. Store the received data into a file
    • open(), fp.write() etc.
  4. Create a socket and establish a TCP connection to the server
    • socket.socket(), serversock.connect() again with SOCK_STREAM
  5. Send the data received from the client onwards to the server
    • serversock.sendall()
  6. Wait for an aswer
    • serversock.recv()
  7. Pass the answer on to the client
    • clientsock.sendall()
  8. Close the connections to the server and the client, but leave the listening socket on
    • serversock.close(), clientsock.close()

Server

The server should do the following things:
  1. Create a listening socket, wait for incoming connections from the proxy, accept and store the handle of an incoming connection
    • socket.socket(), serversock.bind(), serversock.listen(), serversock.accept()
  2. Read the data from the incoming connection
    • proxyclientsock.recv()
  3. Store the received data into a file
    • open(), fp.write() etc.
  4. Send an answer to the proxy
    • proxyclientsock.sendall()
  5. Close the connection, but leave the listening socket on
    • proxyclientsock.close()

Additional notes

After implementing the basic model described above, you can easily start adding more features. For example, you could add a sleep in the proxy between steps 3 and 4 and instead of directly sending the data received from the client to the server, you could read the file and send the contents - this way you can manually change the file before it gets sent to the server.
I also suggest you read Beej's Guide to Network Programming if you want to really learn the basics of network programming. The examples are in C, but the basic principles also apply in Python (and other languages as well).

UDP Connection

TCP Connection