//
// Displays the values from memory in the GUI.
//
void CPageDisk::ShowData()
{
	Manager	*manager;
	Worker	*worker;

	// Only enable the display if a disk worker or a manager with disk 
	// interfaces is selected.
	manager = theApp.pView->m_pWorkerView->GetSelectedManager();
	worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
	if (( theApp.pView->m_pWorkerView->GetSelectedType() == ALL_MANAGERS) ||
		( manager && !manager->InterfaceCount( GenericDiskType ) ) ||
		( worker && !IsType( worker->Type(), GenericDiskType ) ) )
	{
		Reset();
		return;
	}

	// This is a new view of the target assignment.  
	// It has not been modified.
	selected = NULL;
	highlighted = NULL;
	// Show the target list.
	ShowTargets();
	// Set the target selection check boxes.
	ShowTargetSelection();
	// Bold the last selected item.
	ShowFocus();
	// Show the connection rate settings.
	ShowConnectionRate();
	// Show the disk specific settings.
	ShowSettings();
	// Enable the apropriate windows and redraw the page.
	EnableWindow();
}
Example #2
0
//
// Stores the targets that have been selected by the user with the appropriate
// worker.
//
void CPageDisk::StoreTargetSelection()
{
    HTREEITEM hdisk;
    Manager *manager;
    Worker *worker;
    int target = 0;
    int next_worker;

    // Get the selected manager and worker.
    manager = theApp.pView->m_pWorkerView->GetSelectedManager();
    worker = theApp.pView->m_pWorkerView->GetSelectedWorker();

    // Make sure we have a selected manager (or worker).
    if (!manager) {
        ErrorMessage("Unexpectedly found no selected manager in " "CPageDisk::StoreTargetSelection.");
        return;
    }

    if (worker) {
        // Assign the targets to the selected worker in the order that they
        // appear in the GUI.
        worker->RemoveTargets(GenericDiskType);
        for (hdisk = m_TTargets.GetRootItem(); hdisk; hdisk = m_TTargets.GetNextSiblingItem(hdisk)) {
            if (GetSelectionCheck(hdisk) == TargetChecked)
                worker->AddTarget(manager->GetInterface(target, GenericDiskType));
            target++;
        }
    } else {
        // Clear the assigned targets from all the manager's workers.
        manager->RemoveTargets(GenericDiskType);

        // Set the first worker to receive targets.
        worker = manager->GetWorker(0, GenericDiskType);
        next_worker = 0;

        // Assign the targets to the workers of the selected manager.
        for (hdisk = m_TTargets.GetRootItem(); hdisk; hdisk = m_TTargets.GetNextSiblingItem(hdisk)) {
            // If the disk is selected in the GUI, assign it to the expected
            // worker.
            if (GetSelectionCheck(hdisk) == TargetChecked) {
                worker->AddTarget(manager->GetInterface(target, GenericDiskType));

                // Update who the next worker to receive a target is.
                if (++next_worker >= manager->WorkerCount(GenericDiskType))
                    next_worker = 0;
                worker = manager->GetWorker(next_worker, GenericDiskType);
            }
            target++;
        }
    }
    ShowTargetSelection();
}
void CPageNetwork::OnSelchangeDInterface()
{
	Manager *manager;
	Worker *worker;

	switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
	case WORKER:
		worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
		worker->SetLocalNetworkInterface(m_DInterface.GetCurSel());
		break;
	case MANAGER:
		manager = theApp.pView->m_pWorkerView->GetSelectedManager();
		manager->SetLocalNetworkInterface(m_DInterface.GetCurSel());
		break;
	}

	ShowTargets();
	ShowTargetSelection();
	ShowSettings();
	EnableWindow();
}
void CPageNetwork::StoreTargetSelection()
{
	HTREEITEM hmgr, hifc;
	Manager *manager;
	Worker *worker;
	Target_Spec new_target;
	int local_interface_no;
	int interface_no;
	int target_count = 0;
	int expected_worker = 0;

	// Make sure we have a selected manager (or worker).
	manager = theApp.pView->m_pWorkerView->GetSelectedManager();
	if (!manager) {
		ErrorMessage("Unexpectedly found no selected manager in " "CPageNetwork::StoreTargetSelection.");
		return;
	}
	// Count the number of assigned targets.
	for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) {
		for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) {
			if (GetSelectionCheck(hifc) == TargetChecked)
				target_count++;
		}
	}

	// Make sure we are not assigning more targets than we have workers.
	if (target_count > manager->WorkerCount(GenericServerType)) {
		ErrorMessage("You do not have enough network workers to assign all " "the selected targets.");
		// Restore the last selection.
		ShowTargetSelection();
		// Set the focus to the target list.
		::SetFocus(m_TTargets);
		return;
	}
	// The selection will succeed.  Remove current network clients.
	if (worker = theApp.pView->m_pWorkerView->GetSelectedWorker())
		worker->RemoveTargets(GenericNetType);
	else
		manager->RemoveTargets(GenericNetType);

	// Get the assigned local interface to use for the connection.
	local_interface_no = m_DInterface.GetCurSel();

	// Assign the targets.
	// Loop through all managers.
	for (hmgr = m_TTargets.GetRootItem(); hmgr; hmgr = m_TTargets.GetNextSiblingItem(hmgr)) {
		// Loop through all interfaces of a manager.
		interface_no = 0;
		for (hifc = m_TTargets.GetChildItem(hmgr); hifc; hifc = m_TTargets.GetNextSiblingItem(hifc)) {
			if (GetSelectionCheck(hifc) == TargetChecked) {
				// Are we dealing with a worker or a manager?
				if (!worker) {
					// A manager is selected.  Get the next available 
					// network server worker.
					worker = manager->GetWorker(expected_worker++, GenericServerType);

				}
				// Get the interface of the selected target from the manager
				// whose interface is selected.
				memcpy(&new_target,
				       ((Manager *) m_TTargets.GetItemData(hmgr))->GetInterface(interface_no,
												GenericNetType),
				       sizeof(Target_Spec));

				// Set the local and remote addresses of the connection.
				// The remote address used by the server is stored as the local
				// address for some manager's interface.
				if (IsType(new_target.type, TCPClientType)) {
					strcpy(new_target.tcp_info.remote_address, new_target.name);

					// Verify that the locally assigned interface matches the
					// selected target's interface.
					if (local_interface_no >= manager->InterfaceCount(GenericTCPType)) {
						// Use the first TCP interface.
						local_interface_no = 0;
						m_DInterface.SetCurSel(local_interface_no);
					}
				} else if (IsType(new_target.type, VIClientType)) {
					strcpy(new_target.vi_info.remote_nic_name, new_target.name);
					memcpy(&new_target.vi_info.remote_address,
					       &new_target.vi_info.local_address, VI_ADDRESS_SIZE);

					// Verify that the locally assigned interface matches the
					// selected target's interface.
					if (local_interface_no <= manager->InterfaceCount(GenericTCPType)) {
						// Use the first VI interface.
						local_interface_no = manager->InterfaceCount(GenericTCPType);
						m_DInterface.SetCurSel(local_interface_no);
					}
				} else {
					ErrorMessage("Invalid target type for new target in "
						     "CPageNetwork::StoreTargetSelection().");
				}
				worker->AddTarget(&new_target);

				// Record information about what local interface the server
				// should use.
				worker->SetLocalNetworkInterface(local_interface_no);

				// Create the corresponding network client.
				worker->CreateNetClient((Manager *)
							m_TTargets.GetItemData(hmgr), new_target.type);

				// Clear the worker pointer so that the next iteration
				// through the loop (for a manager with multiple selected
				// interfaces) will get the next available network server.
				worker = NULL;
			}
			interface_no++;
		}
	}
}