Permalink
Browse files

A bunch of interfaces for ICs.

  • Loading branch information...
1 parent e00a8db commit 0cb3514062652a99154d66577df9699d6a5e0abe @sk89q sk89q committed Mar 8, 2011
@@ -0,0 +1,44 @@
+// $Id$
+/*
+ * Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package com.sk89q.craftbook.ic;
+
+/**
+ * Represents a chip state. Chip states provide information about pin
+ * inputs and outputs.
+ *
+ * @author sk89q
+ */
+public interface ChipState {
+
+ /**
+ * Gets the value at a pin.
+ *
+ * @param pin
+ * @return
+ */
+ public boolean get(int pin);
+
+ /**
+ * Set a pin's value.
+ *
+ * @param pin
+ * @param value
+ */
+ public void set(int pin, boolean value);
+}
@@ -0,0 +1,44 @@
+// $Id$
+/*
+ * CraftBook
+ * Copyright (C) 2010 sk89q <http://www.sk89q.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package com.sk89q.craftbook.ic;
+
+/**
+ * Integrated circuits are represented by this interface. For self-triggered
+ * ICs, see {@link SelfTriggeredIC}.
+ *
+ * @author sk89q
+ */
+public interface IC {
+
+ /**
+ * Get the title of the IC.
+ *
+ * @return
+ */
+ public String getTitle();
+
+ /**
+ * Get a new state to use.
+ *
+ * @param chip chip state.
+ */
+ public void trigger(ChipState chip);
+
+}
@@ -0,0 +1,32 @@
+// $Id$
+/*
+ * Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package com.sk89q.craftbook.ic;
+
+import org.bukkit.block.Block;
+
+/**
+ * Factories are used to generate instances of ICs.
+ *
+ * @author sk89q
+ */
+public interface ICFactory {
+
+ public IC create(Block block);
+
+}
@@ -0,0 +1,43 @@
+// $Id$
+/*
+ * Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package com.sk89q.craftbook.ic;
+
+import org.bukkit.World;
+import org.bukkit.block.Block;
+
+/**
+ * IC families handle the logic required in figuring out where pins are
+ * located and reading them. One ICFamily instance is created and attached
+ * to the IC manager.
+ *
+ * @author sk89q
+ */
+public interface ICFamily {
+
+ /**
+ * Return a {@link ChipState} that provides an interface to access
+ * the I/O pins.
+ *
+ * @param world
+ * @param sign
+ * @return
+ */
+ public ChipState detect(World world, Block sign);
+
+}
@@ -0,0 +1,38 @@
+// $Id$
+/*
+ * Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package com.sk89q.craftbook.ic;
+
+/**
+ * Represents a self-triggered IC. Self-triggered ICs can think on their own
+ * through use of an external clock signal.
+ *
+ * @author sk89q
+ */
+public interface SelfTriggeredIC {
+
+ /**
+ * Method is called when the IC "thinks" (as triggered by an external
+ * clock signal). The given state allows for accessing the data available
+ * on the pins.
+ *
+ * @param state
+ */
+ public void think(ChipState state);
+
+}

0 comments on commit 0cb3514

Please sign in to comment.