Wednesday, July 13, 2016

Robo4j updatelog: 201607132242 - from command to Consumers and Producers

  

  Robo4j framework has received new major update of the core logic and architecture. The small first taste has been already mention in previous blog post as simple sketch. The sketch has pictured the relation between RoboUnits and RobotAgents. In simplified written words the RoboUnit contains the number of agents. Those agents are interacting between each other and providing the result of the RoboUnit according to its assignment.  
  Let's focused little bit on RoboAgents. RoboAgents behaviour can be simplified as the relation between Producers and Consumers. 
  The Producers are basically providing result of the external inputs to the Consumers. External Producers inputs can be defined by Sensors or the result of the external computation/process. 
  On the other-hand Consumers are applying desired logic on such inputs. Consumers are allowed to use bounded resources, which are provided to the RoboUnit. 

   Current Robo4j framework release contains 1st simple example of RoboUnit implementation by implementing Robo Front-Hand. The front-hand unit is located in the front part of the robot and it's able to carry small things. 
  The Robo Front-hand consists from one engine and one touch sensor. This is enough to employ Producer Consumer scenario where the sensors provides appropriate data to the consumer which is represented by the engine. 
@RoboUnit(value = FrontHandUnit.UNIT_NAME,
        system = FrontHandUnit.SYSTEM_NAME,
        producer= FrontHandUnit.PRODUCER_NAME,
        consumer= FrontHandUnit.CONSUMER_NAME)
public class FrontHandUnit extends DefaultUnit implements LegoUnit {
    /* all connected pars  */
    private static final int CONNECTED_ELEMENTS = 2;
    private static final int DEFAULT_SPEED = 300;
    private static final int AGENT_POSITION = 0;
    static final String UNIT_NAME = "frontHandUnit";
    static final String SYSTEM_NAME = "legoBrick1";
    static final String PRODUCER_NAME = "frontHandSensor";
    static final String CONSUMER_NAME = "frontHand";


    ... 
    @Override
    public LegoUnit init(...

            this.agents.add(createAgent(
                    "frontHandAgent",
                    new FrontHandTouchProducer(exchanger, sensorCache.entrySet()
                            .stream()
                            .filter(sensorEntry -> sensorEntry.getValue()
                              .getPart().equals(LegoEnginePartEnum.HAND))
                            .map(Map.Entry::getValue)
                            .map(legoSensor -> 
                               createTouchSensor(legoBrickRemote, 
                                 legoSensor.getPort()))
                            .reduce(null, (e1, e2) > e2)),

                    new FrontHandEngineConsumer(exchanger,  engineCache.entrySet()
                            .stream()
                            .filter(entry -> entry.getValue()
                               .getPart().equals(LegoEnginePartEnum.HAND))
                            .map(Map.Entry::getValue)
                            .map(legoEngine -> 
                                createEngine(legoBrickRemote, 
                                  legoEngine.getPort(), DEFAULT_SPEED))
                            .reduce(null, (e1, e2) > e2))));
    ...
    @SuppressWarnings(value = "unchecked")
    @Override
    public boolean process(RoboUnitCommand command){

        if(!active.get()){
            return false;
        }

        ProcessAgent processAgent = (ProcessAgent) agents.get(AGENT_POSITION);
        return processAgent.process(command, (cm) -> {
            final FrontHandCommandEnum commandEnum = (FrontHandCommandEnum)cm;
            return logic.get(commandEnum).apply(processAgent);
        }).getStatus().equals(AgentStatusEnum.ACTIVE);

    }
    ...
    @SuppressWarnings(value = "unchecked")
    @Override
    protected Map<RoboUnitCommand, Function<ProcessAgent, AgentStatus > > initLogic(){
        final Map<RoboUnitCommand, Function<ProcessAgent, AgentStatus > > result = new HashMap< >();
        result.put(FrontHandCommandEnum.COMMAND, (ProcessAgent agent) -> {
            agent.setActive(true);
            agent.getExecutor().execute((Runnable) agent.getProducer());
            final Future<Boolean> engineActive = 
                  agent.getExecutor()
                    .submit((Callable<Boolean>) agent.getConsumer());
            try {
                agent.setActive(engineActive.get());
            } catch (InterruptedException | ConcurrentModificationException 
                  | ExecutionException e) {
                      throw new 
                        FrontHandException("SOMETHING ERROR CYCLE COMMAND= ", e);
            }
            return new AgentStatus<String>(AgentStatusEnum.ACTIVE);
        });

        result.put(FrontHandCommandEnum.EXIT, (ProcessAgent agent) -> {
            FrontHandEngineConsumer consumer = (FrontHandEngineConsumer) 
             agent.getConsumer();
            FrontHandTouchProducer producer = (FrontHandTouchProducer) 
              agent.getProducer();
            try {
                consumer.getMotorHandPortA().close();
                producer.getTouchSensor().close();
            } catch (RemoteException e) {
                throw new FrontHandException("RUN ERROR PROCESS: ", e);
            }
            agent.getExecutor().shutdown();
            agent.setActive(false);
            active.set(false);
            return new AgentStatus<String>(AgentStatusEnum.OFFLINE);
        });
        return Collections.unmodifiableMap(result);
    }
    ...

  Following code has shown that RoboUnit consist from two agents one Producer and one Consumer. Producer is represented by TouchSensor and Consumer by Engine. The RoboUnit does accept two commands from outside as the input -> COMMAND and EXIT. 

 The following RoboUnit implementation allows Robo4j-Brick-Client to accept following POST request
{ 
  "commands" : [
    {"name" : "hand",
     "target" : "hand_unit",
     "value" : "command"}
  ]
}

And this is not all we can add additional properties to the command as following example 
{ 
  "commands" : [
    {"name" : "hand",
     "target" : "hand_unit",
     "value" : "command"},
     {"name" : "move",
     "target" : "platform",
     "value" : "20",
     "speed" : "400"
     }
  ]
}
...but more in the upcoming posts... 
Stay tuned!!!



   

98 comments:

  1. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!

    java training in bangalore

    ReplyDelete
    Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

    selenium training in chennai|

    ReplyDelete
  3. The young boys ended up stimulated to read through them and now have unquestionably been having fun with these things.."Devops Training in Chennai"

    ReplyDelete
  4. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    Besant technologies Marathahalli

    ReplyDelete
  5. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    full stack developer training in bangalore

    ReplyDelete
  6. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted
    digital marketing training in tambaram

    ReplyDelete
  7. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    Click here:
    python training in chennai
    Click here:
    python training in chennai

    ReplyDelete
  8. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Blueprism training in Chennai

    Blueprism training in Bangalore

    Blueprism training in Pune

    ReplyDelete
  9. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune

    ReplyDelete
  10. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
    java online training | java training in pune

    java training in chennai | java training in bangalore

    ReplyDelete
  11. mytectra placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance.

    ReplyDelete
  12. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    python training in pune | python training institute in chennai | python training in Bangalore

    ReplyDelete
  13. I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.

    Microsoft Azure online training
    Selenium online training
    Java online training
    Java Script online training
    Share Point online training

    ReplyDelete
  14. Well somehow I got to read lots of articles on your blog. It’s amazing how interesting it is for me to visit you very often.
    Devops Training in Chennai | Devops Training Institute in Chennai

    ReplyDelete
  15. This is a nice post in an interesting line of content.Thanks for sharing this article, great way of bring this topic to discussion.
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  16. Interesting information and attractive.This blog is really rocking... Yes, the post is very interesting and I really like it.I never seen articles like this. I meant it's so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job.
    Kindly visit us @
    Sathya Online Shopping
    Online AC Price | Air Conditioner Online | AC Offers Online | AC Online Shopping
    Inverter AC | Best Inverter AC | Inverter Split AC
    Buy Split AC Online | Best Split AC | Split AC Online
    LED TV Sale | Buy LED TV Online | Smart LED TV | LED TV Price
    Laptop Price | Laptops for Sale | Buy Laptop | Buy Laptop Online
    Full HD TV Price | LED HD TV Price
    Buy Ultra HD TV | Buy Ultra HD TV Online
    Buy Mobile Online | Buy Smartphone Online in India

    ReplyDelete
  17. This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.
    AI learning course malaysia

    ReplyDelete
  18. Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
    python training in bangalore

    ReplyDelete
  19. Get the best nursing services baby care services medical equipment services and allso get the physiotherapist at home in Delhi NCR For more information visit our site

    nursing attendant services in Delhi NCR
    medical equipment services in Delhi NCR
    nursing services in Delhi NCR
    physiotherapist at home in Delhi NCR
    baby care services in Delhi NCR

    ReplyDelete
  20. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab Python training in pune your rss feed to stay informed of any updates.

    ReplyDelete
  21. Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share.
    pmp certification malaysia

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. I learned World's Trending Technology from certified experts for free of cost. I Got a job in decent Top MNC Company with handsome 14 LPA salary, I have learned the World's Trending Technology from Python Training in pune experts who know advanced concepts which can help to solve any type of Real-time issues in the field of Python. Really worth trying Freelance seo expert in bangalore

    ReplyDelete
  24. Thank you so much for this useful article. Visit OGEN Infosystem for Web Designing and SEO Services in Delhi, India.
    SEO Service in Delhi

    ReplyDelete
  25. Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
    Advertising Agency
    3d Animation Services
    Branding services
    Web Design Services in Chennai
    Advertising Company in Chennai

    ReplyDelete
  26. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    Are You looking for best online courses and free webniars you just click following links
    Online Certificate Courses
    Machine Learning Online Courses
    Best Online Certificate Courses In India
    Online Courses On Digital Marketing
    Online It Courses In India

    ReplyDelete

  27. Thanks for sharing,very impressive content.If u are looking for any courses visit our site
    big data training institute in btm

    ReplyDelete
  28. Appslure is Best app development company in mumbai and you can get website development service at a very affordable price.
    App development company in mumbai

    ReplyDelete
  29. I would like to thank you for the efforts you have made in writing this post. Thanks for posting Really Such Things. I should recommend your site to my friends. If you are interested for CRM Software visit here:- CRM Software in Mumbai | CRM Software In Pune | CRM Software in Ahmedabad | Order Management Software in Mumbai | Field Management Software in Mumbai

    ReplyDelete
  30. Wow!!! It was really an Informational Article which provide me with much Insightful Information. I would like to first thank the author for such an Insightful Content. If someone here is looking for a Website Designing Company in India, then look no further than Jeewangarg.com as we are the Best website designing company in Delhi working in the arena for the last 8 years.
    Digital Marketing company in Delhi

    ReplyDelete
  31. Well I definitely enjoyed reading it. This tip procured by you is very constructive for correct planning.
    video production
    film production

    ReplyDelete
  32. Really this is awsome post, which is so informative. We are the largest shot blasting machine manufacturers & Suppliers in India. Get the all types of sandblasting machine and their equipments @ best prices & unmatched services. Call us @ 9811083740.

    ReplyDelete
  33. Thanks for posting such a great post. mostly person have many doubt that the product which is puchaging through online is really right for us! is this better product? That's why right select is standing infront of you to provide right products. Right Select help to select right products.

    Out of them: Top 10 injection molding machine manufacturers in india

    ReplyDelete
  34. Thanks for the great article and post. Need a Industrial UPS? Don’t go beyond nexusups. 10 kva online ups which offers an extensive range of exceptional Industrial UPS, and Online UPS Free to contact.

    ReplyDelete
  35. Thanks for the great article and post. Need a servo voltage stabilizer manufacturers in india? Don’t go beyond servo star “A popular 10 kva single phase voltage stabilizer which offers an extensive range of exceptional servo stabilizer. Feel Free to contact.

    ReplyDelete
  36. Hi...Thanks for sharing this useful article. RPA is the most trending now a days in Machine Learning and Artificial Intelligence. Your shared information is very useful for those who wants to shifts their business logic to robotics.Its a new upcoming technology so this information will play such a great role. And its very important to improve our knowledge for Robotics and their Architect, frameworks and logics.

    ReplyDelete
  37. Thanks for sharing such a great information, Here we are India's best service provider of sbi kiosk banking.
    csp bank mitra
    bank mitra

    ReplyDelete
  38. Dextrous Info Solutions is worldwide and Android App Development Company giving various end-to-end app development solutions at affordable pricing structure. putlocker

    ReplyDelete
  39. I have study your article, it is very informative and beneficial for me. I recognize the valuable statistics you offer in your articles. Thanks for posting it and is.
    Visit us for custom cake packaging boxes.

    ReplyDelete
  40. Airo Shot Blast is Sand Blasting Machine Manufacturer in India. We also Manufacturer, Supplier & Exporter of Shot Blasting Machine, Grit Blasting Machine, Sand Blasting Hopper in India at a low price for sale.
    See More :
    Sand Blasting Machine price in India
    Sand Blasting Machine

    ReplyDelete

  41. Thank you very much for your information. I have gained great information from your post.
    This site is a very good site. I am sure that you will benefit from this web site.
    Whatever you are looking for can be helpful. Click Here

    Thank you very much for your information.I stumbled upon your top nursing blog sites page. I have gained great information from your post.
    This site is a very good site. I am sure that you will benefit from this web site.
    Whatever you are looking for can be helpful. Click Here

    ReplyDelete
  42. Nice Blog!!!
    Here we are Manufacturers of Sand Blasting Cabinet in india.We provide all type of sand blasting machine, shot blasting machine & Grit blasting machine.
    See More:-
    Large Sand Blasting Cabinet
    Sand Blasting Machine

    ReplyDelete
  43. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
    digital marketing course in guduvanchery

    ReplyDelete
  44. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
    read more

    ReplyDelete
  45. Thanks for sharing the valuable information. Your article gave me a lot of information.I have gained great information from your post.
    This site is a very good site. I am sure that you will benefit from this web site.
    Whatever you are looking for can be helpful. Click Here

    ReplyDelete

  46. Ayonz is a Market Development Company in Sydney provides a service solution that is end-to-end like technology design, manufacturing, supply & brand development for consumer lifestyle products sold in retail, through resellers or online shopping channels.

    ReplyDelete
  47. This is one of the best work i came across today, keep it up. Your information is really appreciable.

    1000 free youtube subscribers
    SMM service

    ReplyDelete
  48. Great share!

    I love this bucket list and you know you're right. Sand blasting machine everything takes time and we all have the same amount of hours in a day so put them to good use. We all have to start somewhere and your plan is perfect. I understand the way of the attractive to the customer with the products.

    Sand Blasting Machines like shot blasting machine, sand blasting machine, and grit blasting machines, Wood Working Machinery Dust Extraction unit, Abrasive Blasting Media and various others. Keep it works and share with us your latest information. My time will come but I know I'm on the right path.

    They are similar to small communities that you own - check them out if you haven't already. It's all got a lot better than before!t.Value that list of thousands but I'll get there.

    Thanks for sharing. Have a nice week ahead.


    Regards,
    Ankit Sharma.

    ReplyDelete
  49. Worth reading! Our experts also have given detailed inputs about these trainings & courses! Presenting here for your reference. Do checkout
    oracle training in chennai & enjoy learning more about it.

    ReplyDelete
  50. Cool stuff you have and you keep overhaul every one of us
    data science training in delhi

    ReplyDelete
  51. Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Data Science Training in Chennai & get to know everything you want to about software trainings.

    ReplyDelete
  52. AMO is an award winning home loans specialist. Our mortgage brokers have helped thousands of ordinary Australians to secure finance for home or investment property.

    ReplyDelete
  53. Nice. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also event management and event vendor agreement template

    ReplyDelete
  54. Amazing! The post is full of new information and ideas useful for the readers. Go ahead keep it up, being the leading mobile app development company, we are willing to introduce our specialized efforts in order to bring revolution in human welfare. mobile application development company. You can email us at sales@appsquadz.com or call us at +91-9717270746

    ReplyDelete
  55. Thanks for posting the best information and the blog is very helpful.python course in Bangalore

    ReplyDelete
  56. Extraordinary blog. I took pleasure in scrutinizing your articles. This is extremely a wonderful scrutinized for me. I have bookmarked it and I am suspecting scrutinizing new articles. Continue doing amazing!
    muttertag lustige bilder

    ReplyDelete
  57. This is very interesting, You are a very skilled blogger. I've joined your feed and look ahead to searching for extra of your excellent post. Also, I have shared your website in my social network new years 2021
    l shaped gaming desk
    NehaaGallerina Shop

    ReplyDelete
  58. It’а†s really a great and helpful piece of info. adipurush film
    I’а†m happy that you simply shared this helpful info with us. sarkaru vaari paata download
    Please keep us informed like this. Thanks for sharing. salaar film

    ReplyDelete
  59. I do not even know how I ended up here, hari hara veera mallu download
    but I thought this post was great. central government schemes
    I don't know who you are but definitely you are going to a famous blogger if you are not already telugu box office

    ReplyDelete
  60. I am really very happy to visit your blog. apsrtc bus pass
    Now I am found which I actually want. pongal
    I check your blog every day and try to learn something from your blog. andhra pradesh food
    Thank you and waiting for your new post. government jobs online

    ReplyDelete
  61. Great post! Thanks for sharing. I like your content its unique and interesting, I have been always a fan of those who have this unique talent of writing unique content. Best solicitor in London.

    ReplyDelete
  62. that list of thousands but I'll get there.
    Big Hunter Mod Apk

    ReplyDelete
  63. In addition to improving efficiency, compliance, transparency, and financial integrity, we offer services across the full lifecycle of financial transactions. With experience in areas such as Credit Risk, Liquidity Measurement, Stress Testing, Counterparty Credit Risk, and Risk Reporting, our diversified team has you covered.
    Buy Score Cryptocurrency Online

    ReplyDelete
  64. A great cryptocurrency to invest in is Score, where you will get a high return on investment. Invest in cryptocurrency today, don't delay.

    Cryptocurrency Investment Company in UK

    Cryptocurrency Investment Company in India

    ReplyDelete
  65. Great post! Thanks for sharing. I like your content its unique and interesting, I have been always a fan of those who have this unique talent of writing unique content
    digital marketing agency pakistan

    ReplyDelete
  66. I like your content its unique and interesting, Best Private School in Bulandshahr I have been always a fan of those who have this unique talent of writing unique content . Best CBSE School in Bulandshahr

    ReplyDelete
  67. Read the comments that have already been made an immense power, Best Properties in Gurgaon Exclusive Gurgaon properties for sale at limited edition. Best Real Estate Agent In Gurgaon

    ReplyDelete
  68. Chennai's best training institute, Infycle Technologies, offers the No.1 Hadoop training in Chennai for tech professionals & students along with other courses such as Python, Oracle, Selenium, Java, Hadoop, iOS, and Android development with 100% hands-on training. Once the completion of training, the students will be sent for placement interviews in the core MNC's. Call 7504633633 to get more info and a free demo.Top Hadoop Training in Chennai | Infycle Technologies

    ReplyDelete
  69. This post is very simple to read and appreciate without leaving any details out. Great work!
    data scientist course aurangabad

    ReplyDelete
  70. Infycle Technologies, the top software training institute and placement center in Chennai offers the Best Digital Marketing course in Chennai for freshers, students, and tech professionals at the best offers. In addition to Digital Marketing, other in-demand courses such as DevOps, Data Science, Python, Selenium, Big Data, Java, Power BI, Oracle will also be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  71. Thank you for sharing this valuable knowledge; it will be of great benefit to myself and many others. This is something I can share with my friends. Keep up to date...

    digital marketing course in hyderabad
    digital marketing training in hyderabad

    ReplyDelete
  72. This is a fabulous post I saw because of it. It is really what I expected to see trust in future you will continue in sharing such a mind boggling post
    data scientist training and placement in hyderabad

    ReplyDelete
  73. Small and large companies worldwide can benefit from the Design Trip's branding services. Our branding team will contact you, as soon as possible, following completion of the form or visiting our website, to discuss your branding requirements.

    Branding Services
    Digital Marketing Services

    ReplyDelete