示例#1
0
//>>===========================================================================
bool RELATIONSHIP_CLASS::commit(string		  sopClassUid,
								string		  sopInstanceUid,
								LOG_CLASS	* logger_ptr)
//  DESCRIPTION     : Commit the storage if the sop instance can be found.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	STORED_SOP_INSTANCE_CLASS*	  storedSopInstance_ptr;
	bool						  result = false;

	// wait for access to warehouse
	waitSemaphore();

	// check if the sop is stored
	storedSopInstance_ptr = storedSopListM.search(sopClassUid,
												  sopInstanceUid,
												  logger_ptr);
	if (storedSopInstance_ptr)
	{
		// commit the storage
		storedSopInstance_ptr->commit();

		// return success
		result = true;
	}

	// release access to warehouse
	postSemaphore();

	// return result
	return result;
}
示例#2
0
void decreaseTimerNode(long arg0, long arg1, long arg2, long arg3, long arg4, \
        long arg5, long arg6, long arg7, long arg8, long arg9) {
    TimerNodePtr tmp_node;
    TimerItemPtr tmp_item;
    while (g_timer_switcher == 1) {
        waitSemaphore(g_timer_tick_sem);
        lockTimerGlobalInfo();
        if (g_timer_chain == NULL) {
            timer_debug("decreaseTimerNode: g_timer_chain is empty");
            unlockTimerGlobalInfo();
            continue;
        }
        tmp_node = g_timer_chain;
        timer_debug("decreaseTimerNode: before tick_num %d", tmp_node->tick_number);
        tmp_node->tick_number --;
        if (tmp_node->tick_number == 0) {
            timer_debug("decreaseTimerNode: activate timers");
            while (tmp_node->item_head != NULL) {
                tmp_item = tmp_node->item_head;
                tmp_node->item_head = tmp_item->next;
                activateTimerItem(tmp_item);
                my_free(tmp_item);
            }
            timer_debug("decreaseTimerNode: after activate");
            g_timer_chain = tmp_node->next;
            my_free(tmp_node);
        }
        timer_debug("decreaseTimerNode: end of");
        unlockTimerGlobalInfo();
    }
    timer_debug("decreaseTimerNode: $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    postSemaphore(g_timer_end_sem);
}
示例#3
0
//>>===========================================================================
UINT16 RELATIONSHIP_CLASS::analyseStorageDataset(DCM_DATASET_CLASS *dataset_ptr, 
												 string& msg, 
												 LOG_CLASS *logger_ptr,
												 bool isAcceptDuplicateImage)
//  DESCRIPTION     : Analyse the Storage Dataset.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// wait for access to warehouse
	waitSemaphore();

	UINT16 status = DCM_STATUS_PROCESSING_FAILURE;

	// analyse the Storage Dataset for the patient relationship
	patientListM.analyseStorageDataset(dataset_ptr, logger_ptr);

	// analyse the Storage Dataset for the stored sop
	status = storedSopListM.analyseStorageDataset(dataset_ptr, msg, logger_ptr, isAcceptDuplicateImage);

	// release access to warehouse
	postSemaphore();

	return status;
}
示例#4
0
bool OBJECT_WAREHOUSE_CLASS::update(string identifier, BASE_WAREHOUSE_ITEM_DATA_CLASS *updateData_ptr)

//  DESCRIPTION     : Update the data in the warehouse.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	bool result = false;
	UINT index;

	// check for valid data
	if (updateData_ptr == NULL) return false;

	// wait for access to warehouse
	waitSemaphore();

	// find the item to update
	if (search(identifier, updateData_ptr->getWidType(), &index))
	{
		// update the matching item
		BASE_WAREHOUSE_ITEM_DATA_CLASS *item_ptr = itemM[index].getItemData();
		result = item_ptr->updateWid(updateData_ptr);
	}

	// release access to warehouse
	postSemaphore();

	// return result
	return result;
}
示例#5
0
bool OBJECT_WAREHOUSE_CLASS::remove(string identifier, WID_ENUM type)

//  DESCRIPTION     : Remove data from the warehouse.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	bool result = false;
	UINT index;

	// wait for access to warehouse
	waitSemaphore();

	// search for item to remove
	if (search(identifier, type, &index))
	{
		// remove item
		BASE_WAREHOUSE_ITEM_DATA_CLASS *item_ptr = itemM[index].getItemData();
		delete item_ptr;
		itemM.removeAt(index);
		result = true;
	}

	// release access to warehouse
	postSemaphore();

	// return result
	return result;
}
示例#6
0
bool OBJECT_WAREHOUSE_CLASS::store(string identifier, BASE_WAREHOUSE_ITEM_DATA_CLASS* data_ptr)

//  DESCRIPTION     : Store given data in the warehouse.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	UINT index;

	// check for valid data
	if (data_ptr == NULL) return false;

	// wait for access to warehouse
	waitSemaphore();

	// first check if the same identifier has already been used
	if (search(identifier, data_ptr->getWidType(), &index))
	{
		// remove existing item - the new data will simply replace the old
		itemM.removeAt(index);
	}

	// store the new data
	WAREHOUSE_ITEM_CLASS newData(identifier, data_ptr);
	itemM.add(newData);

	// release access to warehouse
	postSemaphore();

	// return result
	return true;
}
示例#7
0
void OBJECT_WAREHOUSE_CLASS::empty()

//  DESCRIPTION     : Empty the warehouse of all stored items.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// wait for access to warehouse
	waitSemaphore();

	// destructor activities
	while (itemM.getSize())
	{
		// remove warehouse item
		itemM.removeAt(0);
	}

	// reset the reference tag
	referenceTagM = TAG_UNDEFINED;

	// release access to warehouse
	postSemaphore();
}
示例#8
0
void increaseTick(long arg) {
    static int count = 0;
    /* timer_debug("startTimer: start to forwarding the timer cout: %d", count); */
    count ++;
    if (count == 1) {
        postSemaphore(g_timer_tick_sem);
        count = 0;
    }
}
示例#9
0
//>>===========================================================================
void RELATIONSHIP_CLASS::logObjectRelationshipAnalysis(LOG_CLASS *logger_ptr)
//  DESCRIPTION     : Log the Object Relationship Analysis.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// wait for access to warehouse
	waitSemaphore();

	// log the patient list
	patientListM.log(logger_ptr);

	// log the stored sop list
	storedSopListM.log(logger_ptr);

	// release access to warehouse
	postSemaphore();
}
示例#10
0
//>>===========================================================================
void RELATIONSHIP_CLASS::cleanup()
//  DESCRIPTION     : Cleanup the relationship data.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	// wait for access to warehouse
	waitSemaphore();

	// cleanup the patient list - instantiate it again
	patientListM.cleanup();

	// cleanup the stored sop list - instantiate it again
	storedSopListM.cleanup();

	// release access to warehouse
	postSemaphore();
}
示例#11
0
void activateTimerItem(TimerItemPtr ptr) {
    TaskID task_id;
    timer_debug("activateTimerItem: ptr %d, tid %d", ptr, ptr->tid);

    if (ptr->type == TIMER_SEM) {
        /* @TODO sem*/
        postSemaphore(ptr->sem);
    } else if (ptr->type != TIMER_NONE) {
        timer_debug("activateTimerItem: callback %d, args %d", ptr->callback, \
                ptr->args);
        /* @TODO call the function */
        createTask(ptr->callback, ptr->args);
        if (ptr->type == TIMER_INTERVAL) {
            timer_debug("activateTimerItem: the TIMER_INTERVAL");
            insertTimerItem(ptr->interval, ptr->type, NULL, ptr->callback, \
                    ptr->args, ptr->tid);
            timer_debug("activateTimerItem: after insert");
        } else {
            removeCallbackItem(ptr->tid);
        }
    }
}
示例#12
0
void unlockTimerGlobalInfo() {
    postSemaphore(g_timer_global_info_sem);
}
示例#13
0
void initTimerGlobalLock() {
    g_timer_global_info_sem = initSemaphore();
    postSemaphore(g_timer_global_info_sem);
}