Skip to content

Commit

Permalink
Merge pull request #13 from CST-Group/gudwin
Browse files Browse the repository at this point in the history
MindViewer refactoring
  • Loading branch information
andre-paraense authored Jul 31, 2020
2 parents e3c6340 + ff98b16 commit 4101aff
Show file tree
Hide file tree
Showing 24 changed files with 2,426 additions and 523 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Welcome to the CST Toolkit pages.

The [CST Toolkit](http://cst.fee.unicamp.br) is a Java-based toolkit to allow the construction of Cognitive Architectures. It has been developed at the [University of Campinas](http://www.dca.fee.unicamp.br) by a group of researchers in the field of Cognitive Architectures leaded by Prof. [Ricardo Gudwin](http://faculty.dca.fee.unicamp.br/gudwin).
The [CST Toolkit](http://cst.fee.unicamp.br) is a Java-based toolkit to allow the construction of Cognitive Architectures. It has been developed at the [University of Campinas](http://www.dca.fee.unicamp.br) by a group of researchers in the field of Cognitive Architectures led by Prof. [Ricardo Gudwin](http://faculty.dca.fee.unicamp.br/gudwin).

Note: This library is still under development, and some concepts or features might not be available yet. [Feedback/bug report](https://github.com/CST-Group/cst/issues) and [Pull Requests](https://github.com/CST-Group/cst/pulls) are most welcome!

Expand All @@ -28,7 +28,7 @@ Note: This library is still under development, and some concepts or features mig
```
dependencies {
...
implementation 'com.github.CST-Group:cst:0.4.0'
implementation 'com.github.CST-Group:cst:0.5.0'
}
```

Expand All @@ -53,7 +53,7 @@ Sometimes, the version number (tag) in this README gets out of date, as maintain
<dependency>
<groupId>com.github.CST-Group</groupId>
<artifactId>cst</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</dependency>
```

Expand Down
17 changes: 15 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "CST is the Cognitive Systems Toolkit, a toolkit for the construct

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '0.4.0'
version = '0.5.0'

repositories {
flatDir {
Expand Down Expand Up @@ -80,6 +80,11 @@ jar {
from {
configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Class-Path': configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}

task javadocJar(type: Jar) {
Expand All @@ -96,9 +101,17 @@ task sourcesJar(type: Jar) {
configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
}
task uberJar(type: Jar) {
archiveClassifier = 'full'
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
artifacts
{
archives javadocJar, sourcesJar
archives javadocJar, sourcesJar, uberJar
}

jacocoTestReport {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public RosServiceClientCodelet(String nodeName, String service, String messageSe

serviceResponseListener = new ServiceResponseListener<T>() {
@Override
public void onSuccess(T response) {
public void onSuccess(T response) {
if(response != null) {
processServiceResponse(response);
callInProgressSemaphore.release();
Expand All @@ -83,7 +83,7 @@ public void onSuccess(T response) {

@Override
public void onFailure(RemoteException e) {
e.printStackTrace();
e.printStackTrace();
}
};

Expand All @@ -93,22 +93,22 @@ public void onFailure(RemoteException e) {

@Override
public synchronized void start() {
startRosNode();
startRosNode();
super.start();
}

@Override
public synchronized void stop() {
stopRosNode();
stopRosNode();
super.stop();
}

private void startRosNode() {
nodeMainExecutor.execute(this, nodeConfiguration);
nodeMainExecutor.execute(this, nodeConfiguration);
}

private void stopRosNode() {
serviceClient = null;
serviceClient = null;
serviceMessageRequest = null;
nodeMainExecutor.shutdownNodeMain(this);
}
Expand Down Expand Up @@ -185,7 +185,6 @@ public void onStart(ConnectedNode connectedNode) {

@Override
public void onShutdown(Node node) {
// empty
}

@Override
Expand Down
97 changes: 69 additions & 28 deletions src/main/java/br/unicamp/cst/core/entities/Mind.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
package br.unicamp.cst.core.entities;

import br.unicamp.cst.bindings.soar.PlansSubsystemModule;
import br.unicamp.cst.motivational.MotivationalSubsystemModule;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

/**
* This class represents the Mind of the agent, wrapping all the CST's core
Expand All @@ -24,10 +25,8 @@
public class Mind {

protected CodeRack codeRack;

protected RawMemory rawMemory;

private MotivationalSubsystemModule motivationalSubsystemModule;
protected ConcurrentHashMap<String,ArrayList> codelets;

private PlansSubsystemModule plansSubsystemModule;

Expand All @@ -36,11 +35,8 @@ public class Mind {
*/
public Mind() {
codeRack = new CodeRack();

rawMemory = new RawMemory();

motivationalSubsystemModule = new MotivationalSubsystemModule();

codelets = new ConcurrentHashMap();
plansSubsystemModule = new PlansSubsystemModule();
}

Expand All @@ -62,6 +58,35 @@ public synchronized RawMemory getRawMemory() {
return rawMemory;
}

/**
* Creates a Codelet Group
*
* @param groupName The Group name
*
*/
public synchronized void createCodeletGroup(String groupName) {
ArrayList<Codelet> group = new ArrayList<Codelet>();
codelets.put(groupName,group);
}

/**
* Returns the full HashMap which for every group Name it is associated a list of codelets
*
* @return the HashMap with all pairs (groupname,list of codelets belonging to groupname)
*/
public ConcurrentHashMap<String,ArrayList> getGroups() {
return(codelets);
}

/**
* Returns the number of registered groups
*
* @return the number of registered groups
*/
public int getGroupsNumber() {
return(codelets.size());
}

/**
* Creates a Memory Container inside the Mind of a given type.
*
Expand Down Expand Up @@ -122,10 +147,45 @@ public synchronized MemoryObject createMemoryObject(String name) {
public Codelet insertCodelet(Codelet co) {
if (codeRack != null)
codeRack.addCodelet(co);

return co;
}

/**
* Inserts the Codelet passed in the Mind's CodeRack.
*
* @param co the Codelet to be inserted in the Mind
* @param groupName the Codelet group name
* @return the Codelet.
*/
public Codelet insertCodelet(Codelet co, String groupName) {
insertCodelet(co);
registerCodelet(co,groupName);
return co;
}

/**
* Register a Codelet within a group
*
* @param co the Codelet
* @param groupName the group name
*/
public void registerCodelet(Codelet co, String groupName) {
ArrayList<Codelet> groupList = codelets.get(groupName);
if (groupList != null) groupList.add(co);
}


/**
* Get a list of all Codelets belonging to a group
*
* @param groupName the group name to which the Codelets belong
* @return A list of all codelets belonging to the group indicated by groupName
*/
public ArrayList<Codelet> getGroupList(String groupName) {
return(codelets.get(groupName));
}


/**
* Starts all codelets in coderack.
*/
Expand All @@ -142,25 +202,6 @@ public void shutDown() {
codeRack.shutDown();
}

/**
* Gets the Motivational Subsystem Module.
*
* @return the motivationalSubsystemModule.
*/
public MotivationalSubsystemModule getMotivationalSubsystemModule() {
return motivationalSubsystemModule;
}

/**
* Sets the Motivational Subsystem Module.
*
* @param motivationalSubsystemModule
* the motivationalSubsystemModule to set.
*/
public void setMotivationalSubsystemModule(MotivationalSubsystemModule motivationalSubsystemModule) {
this.motivationalSubsystemModule = motivationalSubsystemModule;
}

/**
* Gets the Plans Subsystem Module.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public boolean isPerformed() {

/**
* This, set performed attribute and composes the behavior proposition string from attributes of class.
* @param performed
* @param performed
*/
public void setPerformed(boolean performed) {
//System.out.println("##### Trying to set performed to "+performed+" ########");
Expand Down
Loading

0 comments on commit 4101aff

Please sign in to comment.