Note that there are some explanatory texts on larger screens.

plurals
  1. POOrganizing Simple Boolean Logic Simulator - Java
    text
    copied!<p>At my work we utilize processors with boolean logic programs for an industrial application. These programs can get very long and complex. They basically consist of sets of input bits, output bits, and internal boolean bits. These bits are then used in logic statements that result in the outputs. The inputs and outputs can be either physical wire outputs or serial communication, but that's not really important.</p> <p>Here's a quick, simplified example:</p> <pre><code>Inputs: input1, input2, input3; Outputs: output1, output2, output3; Boolean: bool1, bool2, bool3; Logic: assign input1 &amp;&amp; input2 to bool1; assign input1 &amp;&amp; bool1 to output1; assign input2 &amp;&amp; input3 to bool2; assign output1 &amp;&amp; bool2 to output2; assign output1 &amp;&amp; output2 || bool2 to bool3; </code></pre> <p>So, keep in mind that I'm very new to Java. I've done quite a bit of web based programming (ruby, php, javascript, etc).</p> <p>Basically what I'd like the simulator to do is break down the formatting of the program and allow for graphically simulation. The programs can communicate to each other, and thus the simulator should be able to handle multiple programs as well (and tie the I/O together).</p> <p>My problem is getting started with organization. I'd assume that I need to have a "bit" class. This class would store whether the bit is set to TRUE or FALSE, the type of bit, the relevant equation, what processor the bit is from, etc.</p> <p>But then, I can get to the point where I have hundreds, or thousands of "bit" instances. How I can organize these bits then? If I wanted to grab all instances that are from, for example, a certain processor, how could I accomplish that? </p> <p>Also, when I change the status (TRUE or FALSE) of an input bit within the simulator, it will then update the status of several other bits. Any suggestions on this? I'd like to make this as flexible as possible because i'd like to add additional functionality. For example, certain bits can be designated as timers (it can take a certain amount of time for them to set when their conditions are met, or it can take a certain amount of time for them to drop away when their conditions are no longer met).</p> <p>My initial thought was to keep arrays or hashes of the objects and attempt to keep them organized somehow in that way. </p> <p>I'm basically looking for any suggestions. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload