#define s_ACT 1
#define s_FAIL 2
#define s_SF 3
#define s_RDI 4
#define s_GB1 3
#define s_GB2 4
#define s_EXT 3
#define s_INT 4
#define s_HOLD 5
#define s_LED1 1
#define s_LED2 2
#define s_LED3 3
#define s_LED4 4
#define s_LED5 5
#define s_LED6 6
#define s_LED7 7
#define s_LED8 8
#define s_LED9 9
#define s_LED10 10
#define s_LED11 11
#define s_LED12 12
#define s_LED13 13
#define s_LED14 14
#define s_CR 3
#define s_MJ 4
#define s_MN 5
#define s_ACO 6
#define s_HST 7
#define s_FANFAIL1 1
#define s_FANFAIL2 2
#define s_FANFAIL3 3

#define cINSERT 1
#define cREMOVE 2
#define cENABLE 1
#define cDISABLE 0

unsigned char unitstate[5];
unsigned char ledstate[40];
void SetUnitState(unsigned char unitno, unsigned char stateType)
{
int index, offset;

/* unitno reordering */
if ((0 <= unitno ) && (unitno <= 7)) /* case of Tributary interface */
unitno += 8;
else if((8 <= unitno) && (unitno <= 15)) /* case of UP, GBE and TSI interface */
unitno -= 8;
else
unitno = unitno; /* case of MCU */

index = unitno / 4;
offset = unitno % 4;

if(stateType == cINSERT)
unitstate[index] |= 0x08 >> offset; /* Bit OR 000010000 */
else if(stateType == cREMOVE)
unitstate[index] &= 0xf7 >> offset; /* Bit AND 111101111 */
}/* hjlee */

void SetLedState(unsigned char unitno, unsigned char stateType, unsigned char stateMode)
{
int index, offset;
unsigned char mask;

/* unitno reordering */
if ((unitno >= 0) && (unitno <= 7)) /* case of Tributary interface */
unitno += 8;
else if((unitno >= 8) && (unitno <= 15)) /* case of UP, GBE and TSI interface */
unitno -= 8;
else
unitno = unitno; /* case of MCU and FAN */

if((unitno >= 0) && (unitno <= 5)) /* case of UP and GBE interface */
{
index = unitno;
if(stateMode == cENABLE)
ledstate[index] |= 0x10 >> stateType;
else if(stateMode == cDISABLE)
ledstate[index] &= 0xEF >> stateType;
}
else if((unitno >= 6) && (unitno <= 7)) /* case of TSI interface */
{
index = unitno;
if(stateMode == cENABLE)
ledstate[index] |= 0x20 >> stateType;
else if(stateMode == cDISABLE)
ledstate[index] &= 0xDF >> stateType;
}
else if((unitno >= 8) && (unitno <= 15)) /* case of Tributary interface */
{
index = 8 + ((unitno - 8) * 3);
offset = stateType / 5;
stateType = stateType % 5;

if(stateMode == cENABLE)
ledstate[index + offset] |= 0x20 >> stateType;
else if(stateMode == cDISABLE)
ledstate[index + offset] &= 0xD0 >> stateType;
}
else if((unitno >= 16) && (unitno <= 18)) /* case of MCU and FAN interface */
{
index = 32 + ((unitno - 16) * 2);
offset = stateType / 5;
stateType = stateType % 5;

if(stateMode == cENABLE)
ledstate[index + offset] |= 0x10 >> stateType;
else if(stateMode == cDISABLE)
ledstate[index + offset] &= 0xEF >> stateType;
}
}/* hjlee */
Posted by hjlee
:
Google
 
BLOG main image
http://hjoo.org by hjlee

공지사항

카테고리

분류 전체보기 (154)
연구실생활 (9)
여 행 (8)
영어공부 (4)
취미생활 (7)
논 문 (2)
My Stories (31)
기 사 (11)
Computer (15)
즐길거리 (15)
스크랩 (3)
Web Progmming (0)
유용한 정보 (21)
KISANTEL (5)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :