Example #1
0
// Najde souvislou komponentu (hrany chape oboustrane) z vrcholu n
// Spocita jeji velikost (do size)
// V ramci komponenty prideli vrcholum poradova cisla (MatrixPos)
// Vsem vrcholum nastavi Component na root
void CKerNamesMain::FindComponent(CKerName *n, CKerName *root, int &size){
	CKerNameList *p;
	n->MatrixPos = size;
	size++;
	n->Component = root;
	p =  n->parents;
	while (p) {
		if (p->name->Component==0) FindComponent(p->name,root,size);
		p=p->next;
	}
	p =  n->childs;
	while (p) {
		if (p->name->Component==0) FindComponent(p->name,root,size);
		p=p->next;
	}
}
Example #2
0
void * FindComponentStruct(ARCHETYPE * pArchetype, COMPONENTTYPE DesiredType)
{
  COMPONENT * pComponent;
  pComponent = FindComponent(pArchetype, DesiredType);
  if (pComponent) return pComponent->pStruct;
  else return NULL;
}
Example #3
0
void Entity::DetachComponent(CRC name)
{
	Component* component = FindComponent(name);
	if (component)
	{
		DetachComponent(component);
	}
}
Example #4
0
void Entity::AttachComponent(Component* component)
{
	Dbg_Assert(component != NULL);
	Dbg_Assert(FindComponent(component) == NULL);

	m_components.insert(STL::pair<CRC, Component*>(component->GetName(), component));
	component->Attach(this);
}
Example #5
0
//--------------------------------------------------------------------------------------------------
bool IsComponent
(
    const std::string& name,    ///< The path to check.
    const std::list<std::string> searchPathList ///< List of component search directory paths.
)
//--------------------------------------------------------------------------------------------------
{
    return (FindComponent(name, searchPathList) != "");
}
Example #6
0
void TLevWrt::Clear_All_Cells()
{
for (int i = 1; i <= 121; i++)
 {
  String comp_name = compPanel + IntToStr(i);
  TComponent* comp = FindComponent(comp_name);
  TPanel* panel = dynamic_cast<TPanel*>(comp);
  panel->Caption = "";
  panel->Color = clBtnFace;
  panel->Font->Color = clBlack;
 }
}
Example #7
0
			int Storage::AddComponent (int repoId, const QString& component, bool returnId)
			{
				QueryAddRepoComponent_.bindValue (":repo_id", repoId);
				QueryAddRepoComponent_.bindValue (":component", component);
				if (!QueryAddRepoComponent_.exec ())
				{
					Util::DBLock::DumpError (QueryAddRepoComponent_);
					throw std::runtime_error ("Query execution failed.");
				}

				QueryAddRepoComponent_.finish ();

				if (!returnId)
					 return 0;

				return FindComponent (repoId, component);
			}
Example #8
0
void __fastcall TEntryForm::FormActivate(TObject *Sender)
{
  if (firstTime)
  {
    firstTime = false;
    if (isDelete)
      FocusControl(CancelButton);
    else if (isAdd)
    {
      TControl *Control = (TWinControl*)FindComponent("Edit0");
      TEditPlus* Edit = dynamic_cast<TEditPlus*>(Control);
      if (Edit != 0 && Edit->ReadOnly != true)
        FocusControl(Edit);
    }
    else if (isDisplay)
      CancelButton->Visible = false;
  }
}
Example #9
0
//---------------------------------------------------------------------------
void __fastcall TLevWrt::OpnDlg1Click(TObject *Sender)
{
OpenImageDialog->Execute();
String fn = OpenImageDialog->FileName;
if (fn != "")
{
String s = dynamic_cast<TButton*>(Sender)->Name;
String p;
for (int i = s.Length(); i > 0; i--)
{
if (s[i] != 'g') p.Insert(s[i], 0);
else break;
}
String comp_name = compFilePath + p;
TComponent* comp = NULL;
if (StrToInt(p) <= 7)
comp = FindComponent(comp_name); else
comp = Application->FindComponent(comp_name);
if (comp != NULL)
dynamic_cast<TEdit*>(comp)->Text = fn;
}
}
Example #10
0
// Vytvori Matici
// Matice = Pole o velikosti MatrixSize (=Numbers+1) pointeru na ruzne velka pole charu
// Slouzi k rychlemu porovnani dvou jmen
// Kdyz jsou jmena ve stejnych komponentach, tak informace o jejich vztahu bude v
// Matrix[jm1->numer][jm2->MatrixPos]. Viz Funkce Compare
void CKerNamesMain::CreateMatrix() {
	int f;
	CKerNameList *p;
	CKerName *root;
	int size;
	ClearMatrix();
	MatrixSize=Numbers+1;
	// vytvorim prvni rozmer matice
	Matrix = new char*[MatrixSize];
	for (f=0;f<MatrixSize;f++) Matrix[f]=0;
	// Smazu informaci o komponente u vsech jmen
	p=Names;
	while (p) {
		p->name->Component=0;
		p=p->next;
	}
	p=Names;
	// pro vsechny jmena
	while (p) {
		root = p->name;
		if (root->Component==0) {
			// jmeno dosud nebylo v zadne komponente. Najdu tuto komponenu.
			// spocitam jeji velikost, jmenum priradim poradova cisla a pridam je do komponenty
			size = 0;
			FindComponent(root,root,size);
			root->matrixsize=size; // nastavim velikost komponenty
		} else size = root->Component->matrixsize; // prectu si velikost komponenty
		Matrix[root->number] = new char[size]; // pridam sloupec do matice
		for (f=0;f<size;f++) Matrix[root->number][f] = 0;
		SearchDown(root,Matrix[root->number]);
		SearchUp(root,Matrix[root->number]); // a spocitam jeho hodnoty
		p=p->next;
	}
	MatrixesCalculated = 1;
	FindMethodsAndParams();
}
Example #11
0
void __fastcall TFrmUserDataView::BtnUserParameter1Click(TObject *Sender)
{
    int nIndex = dynamic_cast<TComponent *>(Sender)->Tag;

	for(int i=0; i<4; i++)
	{
    	TSpeedButton  *CloneUserBtn = (TSpeedButton *)FindComponent("BtnUserParameter"+IntToStr(i+1));
    	if((i+1) == nIndex)
        {
			CloneUserBtn->Enabled = false;
            nPKGCategoryStartNo = (50*i)+100;
            nDDMCategoryStartNo = (50*i)+100;
        }
        else
        {
            CloneUserBtn->Enabled = true;
        }
    }
    UserParamDataLoad();
    UserData_ReadFromDB();

    UserData_PKG_ReadFromDB();
    UserData_PKG_ReadFromSEQ();
}
Example #12
0
//--------------------------------------------------------------------------------------------------
void ParseComponent
(
    Component* componentPtr,            ///< The Component object to populate.
    const BuildParams_t& buildParams    ///< Build parameters obtained from the command line.
)
//--------------------------------------------------------------------------------------------------
{
    ComponentPtr = componentPtr;
    BuildParamsPtr = &buildParams;

    // Open the component's Component.cdef file for reading.
    std::string path = FindComponent(componentPtr->Path(), buildParams.SourceDirs());
    if (path == "")
    {
        throw Exception("Couldn't find component '" + componentPtr->Path() + "'.");
    }
    componentPtr->Path(path);

    std::string cdefFilePath = CombinePath(path, "/Component.cdef");
    FILE* file = fopen(cdefFilePath.c_str(), "r");
    if (file == NULL)
    {
        int error = errno;
        std::stringstream errorMessage;
        errorMessage << "Failed to open file '" << cdefFilePath << "'." <<
                        " Errno = " << error << "(" << strerror(error) << ").";
        throw Exception(errorMessage.str());
    }

    if (buildParams.IsVerbose())
    {
        std::cout << "Parsing '" << cdefFilePath << "'\n";
    }

    // Tell the parser to reset itself and connect to the new file stream for future parsing.
    cyy_FileName = cdefFilePath.c_str();
    cyy_IsVerbose = (BuildParamsPtr->IsVerbose() ? 1 : 0);
    cyy_EndOfFile = 0;
    cyy_ErrorCount = 0;
    cyy_set_lineno(1);
    cyy_restart(file);

    // Until the parsing is done,
    int parsingResult;
    do
    {
        // Start parsing.
        parsingResult = cyy_parse();
    }
    while ((parsingResult != 0) && (!cyy_EndOfFile));

    // Close the file
    fclose(file);

    // Halt if there were errors.
    if (cyy_ErrorCount > 0)
    {
        throw Exception("Errors encountered while parsing '" + cdefFilePath + "'.");
    }

    ComponentPtr = NULL;

    if (buildParams.IsVerbose())
    {
        std::cout << "Finished parsing '" << cdefFilePath << "'\n";
    }

    // Recursively, for each of the new component's sub-components,
    for (auto& mapEntry : componentPtr->SubComponents())
    {
        mapEntry.second = Component::FindComponent(mapEntry.first);

        // If the sub-component has not yet been parsed, create an object for it and parse it now.
        if (mapEntry.second == NULL)
        {
            mapEntry.second = Component::CreateComponent(mapEntry.first);

            ParseComponent(mapEntry.second, buildParams);
        }
    }
}
Example #13
0
			void Storage::RemoveComponent (int repoId, const QString& component)
			{
				Util::DBLock lock (DB_);
				try
				{
					lock.Init ();
				}
				catch (const std::exception& e)
				{
					qWarning () << Q_FUNC_INFO
							<< "unable to start transaction";
					throw std::runtime_error ("Unable to start transaction");
				}

				int compId = FindComponent (repoId, component);
				if (compId == -1)
				{
					qWarning () << Q_FUNC_INFO
							<< "component"
							<< component
							<< "not found.";
					throw std::runtime_error ("Requested component not found");
				}

				QSqlQuery idsSelector (DB_);
				idsSelector.prepare ("SELECT DISTINCT package_id "
						"FROM locations WHERE component_id = :component_id");
				idsSelector.bindValue (":component_id", compId);
				if (!idsSelector.exec ())
				{
					Util::DBLock::DumpError (idsSelector);
					throw std::runtime_error ("Fetching of possibly affected packages failed.");
				}

				QList<int> possiblyAffected;
				while (idsSelector.next ())
					possiblyAffected << idsSelector.value (0).toInt ();

				idsSelector.finish ();

				QSqlQuery remover (DB_);
				remover.prepare ("DELETE FROM locations WHERE component_id = :component_id;");
				remover.bindValue (":component_id", compId);
				if (!remover.exec ())
				{
					Util::DBLock::DumpError (remover);
					throw std::runtime_error ("Unable to remove component from locations.");
				}
				remover.prepare ("DELETE FROM components WHERE component_id = :component_id;");
				remover.bindValue (":component_id", compId);
				if (!remover.exec ())
				{
					Util::DBLock::DumpError (remover);
					throw std::runtime_error ("Unable to remove component from components.");
				}

				remover.finish ();

				QSqlQuery checker (DB_);
				checker.prepare ("SELECT COUNT (package_id) FROM locations WHERE package_id = :package_id;");
				Q_FOREACH (int packageId, possiblyAffected)
				{
					checker.bindValue (":package_id", packageId);
					if (!checker.exec ())
					{
						Util::DBLock::DumpError (checker);
						throw std::runtime_error ("Unable to remove check affected.");
					}

					if (!checker.next ())
					{
						qWarning () << Q_FUNC_INFO
								<< "zarroo rows";
						throw std::runtime_error ("Unable to move to the next row");
					}

					if (checker.value (0).toInt ())
						continue;

					checker.finish ();

					emit packageRemoved (packageId);

					remover.prepare ("DELETE FROM packages WHERE package_id = :package_id;");
					remover.bindValue (":package_id", packageId);
					if (!remover.exec ())
					{
						Util::DBLock::DumpError (remover);
						throw std::runtime_error ("Unable to remove orphaned package.");
					}

					remover.finish ();
				}
Example #14
0
void __fastcall TfrmMachineParam::m_dLamHeightDblClick(TObject *Sender)
{
    //pEdit->Tag X=0, Y=1, Lane Changer=2, Front Lifter=3, Rear Lifter=4

    TEdit *pEdit=(TEdit *)Sender;
    TfrmMotorCheck *pMotorCheckDlg;

    AnsiString strCap = "";
    if (pEdit->Tag == 0)
    {
        strCap = "X";
        if (!g_DIO.ReadDIBit(DI::LoadCellDown))
        {
            Application->MessageBoxA("請確認LoadCell是否在上位!!", "Confirm", MB_OK);
            return;
        }
    }
    else if (pEdit->Tag == 1)
    {
        strCap = "Y";
        if (!g_DIO.ReadDIBit(DI::LoadCellDown))
        {
            Application->MessageBoxA("請確認LoadCell是否在上位!!", "Confirm", MB_OK);
            return;
        }
    }
    else if (pEdit->Tag == 2) strCap = "Lane Changer";
    else if (pEdit->Tag == 4)
    {
        strCap = "Front Lifter";
        if (!g_DIO.ReadDIBit(DI::YAxisSafePosA) || !g_DIO.ReadDIBit(DI::YAxisSafePosB))
        {
            Application->MessageBoxA("請確認LoadCell是否在安全位置!!", "Confirm", MB_OK);
            return;
        }
    }
    else if (pEdit->Tag == 5)
    {
        strCap = "Rear Lifter";
        if (!g_DIO.ReadDIBit(DI::YAxisSafePosA) || !g_DIO.ReadDIBit(DI::YAxisSafePosB))
        {
            Application->MessageBoxA("請確認LoadCell是否在安全位置!!", "Confirm", MB_OK);
            return;
        }
    }
    else strCap = "Error!";

    pMotorCheckDlg=new TfrmMotorCheck(this);
    pMotorCheckDlg->m_nActiveAxis=pEdit->Tag;
    pMotorCheckDlg->Caption=strCap;

    AnsiString sPath = g_IniFile.m_strApplicationPath;
    sPath = StringReplace(sPath, "\\exe\\", "", TReplaceFlags());

    if (pMotorCheckDlg->m_nActiveAxis == 0)
    {
        pMotorCheckDlg->btnFWD->Glyph->LoadFromFile(sPath + "\\bmp\\right.bmp");
        pMotorCheckDlg->btnRWD->Glyph->LoadFromFile(sPath + "\\bmp\\left.bmp");
    }
    else if (pMotorCheckDlg->m_nActiveAxis == 4 || pMotorCheckDlg->m_nActiveAxis == 5)
    {
        pMotorCheckDlg->btnRWD->Glyph->LoadFromFile(sPath + "\\bmp\\down.bmp");
        pMotorCheckDlg->btnFWD->Glyph->LoadFromFile(sPath + "\\bmp\\up.bmp");
    }

    if(pMotorCheckDlg->ShowModal()==mrOk)
    {
        TEdit *pEdit2=(TEdit *)FindComponent(pEdit->Hint);
        if(pEdit2) pEdit2->Text=pMotorCheckDlg->m_dCurrPos;
        else ShowMessage("寫入失敗");
    }

    delete pMotorCheckDlg;
}
Example #15
0
//---------------------------------------------------------------------------
void TLevWrt::Save_Level(String fn)
{
      	TiXmlDocument doc;
	TiXmlElement* msg;
 	TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", "yes");
	doc.LinkEndChild(decl);

        TiXmlComment *comment1 = new TiXmlComment();
	comment1->SetValue("XML file was written using XMLLevelWriter");
	doc.LinkEndChild(comment1);
        TiXmlComment *comment2 = new TiXmlComment();
	comment2->SetValue("objects' size is 40 x 40");
	doc.LinkEndChild(comment2);

	TiXmlElement *root = new TiXmlElement("level");
	doc.LinkEndChild(root);

        const maxcomps = sunnum + cm;
        for (int i = 0; i <= maxcomps; i++)
        {
                String comp_name = compObjType + IntToStr(i);
                //
                TComponent* comp;
                if (i < 8) comp = FindComponent(comp_name); else
                comp = Application->FindComponent(comp_name);
                //
                if (comp != NULL)
                {
                TComboBox* box = dynamic_cast<TComboBox*>(comp);
                if (box->Text != "")
                {
                String comp_name2 = compFilePath + IntToStr(i);
                //
                TComponent* comp2;
                if (i < 8) comp2 = FindComponent(comp_name2); else
                comp2 = Application->FindComponent(comp_name2);
                //
                TEdit* edit = dynamic_cast<TEdit*>(comp2);
               	TiXmlElement *xfile;
	        xfile = new TiXmlElement("file");
                root->LinkEndChild(xfile);
       	        xfile->SetAttribute("type", box->Text.c_str());
        	xfile->SetAttribute("path", edit->Text.c_str());

                for (int j = 1; j <= 121; j++)  // обработка
                {
                if (i == 0)// объект - фон
                {
                 TiXmlElement *object = new TiXmlElement("object");
                	root->LinkEndChild(object);
                	object->SetAttribute("type", box->Text.c_str());
                	object->SetAttribute("dummy1", "");
                        object->SetAttribute("dummy2", "");
                 break;
                }
                   String panel_name = "Panel" + IntToStr(j);
                   TComponent* panel_comp = FindComponent(panel_name);
                   TPanel* panel = dynamic_cast<TPanel*>(panel_comp);
                   if (panel != NULL)
                   {
                   if (((box->Text == "cell") && (panel->Color != clBtnFace))
                   || (box->Text == panel->Caption)
                   || ((panel->Color == clBlack) && (box->Text == "lock")))
                   {
        TiXmlElement *object = new TiXmlElement("object");
        root->LinkEndChild(object);
        object->SetAttribute("type", box->Text.c_str());
        object->SetAttribute("x", panel->Left);
        object->SetAttribute("y", panel->Top);
                    }
                    }
                 }
                }
             }
         }
modified = false;
doc.SaveFile(fn.c_str());
}
Example #16
0
//---------------------------------------------------------------------------
void TLevWrt::Load_Level(const char *fn)
{
// этот кусок кода пожаловал сюда прямиком из myRiseOfAtlantis :)
// -> с некоторыми изменениями, конечно :)
	const char *pfile = "file", *pobject = "object", *plock = "lock",
                   *pbackground = "background", *psunp = "sun p";
	const char *elementName, *type, *path, *xp, *yp;
	float xpos, ypos;

	TiXmlDocument doc(fn);
	doc.LoadFile();
	TiXmlElement* root = doc.FirstChildElement("level");
	TiXmlElement* element = root->FirstChildElement();

	while (element != NULL)
{
	elementName = element->Value();
	if (stricmp(elementName, pfile) == 0)//file
	{
		TiXmlAttribute* fattr = element->FirstAttribute();//first attribute
		if (fattr)
		{
			type = fattr->Value();
			TiXmlAttribute* sattr = fattr->Next();//second attribute
			path = sattr->Value();
			xp = NULL;
			yp = NULL;
                if (stricmp(type, pbackground) == 0)
                {
                  ObjType0->Text = type;
                  FilePath0->Text = path;
                } else
                if (stricmp(type, plock) == 0)
                {
                  ObjType7->Text = type;
                  FilePath7->Text = path;
                } else
                if (strstr(type, psunp) != NULL)
                {
                   String s = path;
                   char *c = s.c_str();
                   Make_Objects(c);
                } else
                for (int i = 0; i <= 7; i++)
                {
                String comp_name = compObjType + IntToStr(i);
                TComponent* comp = FindComponent(comp_name);
                TComboBox* box = dynamic_cast<TComboBox*>(comp);
                if (box->Text == "")
                {
                 box->Text = type;
                 String comp_name2 = compFilePath + IntToStr(i);
                 TComponent* comp2 = FindComponent(comp_name2);
                 TEdit* edit = dynamic_cast<TEdit*>(comp2);
                 edit->Text = path;
                break;
                }
                }
		element = element->NextSiblingElement();
		}
	} else
	if (stricmp(elementName, pobject) == 0)//object
	{
		TiXmlAttribute* fattr = element->FirstAttribute();//first attribute
		if (fattr)
		{
			type = fattr->Value();
			TiXmlAttribute* sattr = fattr->Next();//second attribute
			xp = sattr->Value();
			TiXmlAttribute* tattr = sattr->Next();//third attribute
			yp = tattr->Value();
			if (xp != NULL)
			{
			xpos = atof(xp);
			}
			if (yp != NULL)
			{
			ypos = atof(yp);
			}
                        for (int i = 1; i <= 121; i++)
                        {
                         String comp_name = compPanel + IntToStr(i);
                         TComponent* comp = FindComponent(comp_name);
                         TPanel* panel = dynamic_cast<TPanel*>(comp);
                         if ((panel->Left == xpos) && (panel->Top == ypos))
                         {
                          if (stricmp(type, plock) == 0)
                          {
                           panel->Color = clBlack;
                           panel->Font->Color = clWhite;
                          } else
                          if (stricmp(type, pbackground) == 0)
                          {
                           break;
                          } else {
                          panel->Caption = type;
                          panel->Color = clWhite;
                          }
                         }
			}
		element = element->NextSiblingElement();
		}
	}
}
}