Example #1
0
S_CIP_Instance *
createAssemblyObject(EIP_UINT32 pa_nInstanceID,
                     EIP_BYTE * pa_data,
                     EIP_UINT16 pa_datalength)
{
  S_CIP_Class * pstAssemblyClass;
  S_CIP_Instance * pstAssemblyInstance;
  S_CIP_Byte_Array * stAssemblyByteArray;

  if(NULL == (pstAssemblyClass = getCIPClass(CIP_ASSEMBLY_CLASS_CODE)))
    {
      if(NULL == (pstAssemblyClass = createAssemblyClass()))
        {
          return NULL;
        }
    }

  pstAssemblyInstance = addCIPInstance(pstAssemblyClass, pa_nInstanceID); /* add instances (always succeeds (or asserts))*/

  if((stAssemblyByteArray = (S_CIP_Byte_Array *) IApp_CipCalloc(1,
                                                                sizeof(S_CIP_Byte_Array))) == NULL)
    {
      return NULL; /*TODO remove assembly instance in case of error*/
    }

  stAssemblyByteArray->len = pa_datalength;
  stAssemblyByteArray->Data = pa_data;
  insertAttribute(pstAssemblyInstance, 3, CIP_BYTE_ARRAY, stAssemblyByteArray, CIP_ATTRIB_SETGETABLE);

  return pstAssemblyInstance;
}
Example #2
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	AutoPilot *ap = NULL;
	XMLModifier *xm = NULL;
	FILE *f = NULL;
	UCSChar *string = NULL; 
	int i;
    f = fopen("d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/input.vxl","rb");
	if (f==NULL)
		return 0;
	Try{
		xm = createXMLModifier();
		ap = createAutoPilot2();
		selectXPath(ap,L"/a/b");
		vg = createVTDGen();		
		vn = loadIndex (vg,f);
		bind(ap,vn);
		bind4XMLModifier(xm,vn);
		while((i=evalXPath(ap))!=-1){
			insertAttribute(xm,L" attr1='val'");
		}
		output2(xm,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/new.xml");
		free(vn->XMLDoc);		
	}Catch(e){// handle various types of exceptions here
	}
	fclose(f);		
	freeAutoPilot(ap);
	freeXMLModifier(xm);
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
Example #3
0
XmlTag::XmlTag(const char *name, const XML_Char **attrs) {
	attributes = 0;
	children = 0;
	for(int i = 0; attrs[i]; i += 2) {
		insertAttribute(attrs[i], attrs[i + 1]);
	}
	tag_name = strdup(name);
}
Example #4
0
EIP_STATUS CIP_Identity_Init()
  {
    S_CIP_Class *pClass;
    S_CIP_Instance *pInstance;

    pClass = createCIPClass(CIP_IDENTITY_CLASS_CODE, 0, /* # of non-default class attributes*/
        MASK4(1, 2, 6, 7), /* class getAttributeAll mask		CIP spec 5-2.3.2*/
        0, /* # of class services*/
        7, /* # of instance attributes*/
        MASK7(1, 2, 3, 4, 5, 6, 7), /* instance getAttributeAll mask	CIP spec 5-2.3.2*/
        1, /* # of instance services*/
        1, /* # of instances*/
        "identity", /* class name (for debug)*/
        1); /* class revision*/

    if (pClass == 0)
      return EIP_ERROR;

    pInstance = getCIPInstance(pClass, 1);

    insertAttribute(pInstance, 1, CIP_UINT, &VendorID, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 2, CIP_UINT, &DeviceType, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 3, CIP_UINT, &ProductCode, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 4, CIP_USINT_USINT, &Revison, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 5, CIP_WORD, &ID_Status, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 6, CIP_UDINT, &SerialNumber, CIP_ATTRIB_GETABLE);
    insertAttribute(pInstance, 7, CIP_SHORT_STRING, &ProductName, CIP_ATTRIB_GETABLE);

    insertService(pClass, CIP_RESET, &Reset, "Reset");

    return EIP_OK;
  }
Example #5
0
void EditEntryWidget::setupAdvanced()
{
    m_advancedUi->setupUi(m_advancedWidget);
    add(tr("Advanced"), m_advancedWidget);

    m_attachmentsModel->setEntryAttachments(m_entryAttachments);
    m_advancedUi->attachmentsView->setModel(m_attachmentsModel);
    connect(m_advancedUi->saveAttachmentButton, SIGNAL(clicked()), SLOT(saveCurrentAttachment()));
    connect(m_advancedUi->addAttachmentButton, SIGNAL(clicked()), SLOT(insertAttachment()));
    connect(m_advancedUi->removeAttachmentButton, SIGNAL(clicked()), SLOT(removeCurrentAttachment()));

    m_attributesModel->setEntryAttributes(m_entryAttributes);
    m_advancedUi->attributesView->setModel(m_attributesModel);
    connect(m_advancedUi->addAttributeButton, SIGNAL(clicked()), SLOT(insertAttribute()));
    connect(m_advancedUi->editAttributeButton, SIGNAL(clicked()), SLOT(editCurrentAttribute()));
    connect(m_advancedUi->removeAttributeButton, SIGNAL(clicked()), SLOT(removeCurrentAttribute()));
    connect(m_advancedUi->attributesView->selectionModel(),
            SIGNAL(currentChanged(QModelIndex,QModelIndex)),
            SLOT(updateCurrentAttribute()));
}
/**
 *   Sets up the dialog.
 */
void UMLEntityAttributeDialog::setupDialog()
{
    int margin = fontMetrics().height();
    QFrame *frame = new QFrame(this);
    setMainWidget(frame);
    QVBoxLayout * mainLayout = new QVBoxLayout(frame);

    m_pValuesGB = new QGroupBox(i18n("General Properties"), frame);
    QGridLayout * valuesLayout = new QGridLayout(m_pValuesGB);
    valuesLayout->setMargin(margin);
    valuesLayout->setSpacing(10);

    m_datatypeWidget = new UMLDatatypeWidget(m_pEntityAttribute);
    m_datatypeWidget->addToLayout(valuesLayout, 0);

    Dialog_Utils::makeLabeledEditField(valuesLayout, 1,
                                       m_pNameL, i18nc("name of entity attribute", "&Name:"),
                                       m_pNameLE, m_pEntityAttribute->name());

    Dialog_Utils::makeLabeledEditField(valuesLayout, 2,
                                       m_pInitialL, i18n("&Default value:"),
                                       m_pInitialLE, m_pEntityAttribute->getInitialValue());

    m_stereotypeWidget = new UMLStereotypeWidget(m_pEntityAttribute);
    m_stereotypeWidget->addToLayout(valuesLayout, 3);

    Dialog_Utils::makeLabeledEditField(valuesLayout, 4,
                                       m_pValuesL, i18n("Length/Values:"),
                                       m_pValuesLE, m_pEntityAttribute->getValues());

    m_pAutoIncrementCB = new QCheckBox(i18n("&Auto increment"), m_pValuesGB);
    m_pAutoIncrementCB->setChecked(m_pEntityAttribute->getAutoIncrement());
    valuesLayout->addWidget(m_pAutoIncrementCB, 5, 0);

    m_pNullCB = new QCheckBox(i18n("Allow &null"), m_pValuesGB);
    m_pNullCB->setChecked(m_pEntityAttribute->getNull());
    valuesLayout->addWidget(m_pNullCB, 6, 0);

    // enable/disable isNull depending on the state of Auto Increment Check Box
    slotAutoIncrementStateChanged(m_pAutoIncrementCB->isChecked());

    m_pAttributesL = new QLabel(i18n("Attributes:"), m_pValuesGB);
    valuesLayout->addWidget(m_pAttributesL, 7, 0);

    m_pAttributesCB = new KComboBox(true, m_pValuesGB);
#if QT_VERSION < 0x050000
    m_pAttributesCB->setCompletionMode(KGlobalSettings::CompletionPopup);
#endif
    valuesLayout->addWidget(m_pAttributesCB, 7, 1);
    m_pAttributesL->setBuddy(m_pAttributesCB);

    insertAttribute(m_pEntityAttribute->getAttributes());
    insertAttribute(QString::fromLatin1("binary"), m_pAttributesCB->count());
    insertAttribute(QString::fromLatin1("unsigned"), m_pAttributesCB->count());
    insertAttribute(QString::fromLatin1("unsigned zerofill"), m_pAttributesCB->count());

    mainLayout->addWidget(m_pValuesGB);

    m_pScopeGB = new QGroupBox(i18n("Indexing"), frame);
    QHBoxLayout* scopeLayout = new QHBoxLayout(m_pScopeGB);
    scopeLayout->setMargin(margin);

    m_pNoneRB = new QRadioButton(i18n("&Not Indexed"), m_pScopeGB);
    scopeLayout->addWidget(m_pNoneRB);

    /*
    m_pPublicRB = new QRadioButton(i18n("&Primary"), m_pScopeGB);
    scopeLayout->addWidget(m_pPublicRB);

    m_pProtectedRB = new QRadioButton(i18n("&Unique"), m_pScopeGB);
    scopeLayout->addWidget(m_pProtectedRB);
    */

    m_pPrivateRB = new QRadioButton(i18n("&Indexed"), m_pScopeGB);
    scopeLayout->addWidget(m_pPrivateRB);

    mainLayout->addWidget(m_pScopeGB);
    UMLEntityAttribute::DBIndex_Type scope = m_pEntityAttribute->indexType();

    /*
    if (scope == UMLEntityAttribute::Primary)
        m_pPublicRB->setChecked(true);
    else if(scope == UMLEntityAttribute::Unique)
        m_pProtectedRB->setChecked(true);
    else */

    if (scope == UMLEntityAttribute::Index)
        m_pPrivateRB->setChecked(true);
    else {
        m_pNoneRB->setChecked(true);
    }

    m_pNameLE->setFocus();
    connect(m_pNameLE, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)));
    connect(m_pAutoIncrementCB, SIGNAL(clicked(bool)), this, SLOT(slotAutoIncrementStateChanged(bool)));
    slotNameChanged(m_pNameLE->text());
}
Example #7
0
static void saveSettings(WMWidget *button, void *client_data)
{
	InspectorPanel *panel = (InspectorPanel *) client_data;
	WWindow *wwin = panel->inspected;
	WDDomain *db = w_global.domain.window_attr;
	WMPropList *dict = NULL;
	WMPropList *winDic, *appDic, *value, *value1, *key = NULL, *key2;
	char *icon_file, *buf1, *buf2;
	int flags = 0, i = 0, different = 0, different2 = 0;

	/* Save will apply the changes and save them */
	applySettings(panel->applyBtn, panel);

	if (WMGetButtonSelected(panel->instRb) != 0) {
		key = WMCreatePLString(wwin->wm_instance);
	} else if (WMGetButtonSelected(panel->clsRb) != 0) {
		key = WMCreatePLString(wwin->wm_class);
	} else if (WMGetButtonSelected(panel->bothRb) != 0) {
		buf1 = StrConcatDot(wwin->wm_instance, wwin->wm_class);
		key = WMCreatePLString(buf1);
		wfree(buf1);
	} else if (WMGetButtonSelected(panel->defaultRb) != 0) {
		key = WMRetainPropList(AnyWindow);
		flags = UPDATE_DEFAULTS;
	}

	if (!key)
		return;

	dict = db->dictionary;
	if (!dict) {
		dict = WMCreatePLDictionary(NULL, NULL);
		if (dict) {
			db->dictionary = dict;
		} else {
			WMReleasePropList(key);
			return;
		}
	}

	if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD) < 0)
		return;

	WMPLSetCaseSensitive(True);

	winDic = WMCreatePLDictionary(NULL, NULL);
	appDic = WMCreatePLDictionary(NULL, NULL);

	/* Save the icon info */
	/* The flag "Ignore client suplied icon is not selected" */
	buf1 = wmalloc(4);
	snprintf(buf1, 4, "%s", (WMGetButtonSelected(panel->alwChk) != 0) ? "Yes" : "No");
	value1 = WMCreatePLString(buf1);
	different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value1, flags);
	WMReleasePropList(value1);
	wfree(buf1);

	/* The icon filename (if exists) */
	icon_file = WMGetTextFieldText(panel->fileText);
	if (icon_file != NULL) {
		if (icon_file[0] != '\0') {
			value = WMCreatePLString(icon_file);
			different |= insertAttribute(dict, winDic, AIcon, value, flags);
			different2 |= insertAttribute(dict, appDic, AIcon, value, flags);
			WMReleasePropList(value);
		}
		wfree(icon_file);
	}

	i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
	if (i >= 0 && i < w_global.workspace.count) {
		value = WMCreatePLString(w_global.workspace.array[i]->name);
		different |= insertAttribute(dict, winDic, AStartWorkspace, value, flags);
		WMReleasePropList(value);
	}

	flags |= IS_BOOLEAN;

	value = (WMGetButtonSelected(panel->attrChk[0]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoTitlebar, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[1]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoResizebar, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[2]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoCloseButton, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[3]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMiniaturizeButton, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[4]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoBorder, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[5]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepOnTop, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[6]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepOnBottom, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[7]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AOmnipresent, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[8]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AStartMiniaturized, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[9]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AStartMaximized, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[10]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AFullMaximize, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[0]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoKeyBindings, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[1]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMouseBindings, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[2]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ASkipWindowList, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[3]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ASkipSwitchPanel, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[4]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AUnfocusable, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[5]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepInsideScreen, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[6]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoHideOthers, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[7]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ADontSaveSession, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[8]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AEmulateAppIcon, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[9]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AFocusAcrossWorkspace, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[10]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMiniaturizable, value, flags);

#ifdef XKB_BUTTON_HINT
	value = (WMGetButtonSelected(panel->moreChk[11]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoLanguageButton, value, flags);
#endif

	if (wwin->main_window != None && wApplicationOf(wwin->main_window) != NULL) {
		value = (WMGetButtonSelected(panel->appChk[0]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, AStartHidden, value, flags);

		value = (WMGetButtonSelected(panel->appChk[1]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, ANoAppIcon, value, flags);

		value = (WMGetButtonSelected(panel->appChk[2]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, ASharedAppIcon, value, flags);
	}

	if (wwin->fake_group) {
		key2 = WMCreatePLString(wwin->fake_group->identifier);
		if (WMIsPropListEqualTo(key, key2)) {
			WMMergePLDictionaries(winDic, appDic, True);
			different |= different2;
		} else {
			WMRemoveFromPLDictionary(dict, key2);
			if (different2)
				WMPutInPLDictionary(dict, key2, appDic);
		}
		WMReleasePropList(key2);
	} else if (wwin->main_window != wwin->client_win) {
		WApplication *wapp = wApplicationOf(wwin->main_window);

		if (wapp) {
			buf2 = StrConcatDot(wapp->main_window_desc->wm_instance,
					      wapp->main_window_desc->wm_class);
			key2 = WMCreatePLString(buf2);
			wfree(buf2);

			if (WMIsPropListEqualTo(key, key2)) {
				WMMergePLDictionaries(winDic, appDic, True);
				different |= different2;
			} else {
				WMRemoveFromPLDictionary(dict, key2);
				if (different2)
					WMPutInPLDictionary(dict, key2, appDic);
			}
			WMReleasePropList(key2);
		}
	} else {
		WMMergePLDictionaries(winDic, appDic, True);
		different |= different2;
	}
	WMReleasePropList(appDic);

	WMRemoveFromPLDictionary(dict, key);
	if (different)
		WMPutInPLDictionary(dict, key, winDic);

	WMReleasePropList(key);
	WMReleasePropList(winDic);

	UpdateDomainFile(db);

	/* clean up */
	WMPLSetCaseSensitive(False);
}