'2014/01/13'에 해당되는 글 36건

  1. 2014.01.13 애플리케이션 오류
  2. 2014.01.13 cocos2d-x multi-resolution
  3. 2014.01.13 cocos2d-x 스크롤 테이블뷰 예제 소스
  4. 2014.01.13 cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기)
  5. 2014.01.13 cocos2d-x 의 메모리 관리
  6. 2014.01.13 구글 인앱 빌링 ver 3 item already owned 오류시 해결방법
  7. 2014.01.13 cocos2d-x 멀티해상도 지원
  8. 2014.01.13 구글 안드로이드 인앱결제 관련 인앱빌링 ver3 적용
  9. 2014.01.13 [블로그] 더블 클릭시 맨 하단으로 이동하는 코드입니다.
  10. 2014.01.13 동기화 비동기화 동기식 비동기식 이란?

애플리케이션 오류

|

어플리케이션 오류

 

이 버전의 애플리케이션에서는 Google Play를 통한 결제를 사용 할 수 없습니다자세한 내용을 도움말 센터를 참조하세요

 

먼저 어플을 등록하고 인앱을 등록합니다.

인앱을 등록한후 인앱은 반드시 활성화 apk로 해야되며,

등록한후 2~3시간 이후에 적용이 됩니다.

 

그리고 인앱결제 테스트를 하기 위해서는 설정에서

테스트 권환이 있는 Gmail 계정에등록한후(이것도 2~3시간 이후에 확인 가능합니다.)

테스트를 하기 위해서는 반드시!!!

Export keystore가 적용된 apk파일을 추출하여 핸드폰에 넣어서 테스트를 해야됩니다.

이렇지 않을 시에는 위와 같은 오류가 발생합니다.

Trackback 0 And Comment 0

cocos2d-x multi-resolution

|


http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support#designResolutionSize

Multi-resolution support(since cocos2d-2.0-x-2.0.4)

안드로이드 기기에서 다양한 해상도를 적용 하기는 어렵다.

Cocos2d-x는 두가지 메서드를 제공한다 CCEGLView::setDesignResolutionSize() 과 CCDirector::setContentScaleFactor() 은 너가 최대한 쉽게 해상도를 변경할수 있게 한다.

The principle

enableRetina 관련 메서드는 v2.0.4. 부터 제거 되었다. On iOS, if thedevice supports retina display, we enable it by default.
Therefore, 너의 실제 스크린 사이즈를 얻기 위해서는 CCEGLView::sharedOpenGLView()->getFrameSize()를 사용해야된다.

예를들어, 이 메서드를 사용하면 아이폰 4s의 가로모드 사이즈는 '960x640'이다.

레티나 장치에 레티나가 아닌 것을 사용 하는 방법은 무엇일까? 

너는 두가지 메서드만 알고 있으면 된다.

하나는 designResolutionSize 이고 다른 하나는 contentScaleFactor 이다.

designResolutionSize


All your game's coordinates rely on design resolution no matter what the size of your device screen. If the UI layout of your game is the same on all resolutions, you just need only a set of coordinates.

디자인 해상도는 설정할수 있다.

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(width, height, policy)

첫번째와 두번째 피라미터 값은 디자인 해상도의 높이와 넓이 이고 세번째 값은 디바이스에 뿌려주는 방식 이다. 

 

세번째 값에 대해서는 맨 마지막에 설명하겠다.

 

You could also use more than one set of resources on different devices to make a better display by CCFileUtils::sharedFileUtils()->setResourceDirectory(path_string),
but you must set the contentScaleFactor too.

Here are some code snippets in HelloCpp project.

1typedef struct tagResource 2{ 3 cocos2d::CCSize size; 4 char directory[100]; 5}Resource; 6 7static Resource smallResource = { cocos2d::CCSizeMake(480, 320), "iphone" }; 8static Resource mediumResource = { cocos2d::CCSizeMake(1024, 768), "ipad" }; 9static Resource largeResource = { cocos2d::CCSizeMake(2048, 1536), "ipadhd" }; 10static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(480, 320); 11

1bool AppDelegate::applicationDidFinishLaunching() { 2 // initialize director 3 CCDirector* pDirector = CCDirector::sharedDirector(); 4 CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); 5 6 pDirector->setOpenGLView(pEGLView); 7 8 // Set the design resolution 9 pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder); 10 11 CCSize frameSize = pEGLView->getFrameSize(); 12 13 // In this demo, we select resource according to the frame's height. 14 // If the resource size is different from design resolution size, you need to set contentScaleFactor. 15 // We use the ratio of resource's height to the height of design resolution, 16 // this can make sure that the resource's height could fit for the height of design resolution. 17 18 // if the frame's height is larger than the height of medium resource size, select large resource. 19 if (frameSize.height > mediumResource.size.height) 20 { 21 CCFileUtils::sharedFileUtils()->setResourceDirectory(largeResource.directory); 22 pDirector->setContentScaleFactor(largeResource.size.height/designResolutionSize.height); 23 } 24 // if the frame's height is larger than the height of small resource size, select medium resource. 25 else if (frameSize.height > smallResource.size.height) 26 { 27 CCFileUtils::sharedFileUtils()->setResourceDirectory(mediumResource.directory); 28 pDirector->setContentScaleFactor(mediumResource.size.height/designResolutionSize.height); 29 } 30 // if the frame's height is smaller than the height of medium resource size, select small resource. 31 else 32 { 33 CCFileUtils::sharedFileUtils()->setResourceDirectory(smallResource.directory); 34 pDirector->setContentScaleFactor(smallResource.size.height/designResolutionSize.height); 35 } 36 ................... 37 ................... 38}

contentScaleFactor

ContentScaleFactor는 designResolutionSize에 ResourcesSize에서 비율을 설명합니다

ContentScaleFactor describes the ratio from ResourcesSize to designResolutionSize. 일반적으로 'ResourceBackGround.height/DesignResolution.height' 혹은 'ResourceBackGround.width/DesignResolution.width'. 둘중 하나를 사용하며, 너의 게임에 맞는 방법을 선택하면 된다. 
아래 그림의 경우, 우리는 인자를 계산하기 위해 높이를 사용합니다.

Chart 1: Resource Size = 960x640 ; Design Resolution Size = 480x320 ; Target Device Screen Size = 800x480 ; RH/DH=RW/DW=2.0f; NoBorder Policy

When using NoBorder mode, there are some areas of the backgroud out of scope. If you use absolute coordinates based on design resolution size(480x320),
게임의 UI의 일부는 완전히 표시되지 않습니다. 이 문제를 해결하기 위해서는, 당신은 'visible rectangle'을 기준으로 좌표를 설정해야됩니다.

You can get the origin point of 'visible rectange' by 'CCDirector::sharedDirector()->getVisibleOrign()'.

Together with 'CCDirector::sharedDirector()->getVisibleSize()', 당신은 9개의 점을 화면위에서 확인할수 있다.

'Left','Right', 'Top','Bottom','Center','LeftTop','RightTop','LeftBottom' and 'RightBottom'.


게임의 모든 좌표가이 아홉 포인트에 기반 한 경우 게임은 정말 전체 화면으로 표시 될 것입니다
이러한 점을 계산하는 방법에 대해, TestCpp 프로젝트의 'VisibleRect'클래스를 참조하십시오.


Chart 2: Resource Size = 1024x768 ; Design Resolution Size = 480x320 ; Target Device Screen Size = 800x480 ; RH/DH != RW/DW; NoBorder Policy

When RH/DH isn't equal to RW/RH, You should decide to select Width or Height ratio of resource to design resolution.
In the chart 2, we still use height ratio to calculate contentScaleFator, so the height of the resource background will fill for the height of design resolution.
Mark① shows two black rectangle will be in design resolution.
After mapping design resolution to screen, Mark① --> Mark②, and Mark③ will be out of screen. 
Now, you have two choices to make your game becomes full screen. One is to make your background picture wider.
Another is to set the contentScaleFactor based on the ratio of width.

Policies

지금 cocos2d-x는 세 가지 방식을 지원합니다.

Exact fit

The entire application is visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, and the application may appear stretched or compressed.

전체 응용 프로그램은 원래 가로 세로 비율을 유지하기 위해 노력하지 않고 지정된 지역에서 볼 수 있습니다. 왜곡이 발생할 수 있으며, 응용 프로그램은 늘어나거나 압축 나타날 수 있습니다.

No border

The entire application fills the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application.

응용 프로그램의 원래 가로 세로 비율을 유지하면서 전체 응용 프로그램, 왜곡하지 않고 있지만, 아마도 몇 가지 자르기와 함께 지정된 영역을 채 웁니다.

Show all

The entire application is visible in the specified area without distortion while maintaining the original aspect ratio of the application. Borders can appear on two sides of the application.

응용 프로그램의 원래 가로 세로 비율을 유지하면서 전체 응용 프로그램은 왜곡없이 지정된 영역에 표시됩니다. 국경은 응용 프로그램의 두면에 게재 될 수 있습니다.


Chart 3: Resource Size = 1024x768 ; Design Resolution Size = 480x320 ; Target Device Screen Size = 800x480 ; RH/DH != RW/DW; ShowAll Policy

Mark② and Mark③ are both black rectangle areas. But they are different, Mark③ is out of Opengl Viewport, so you can't put any game elements onto it.
Mark② appears because RW/RH isn't equal to DW/DH, it's in the Opengl Viewport, you can place your game elements onto it.

  • You need to use relative coordinates only in NoBorder mode. Generally, developer uses NoBorder mode for better display


Trackback 0 And Comment 0

cocos2d-x 스크롤 테이블뷰 예제 소스

|

cocos2d-x 스크롤 예제 소스


TableViewTest.zip


Trackback 0 And Comment 0

cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기)

|
CCString 에 있는 문자열을 분리하고 싶은 문자를 어규먼트에 넣으면 분리되서 각각 문자열이 CCArray에 집어넣는 함수
아래 예제는 띄어쓰기로 각 문자를 분리 했다.
exam)

char * name = "This is my book!!";
cocos2d::CCString * tStr = cocos2d::CCString::create(name);
CCArray * tAry = tStr->componentsSeparatedByCharactersInSet(" "); //문자열 분리 함수
CCObject * pObj = NULL;
CCARRAY_FOREACH(tAry, pObj)
{
CCString * str = (CCString *) pObj;
CCLog("%s",str->getCString());
}

결과값:
This
is
my
book!!

cocos2d::CCArray * CCString::componentsSeparatedByCharactersInSet(const char * Separator)
{
//구분자를 사용해서 Array배열 반환
CCAssert( length() < 1024, "OVER LengTh!!");
char tBuf[1024];

strncpy(tBuf,getCString(),sizeof(tBuf));

char* token = strtok(tBuf, Separator);  
cocos2d::CCArray * tAry = cocos2d::CCArray::create();
tAry->addObject(CCString::create(token));
while (token)  
{  
token = strtok(NULL, Separator); 
if(token!=NULL)
tAry->addObject(CCString::create(token));
}  
return tAry;
}


Trackback 0 And Comment 0

cocos2d-x 의 메모리 관리

|
cocos2d-x 는 아이폰의 autorelease Pool 개념을 사용하여 c++ 에서도 같은 방식으로 메모리 관리를 한다.

c++에서는 new를 해주면 delete를 해주듯이.

cocos2d-x는 new로 객체를 생성시 release()를 호출하여 메모리를 해제한다.

 

 

cocos2d-x의 모든 클래스는 CCObject클래스를 상속받는데 CCObject클래스는 생성자에서 m_uReference라는 값을 1로 만들어준다.

 

 

 m_uReference 의 값을 확인하는 함수는 retainCount()이다.

 

CCNode * node = new CCNode();   //CCNode의 m_uReference = 1 이됨

this->addChild(node);                    //CCNode의 m_uReference = 2 가됨   

this->removeChild(node,true);               //CCNode의 m_uReference = 1 가됨   

node->release();                          //CCNode의 m_uReference = -17891602(쓰레기값) 메모리해제됨    메모리 할당한값 전부 해제


addChilde시 m_uReference가 1 증가하고 , removeChild시  m_uReference가 1 감소한다. this의 m_uReference는 그대로 이다.

 

 

(메모리가 초기화 된것은 visual stduio에서 디버그-창-메모리-메모리1을 누르고 디버깅 모드에서 해당 주소값 입력후 초기화 되는지 확인하면 된다. 초기화가 되면 fe ee fe ee 이런식으로 값이 들어간다)

 

 

 

 

 

 

안전한 코드는 release()후 node = NULL을 입력시 안전한 코드가 된다. C++에서 delete후 null을 입력하는것과 마찬가지이다.

 #define SAFE_RELEASE(p) if ((p) != NULL) { delete (p); (p) = NULL; 

 

이런식으로 정의한후

SAFE_RELEASE(node);로 해도 된다


 

cocos2d-x에서도 자체 매크로를 제공한다


#define CC_SAFE_DELETE(p)            do { if(p) { delete (p); (p) = 0; } } while(0)

#define CC_SAFE_DELETE_ARRAY(p)     do { if(p) { delete[] (p); (p) = 0; } } while(0)

#define CC_SAFE_FREE(p)                do { if(p) { free(p); (p) = 0; } } while(0)

#define CC_SAFE_RELEASE(p)            do { if(p) { (p)->release(); } } while(0)

#define CC_SAFE_RELEASE_NULL(p)        do { if(p) { (p)->release(); (p) = 0; } } while(0)

#define CC_SAFE_RETAIN(p)            do { if(p) { (p)->retain(); } } while(0)

#define CC_BREAK_IF(cond)            if(cond) break


 

알아서 입맛에 맞게 매크로를 사용하면 된다.

 

 

void CCObject::retain(void)

{

    CCAssert(m_uReference > 0, "reference count should greater than 0");

 

    ++m_uReference;

}

 

void CCObject::release(void)

{

    CCAssert(m_uReference > 0, "reference count should greater than 0");

    --m_uReference;

 

    if (m_uReference == 0)

    {

        delete this;

    }

}

autoRelease란 사용자가 메모리 관리에 신경을 덜 써도 된다. ( m_uReference 가 1이면 자동으로 메모리에서 해제된다.)

 

 

싱글턴으로 선언된  CCPoolManager에서 관리되면 CCPoolManager가 메모리에서 해제될때 CCPoolManager의 객체들을 전부

release()해주므로 CCPoolManager의 객체중 m_uReference가 1인 것들은 0이되고 자동으로 delete가 된다.

autoRelease는 보통 create()메서드 (2.0이상부터는 전부 create로 변경되었다.) 로 호출되는건 전부 라고 생각하면 된다.

CCNode * node = CCNode::create(); 이런식으로 호출하면 된다.

 

 

CCNode * CCNode::create(void)

{

CCNode * pRet = new CCNode();

pRet->autorelease();

return pRet;

}

 

 

 

CCObject* CCObject::autorelease(void)

{

    CCPoolManager::sharedPoolManager()->addObject(this);

    return this;

}

Trackback 0 And Comment 0

구글 인앱 빌링 ver 3 item already owned 오류시 해결방법

|
소비형 아이템의 경우 구매를 할시 오류가 나면 이미 구매한 상품이라는 오류가 뜨면서 재구매가 안되는 현상이 있습니다.
oncreate() 에서 queryInventoryAsync를 실행시킨후
getPurchase 를 호출 하고 consumeAsync를 호출하면 소비형아이템이 정상적으로 구매가 됩니다.


oncreate()
       mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
               if (!result.isSuccess()) {
                  // Oh noes, there was a problem.
                  Log.d(TAG, "Problem setting up In-app Billing: " + result);
               }            
                  // Hooray, IAB is fully set up!
               mHelper.queryInventoryAsync(mGotInventoryListener);
            }
         });


// Listener that's called when we finish querying the items and subscriptions we own
    IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
            Log.d(TAG, "Query inventory finished.");
            if (result.isFailure()) {
        //        complain("Failed to query inventory: " + result);
                return;
            }

            // Check for gas delivery -- if we own gas, we should fill up the tank immediately
            Purchase gasPurchase = inventory.getPurchase(SKU_GAS);
            if (gasPurchase != null && verifyDeveloperPayload(gasPurchase)) {
                Log.d(TAG, "We have gas. Consuming it.");
                mHelper.consumeAsync(inventory.getPurchase(SKU_GAS), mConsumeFinishedListener);
                return;
            }
        }
    };


Trackback 0 And Comment 0

cocos2d-x 멀티해상도 지원

|

그림파일 이미지 해상도 960*640 (그림은 480*320으로 되있지만 960*640 이미지이다.)

디자인 해상도 480*320 (실제 작업 해상도) 터치좌표 반영되는 해상도 이다

디바이스 해상도 800*480 (가장 보편적인 디바이스 해상도 갤s 기준)

 kResolutionExactFit.png

 

 

kResolutionNoBorder.png

 

kResolutionShowAll.png

 

 

 

 

1. noborder - 2번째

화면은 가득차지만 일부영역은 보여주지 못한다. 가로 세로 증가하는(Scale) 비율은 같다.

 

2. showAll -3 번째

전체 그림을 화면 안에 다 보여준다. 레터박스가 보일수 있으며 , 가로 세로 증가하는 비율은 같다.

 

3. ExactFit - 1번째

전체 그림을 화면 안에 다 보여준다. 가로 세로 증가하는 비율이 다르다.

 

 

 

 

CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

 

visibleSize 실제 화면에 보이는 해상도

origin 짤린 해상도 기준으로 시작하는 x,y 좌표

 

일반적으로 개발자는 noborder(테두리없음) 을 많이사용한다고 한다.

 

터치좌표 기준

1.noborder은

visibleSize [480, 288]

origin [-0, 16]

짤린하면은 총 32픽셀

480*320 해상도 기준(DESIGN_RESOLUTION) 으로 17~304까지 터치가 먹히고

위아래 16포인트는 터치가 안먹힌다. (짤린화면은 총 32픽셀)

origin 시작지점 16부터

2.showAll은

visibleSize [480, 320]

origin [0, 0]

검은색 짤린 화면은 터치가 안먹히고 보여지는 해상도내에서 480*320내에는 다 터치가 먹힌다.

3.ExactFit은

visibleSize [480, 320]

origin [0, 0]

전부 터치가 먹힘

 

 

Trackback 0 And Comment 0

구글 안드로이드 인앱결제 관련 인앱빌링 ver3 적용

|



Trackback 0 And Comment 0

[블로그] 더블 클릭시 맨 하단으로 이동하는 코드입니다.

|

head에다가 집어 넣어줍시다.

  

 <script language=javascript>

 <!--

 toggle=0;

 function dblclick() {

     if (toggle==0) {

         var sc=99999; toggle=1;

     } else {

         var sc=0; toggle=0;

     }


     window.scrollTo(0,sc);

 }


 if (document.layers) {

     document.captureEvents(Event.ONDBLCLICK);

 }

 document.ondblclick=dblclick;


 var IE = document.all?true:false;

 if (!IE) document.captureEvents(Event.MOUSEMOVE)

 document.onmousemove = getMouseXY;


 var tempX = 0;

 var tempY = 0;


 function getMouseXY(e) {

     if (IE) { // grab the x-y pos.s if browser is IE

         tempX = event.clientX + document.body.scrollLeft;

         tempY = event.clientY + document.body.scrollTop;

     } else { // grab the x-y pos.s if browser is NS

         tempX = e.pageX;

         tempY = e.pageY;

     }


     if (tempX < 0){tempX = 0;}

     if (tempY < 0){tempY = 0;}

     return true;

 }

 // -->

 </script>


Trackback 0 And Comment 0

동기화 비동기화 동기식 비동기식 이란?

|

동기화란 말이 다방면에서 사용하고 있어서 개념을 잡기가 좀 어렵습니다.

비동기식이니 동기식이라는 말도 있고요.

 

동기화를 이해할려면 클라이언트와 서버라는 개념을 먼저 이해해야 합니다.

클라이언트에서 작업을 요청하면 서버에서 응답하는 형식이죠.

그런데 이 응답하는 방식에 따라 동기식이니 비동기식이라고 합니다.

 

여기서 동기식은 클라이언트의 요청이 있어야만 서버가 응답을 보내고

서버의 응답을  기다리다가 응답이 와야만 그에 따라 클라이언트가 반응하는 방식으로 서버와 클라이언트의 작업을 하나로 일치시키는 방식입니다.

요청과 응답,응답과 작업, 다시 요청과 반응 이라는 식이죠.

 

폴더의 자료를 최신으로 유지하는 것도 클라이언트에서 자료갱신을 요청하면 서버에서 응답해서 최신자료를 보내주고 클라이언트 받아서 갱신하는 것입니다.(하나의 작업으로 일치시켜서 작동하는 동기식입니다.)

 

일반화하면 어떤 작업을 하기 위해 두 개의 별개의 장치간에 시간적으로 동시에 하나의 연결을 만드는 것입니다.

그렇게하면 두 개의 장치 안의 자료가 시간적으로 일치하게 됩니다.

이런 방식은 시간적으로 데이타가 서로 일치해야 하는 경우에 꼭 필요한 방식입니다.

예를 들어 은행계좌 입출금시 동기화식으로 데이타가 처리됩니다.

만약 비동기식으로 처리된다면 CD기에서 출금을 했는데 은행의 중앙컴퓨터에서는 처리가 안 되어 있게 되는 자료의 불일치성이 나타나게 됩니다.

 



출처: http://www.open21.kr/bbs/board.php?bo_table=terminology&wr_id=51&page=1


이 개념은 네트워크나 컴퓨터 구조에서 아주아주아주아주~ 많이 쓰이는 개념이거든요..

동기화는 시간에 딱딱 맞춰서 무슨 일을 진행시키는 것을 말합니다.

대한민국 군인들은 모두 아침 6시에 일어나서 8시에 일을 하고 11시쯤에 밥을 먹고 5시 30분부터 휴식을 취한 후 밤 10시에 취침에 들죠. 이런게 바로 동기화의 예입니다. 기준(보통은 시간입니다.)에 맞춰서 동작이 딱딱 이루어지죠.

네트워크에서 송신측과 수신측이 동기화되어있다고 말하는데, 한마디로 어떤 시간에 누가 데이터를 보내는지 모두 알고 있다는 뜻입니다. 맨처음 1분은 A가 데이터를 보내고 그다음 1분은 B가 데이터를 보내고 그다음 1분은 C가 데이터를 보낸다는 걸 송신측과 수신측 모두 알고 있기때문에 누가 데이터를 보내고 있는지에 대한 혼란이 없죠. 

전산쪽에서는 TDM 이라는 방식이 있거든요. 각각의 source(데이터를 보내는 쪽)는 자신에게 주어신 시간동안만 데이터를 전송할 수 있도록 디자인되어있는데 대표적인 동기화 방식이라고 할 수 있습니당.



그리고 비동기식은 어떤 기준에 맞춰서 데이터가 전송되는게 아니라, 필요할때마다 그때그때 데이터를 전송하는 거죠... 그때그때 데이터를 보내야 하기때문에 가장 큰 문제는 지금 전송되는 데이터가 누구에게 도착하는 것이고 또 누가 보내고 있는지, 그 길이는 어느정도인지(어디까지만 받아야 하는지) 를 결정해야 해요. 따라서 보내기 전에 "내가 이제부터 A에게 보내려고 한다"라고 알려주고, 다 보내고 나면 "이제 다 보냈다" 라는 것 등을 알려줘야 해요. 

게다가 동시에 여러명이 보내려고 할 수도 있겠죠. 동기식에서는 기준에 맞춰서 보내는 순서가 있으니까 질서가 잡혀있지만 비동기식에서는 이런 순서가 없으니까 한마디로 개판이라고 할 수 있져..^^;;(서로 보내겠다고 난리치는 경우도 있을수 있을거에요..) 따라서 비동기화가 질서를 잡는데 더 어렵죠..


그렇다고 동기화가 더 좋은건 아니에요. 동기화는 매 단위시간마다 데이터를 전송할 수 있는 송신자가 정해져 있는데, 만일 B는 더이상 보낼 데이터가 없어도 자신에게 주어진 시간은 여전히 B만 데이터를 보낼 수 있어서 많은 데이터를 보내야 하는 다른 송신자들은 데이터 전송에 더 오랜 시간이 걸릴 수 밖에 없어요.(효율성이 많이 떨어진다는 얘기이기도 하죠..)

양쪽 모두 일장일단이 있으니까 주어진 환경에 맞게 어느 방식을 써야할지 결정해야 하겠죠..
 
 
 
 
*동기식 synchronous (transmission) 

동기식 전송은 한 문자 단위가 아니라 미리 정해진 수 만큼의 문자열을 한 묶음으로 만들어서 일시에 전송하는 방법이다. 이 방법에서는 데이터와는 별도로 송신측과 수신측이 하나의 기준 클록으로 동기신호를 맞추어 동작한다. 수신측에서는 클록에 의해 비트를 구별하게 되므로, 동기식 전송을 위해서는 데이터와 클록을 위한 2회선이 필요하다. 송신측에서 2진 데이터들을 정상적인 속도로 내 보내면, 수신측에서는 클록의 한 사이클 간격으로 데이터를 인식하는 것이다. 

동기식 전송은 비동기식에 비해 전송효율이 높다는 것이 장점이지만 수신측에서 비트 계산을 해야하며, 문자를 조립하는 별도의 기억장치가 필요하므로 가격이 다소 높은 것이 단점이다

*비동기식 asynchronous (transmission) 

에디터 내에 동기신호를 포함시켜 데이터를 전송한다. 송신측의 송신 클록에 관계없이 수신신호 클록으로 타임 슬롯의 간격을 식별하여 한번에 한 문자씩 송수신한다. 

이때 문자는 7~8 비트로 구성되며, 문자의 앞에 시작비트 (start bit)를, 끝에는 정지비트 (stop bit)를 첨가해서 보내는 방법이다. 

비동기식 전송은 시작비트와 정지비트 사이의 간격이 가변적이므로 불규칙적인 전송에 적합하다. 또한 필요한 접속장치와 기기들이 간단하므로 동기식전송 장비보다 값이 싸다는 장점이 있다.
 
 
 
 
 
동기식은
이력 A 가 들어가면 출력 B가 바로 나오게끔 만들어져 있게 설계 되고요

비동기식은 그렇지 않죠

비동기식은 딜레이같은 문제를 해결해야 되기땜에 더 복잡하고
기술적으로 어렵습니다.


Trackback 0 And Comment 0
prev | 1 | 2 | 3 | 4 | next