* @brief This method is used to update this client's representation * of the input link to match what is currently on the agent's * input link. * * NOTE: This is the reverse of how a client normally uses the input link * but can be useful for tools that wish to debug or monitor changes in the input link. * * NOTE: If two clients try to modify the input link at on
| 649 | * make any guarantees about what will or won't work. |
| 650 | *************************************************************/ |
| 651 | bool WorkingMemory::SynchronizeInputLink() |
| 652 | { |
| 653 | // Not supported for direct connections |
| 654 | //if (GetConnection()->IsDirectConnection()) |
| 655 | // return false ; |
| 656 | |
| 657 | AnalyzeXML response ; |
| 658 | |
| 659 | // Call to the kernel to get the current state of the input link |
| 660 | bool ok = GetConnection()->SendAgentCommand(&response, sml_Names::kCommand_GetAllInput, GetAgentName()) ; |
| 661 | |
| 662 | if (!ok) |
| 663 | { |
| 664 | return false ; |
| 665 | } |
| 666 | |
| 667 | #ifdef _DEBUG |
| 668 | char* pStr = response.GenerateXMLString(true) ; |
| 669 | #endif |
| 670 | |
| 671 | // Erase the existing input link and create a new representation from scratch |
| 672 | delete m_InputLink ; |
| 673 | m_InputLink = NULL ; |
| 674 | |
| 675 | GetInputLink() ; |
| 676 | |
| 677 | // Get the result tag which contains the list of wmes |
| 678 | ElementXML const* pMain = response.GetResultTag() ; |
| 679 | |
| 680 | int nChildren = pMain->GetNumberChildren() ; |
| 681 | |
| 682 | ElementXML wmeXML(NULL) ; |
| 683 | ElementXML* pWmeXML = &wmeXML ; |
| 684 | |
| 685 | bool tracing = this->GetAgent()->GetKernel()->IsTracingCommunications() ; |
| 686 | |
| 687 | for (int i = 0 ; i < nChildren ; i++) |
| 688 | { |
| 689 | pMain->GetChild(&wmeXML, i) ; |
| 690 | |
| 691 | // Ignore tags that aren't wmes. |
| 692 | if (!pWmeXML->IsTag(sml_Names::kTagWME)) |
| 693 | { |
| 694 | continue ; |
| 695 | } |
| 696 | |
| 697 | // Get the wme information |
| 698 | char const* pID = pWmeXML->GetAttribute(sml_Names::kWME_Id) ; // These IDs will be kernel side ids (e.g. "I3" not "i3") |
| 699 | char const* pAttribute = pWmeXML->GetAttribute(sml_Names::kWME_Attribute) ; |
| 700 | char const* pValue = pWmeXML->GetAttribute(sml_Names::kWME_Value) ; |
| 701 | char const* pType = pWmeXML->GetAttribute(sml_Names::kWME_ValueType) ; // Can be NULL (=> string) |
| 702 | char const* pTimeTag = pWmeXML->GetAttribute(sml_Names::kWME_TimeTag) ; // These will be kernel side time tags (e.g. +5 not -7) |
| 703 | |
| 704 | // Set the default value |
| 705 | if (!pType) |
| 706 | { |
| 707 | pType = sml_Names::kTypeString ; |
| 708 | } |
nothing calls this directly
no test coverage detected