/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : ModuleDefinition.pkg */ /* Version : 03 Juillet 2000 */ /* Module definitions functions */ /* */ /***************************************************************************************/ proto MODULE_GetOutgoingLinks = fun [Module] [Link r1];; /**************************************************************************************** definition basic search functions ****************************************************************************************/ /**************************************************************************************** return true if def name is in string list ****************************************************************************************/ fun MODULE_SearchDefName (definitionL, definitionNames)= let definitionL -> [defName _] in str_and_list_cmpi defName definitionNames ;; /**************************************************************************************** return true if def first value is string ****************************************************************************************/ fun MODULE_SearchDefValue (definitionL, definitionValue)= let definitionL -> [_ [value _]] in !strcmpi value definitionValue ;; /**************************************************************************************** return true if def name is string ****************************************************************************************/ fun defByName (def, name) = let def -> [n _] in !strcmpi n name ;; /**************************************************************************************** get def line by name ****************************************************************************************/ fun getDef (defs, name) = search_in_list defs @defByName name ;; /**************************************************************************************** return true if def name and def value correspond ****************************************************************************************/ fun MODULE_CompareDefAndVal (definitionL, param) = let param -> [defName defVal] in let definitionL -> [defN [defV _]] in (!strcmp defName defN) && (!strcmp defVal defV) ;; /**************************************************************************************** definition block access functions ****************************************************************************************/ /*************************************************************************************** Get definition block of a module Return value: [[S r1] r1] (success) or nil (failure) ***************************************************************************************/ fun MODULE_GetDefBlock (module, defName) = switchstr module.MODdefinitions defName ;; /*************************************************************************************** set a block of definition of a module if the new block value is nil then suppress the block definition Return value: 1 (success) ***************************************************************************************/ fun MODULE_SetDefBlock (module, defName, defBlock) = let remove_from_list module.MODdefinitions getDef module.MODdefinitions defName -> defs in set module.MODdefinitions = if defBlock == nil then defs else [defName defBlock]::defs; 1 ;; /*************************************************************************************** Add a line in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun MODULE_AddDefLine (module, defName, defLine) = let MODULE_GetDefBlock module defName -> defBlock in if defBlock == nil then MODULE_SetDefBlock module defName (defLine::nil) else if isf_in_list defBlock @strlist_cmpi defLine then 1 else MODULE_SetDefBlock module defName (defLine::defBlock) ;; /*************************************************************************************** Add a list of lines in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun MODULE_AddDefLineList (module, defName, listDefLine) = if listDefLine == nil then 1 else let listDefLine -> [defLine nextDefLine] in ( MODULE_AddDefLine module defName defLine; MODULE_AddDefLineList module defName nextDefLine ) ;; /*************************************************************************************** Update a line in a block of definition of a module Return value: 1 (success) ***************************************************************************************/ fun MODULE_SetDefLine (module, defName, defLineName, defLineValues) = let MODULE_GetDefBlock module defName -> defBlock in let defLineName::defLineValues -> defLine in if defLineValues == nil then MODULE_SetDefBlock module defName (removef_from_list defBlock @defByName defLineName) else MODULE_SetDefBlock module defName (f_replace_in_list defBlock @defByName defLineName defLine) ;; proto SITE_GetModuleCurrentBlackBox = fun [Site] Module;; /*************************************************************************************** other functions ***************************************************************************************/ /*************************************************************************************** return true if the DMI of the module contains the action in parameter ***************************************************************************************/ fun MODULE_SearchAction (site, module, action) = let if MODULE_IsBlackBox module then MOD_DEF_BB_OUT::MOD_DEF_BB_IN::nil else MOD_DEF_ACTION_S::MOD_DEF_ACTION_C::nil -> searchDef in let switchstr module.MODdefinitions MOD_BLOCK_DMI -> listDef in let search_all_in_list listDef @MODULE_SearchDefName searchDef -> list in (search_in_list list @MODULE_SearchDefValue action) != nil ;; /*************************************************************************************** return true if the DMI of the module contains the event in parameter ***************************************************************************************/ fun MODULE_SearchEvent (site, module, event) = let if MODULE_IsBlackBox module then MOD_DEF_BB_IN::MOD_DEF_BB_OUT::nil else MOD_DEF_EVENT_S::MOD_DEF_EVENT_C::nil -> searchDef in let switchstr module.MODdefinitions MOD_BLOCK_DMI -> listDef in let search_all_in_list listDef @MODULE_SearchDefName searchDef -> list in (search_in_list list @MODULE_SearchDefValue event) != nil ;; /*************************************************************************************** return module bitmap file name ***************************************************************************************/ fun MODULE_GetBitmapFilename (module) = let switchstr module.MODdefinitions MOD_BLOCK_DMI -> listDef in getInfo listDef MOD_DEF_BITMAP ;; proto ASSO_GetDefinitions = fun [Site [Association r1]] [[S r1]r1];; proto ASSO_SearchModuleAssociation = fun [Site Module] [Association r1];; /*************************************************************************************** update module definition with external module data ***************************************************************************************/ fun MODULE_UpdateDefinition (site, module) = if module == nil then /* ERROR NOT SENT TO END-USER */ logScsError "MODULE_UpdateDefinition" nil "Module is nil" 0 else ( MODULE_SetDefLine module MOD_BLOCK_DMI MOD_DEF_NAME (module.MODname)::nil; let module.MODposition -> [x y] in MODULE_SetDefLine module MOD_BLOCK_SCS MOD_DEF_POSITION (itoa x)::(itoa y)::nil; let ASSO_GetDefinitions site ASSO_SearchModuleAssociation site module -> assoBlock in MODULE_SetDefBlock module MOD_BLOCK_ZONE assoBlock; let LINK_GetLinksDefinitions site MODULE_GetOutgoingLinks module -> linkBlock in MODULE_SetDefBlock module MOD_BLOCK_LINK linkBlock ); 1 ;; /**************************************************************************************** * * Extract some definitions from a list of definitions * ****************************************************************************************/ fun _GetDefBlocks (module, defNameList) = let defNameList -> [first next] in if first == nil then nil else let switchstr module.MODdefinitions first -> def in if def == nil then _GetDefBlocks module next else [first def]::(_GetDefBlocks module next) ;; fun MODULE_BBcreateNewRelay (module, name, defLine) = let switchstr module.MODdefinitions MOD_BLOCK_DMI -> listDef in let search_all_in_list listDef @MODULE_SearchDefName defLine::nil -> list in if (search_in_list list @MODULE_SearchDefValue name) != nil then MODULE_BBcreateNewRelay module strcat name " relay" defLine else ( MODULE_AddDefLine module MOD_BLOCK_DMI defLine::name::nil; name ) ;; fun MODULE_ClearAssoDef (defs) = if defs == nil then nil else let defs -> [def next] in ( set def.listDEF = removef_from_list def.listDEF @defByName MOD_BLOCK_ZONE; set def.subDEF = MODULE_ClearAssoDef def.subDEF; def::(MODULE_ClearAssoDef next) ) ;;