public void executeAction(DataSets.dsModuleStructure3.dtActionValueRow row) { if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.OPEN) { byte pourcentage = Convert.ToByte(row.description); Dynamixel2CANQueue.openGripper(pourcentage); //DynamixelCom.sendInstruction(INST_OPEN_GRIPPER); } //else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.CLOSE) //{ // DynamixelCom.sendInstruction(INST_CLOSE_GRIPPER); //} else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.TILT) { Dynamixel2CANQueue.TiltGripper(UInt16.Parse(row.description)); //DynamixelCom.sendInstruction(INST_TILT, UInt16.Parse(row.description)); } //else if(row.dtActionTypeRow.pk_id == DBManager.ActionTypes.ROTATE) //{ // DynamixelCom.sendInstruction(INST_ROTATE, UInt16.Parse(row.description)); //} //else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.SPEED) //{ // String[] values = row.description.Split(','); // byte id = byte.Parse(values[0]); // UInt16 speed = UInt16.Parse(values[1]); // DynamixelCom.sendInstruction(INST_SET_MOVING_SPEED, id, speed); //} //else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.TORQUE) //{ // //String[] values = row.description.Split(','); // //byte id = byte.Parse(values[0]); // //UInt16 torque = UInt16.Parse(values[1]); // Dynamixel2CANQueue.setMaxTorque() // //DynamixelCom.sendInstruction(INST_SET_MOVING_SPEED, id, torque); //} //else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.TORQUE_ENABLE) //{ // // DynamixelCom.sendInstruction(INST_SET_TORQUE_ENABLE, UInt16.Parse(row.description)); //} else if (row.dtActionTypeRow.pk_id == DBManager.ActionTypes.DELAY_MS) { System.Threading.Thread.Sleep(Int32.Parse(row.description)); } else if (row.dtActionTypeRow.pk_id == MOVE_Z3) { Int16 tempValue = 0; if (Int16.TryParse(row.description, out tempValue)) { DynamixelCom.sendPositionToMoveTo(tempValue); } } else if (row.dtActionTypeRow.pk_id == HOME) { DynamixelCom.homeTool(); } }
private void crudOptionsAction_ModifyClickHandler(object sender, EventArgs e) { abstractDialog dialog = new abstractDialog("Action type", "Modify"); DataSets.dsModuleStructure3.dtActionValueRow row = getSelectedActionRow(); if (row == null) { return; } namedInputTextBox index = new namedInputTextBox("Index: ", row.index.ToString()); namedInputTextBox description = new namedInputTextBox("Description", row.description); namedComboBox ActionType = new namedComboBox("Action Type: "); namedComboBox ActionValueType = new namedComboBox("Action Value Type: "); ActionType.Text = "Action Type"; ActionType.getComboBox().DataSource = dsModuleStructureGUI.dtActionType; ActionType.getComboBox().ValueMember = "pk_id"; ActionType.getComboBox().DisplayMember = "description"; ActionType.getComboBox().SelectedValue = row.fk_action_type; ActionValueType.Text = "Action Value Type"; ActionValueType.getComboBox().DataSource = dsModuleStructureGUI.dtActionValueType; ActionValueType.getComboBox().ValueMember = "pk_id"; ActionValueType.getComboBox().DisplayMember = "description"; ActionValueType.getComboBox().SelectedValue = row.fk_action_value_type; dialog.addNamedInputTextBox(index); dialog.addNamedInputTextBox(description); dialog.addControl(ActionType); dialog.addControl(ActionValueType); dialog.ShowDialog(); DataSets.dsModuleStructure3.dtActionTypeRow Actionrow; DataRowView ActionCombo = ActionType.getComboBox().SelectedItem as DataRowView; Actionrow = ActionCombo.Row as DataSets.dsModuleStructure3.dtActionTypeRow; DataSets.dsModuleStructure3.dtActionValueTypeRow ActionValueTyperow; DataRowView ActionValueTypecombo = ActionValueType.getComboBox().SelectedItem as DataRowView; ActionValueTyperow = ActionValueTypecombo.Row as DataSets.dsModuleStructure3.dtActionValueTypeRow; if (dialog.DialogResult.Equals(DialogResult.OK)) { row.index = string.IsNullOrEmpty(index.getInputTextValue()) ? 0 : int.Parse(index.getInputTextValue()); row.description = description.getInputTextValue(); row.fk_action_type = Actionrow.pk_id; row.fk_action_value_type = ActionValueTyperow.pk_id; updateActionRow(row); } }
public void updateRow(DataSets.dsModuleStructure3.dtActionValueRow updateRow) { try { taActionValue.Update(updateRow); } catch (Exception ex) { MessageBox.Show("Invalid step composite row, try again !", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); _dsModuleStructure.RejectChanges(); } }
public void updateActionRow(DataSets.dsModuleStructure3.dtActionValueRow updateRow) { try { taActionValue1.Update(updateRow); } catch (Exception ex) { MessageBox.Show("Invalid action type, try again !", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); dsModuleStructureGUI.RejectChanges(); } }
public void executeAction(DataSets.dsModuleStructure3.dtActionValueRow row) { if (row.dtActionTypeRow.pk_id == PIPETTE) { Int16 volume = 0; if (Int16.TryParse(row.description, out volume)) { SingleChannelPipette.pipette(volume); wait.Reset(); wait.WaitOne(); Int16 delay = Convert.ToInt16(row.description); System.Threading.Thread.Sleep(delay / 2); } } else if (row.dtActionTypeRow.pk_id == DISPENSE) { Int16 volume = 0; if (Int16.TryParse(row.description, out volume)) { SingleChannelPipette.dispense(volume); wait.Reset(); wait.WaitOne(); Int16 delay = Convert.ToInt16(row.description); System.Threading.Thread.Sleep(delay / 2); } } else if (row.dtActionTypeRow.pk_id == MOVE_Z1) { Int16 tempValue = 0; if (Int16.TryParse(row.description, out tempValue)) { SingleChannelPipette.sendPositionToMoveTo(tempValue); wait.Reset(); wait.WaitOne(); } } else if (row.dtActionTypeRow.pk_id == HOME) { SingleChannelPipette.homeTool(); wait.Reset(); wait.WaitOne(); } }
public void executeAction(DataSets.dsModuleStructure3.dtActionValueRow action) { int moduleTypeId = action.dtStepLeafRow.dtStepCompositeRow.dtModuleRow.dtModuleTypeRow.pk_id; if (moduleTypeId == TOOL_HOLDER) { movement.move(action); } else if (moduleTypeId == PINCE) { pince.executeAction(action); } else if (moduleTypeId == SNGLE_CHANNEL_PIPETTE) { singleChannePipette.executeAction(action); } else if (moduleTypeId == MULTI_CHANNEL_PIPETTE) { multiChannelPipette.executeAction(action); } }
private void AutoFillToolStripMenuItem_Click(object sender, EventArgs e) { String protocolType = ((ToolStripMenuItem)sender).Text; //dialog result for adding new node to treeview DialogResult dialogResultAddNode = DialogResult.Cancel; frmNewProtocol frmProtocolAdd; frmNewStep _frmNewStep; TreeNode treeNode = new TreeNode(); switch (protocolType) { case PROTOCOL_TYPE: frmProtocolAdd = new frmNewProtocol(); dialogResultAddNode = frmProtocolAdd.ShowDialog(); if (dialogResultAddNode == DialogResult.OK) { //treeNodeText = frmProtocolAdd.getStepName(); DataSets.dsModuleStructure3.dtStepCompositeRow compositeRow = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow(); DataSets.dsModuleStructure3.dtModuleRow module = getSelectedModuleRow(); if (module == null) { return; } if (module.pk_id.Length == 0) { return; } compositeRow.fk_module_id = module.pk_id; compositeRow.description = frmProtocolAdd.getStepName(); if (tlvSteps.SelectedNode != null) { if (tlvSteps.SelectedNode is StepCompositeNode) { StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode; compositeRow.fk_step_parent_id = stepCompositeNode.getStepCompositeRow().pk_id; } } _dsModuleStructure.dtStepComposite.AdddtStepCompositeRow(compositeRow); updateRow(compositeRow); treeNode = new Steps.Parameter_controls.StepCompositeNode(compositeRow); } break; case STEP_TYPE: DataSets.dsModuleStructure3.dtModuleRow moduleRow = getSelectedModuleRow(); DataSets.dsModuleStructure3.dtStepCompositeRow c = _dsModuleStructure.dtStepComposite.NewdtStepCompositeRow(); if (moduleRow == null) { break; } c.fk_module_id = moduleRow.pk_id; //c.fk String headerTitle = moduleRow.pk_id.ToString(); _frmNewStep = new frmNewStep(_dsModuleStructure, moduleRow); dialogResultAddNode = _frmNewStep.ShowDialog(); if (dialogResultAddNode.Equals(DialogResult.OK)) { if (tlvSteps.SelectedNode is StepCompositeNode) { StepCompositeNode stepCompositeNode = tlvSteps.SelectedNode as StepCompositeNode; DataSets.dsModuleStructure3.dtStepLeafRow stepLeafRow = _dsModuleStructure.dtStepLeaf.NewdtStepLeafRow(); stepLeafRow.fk_step_composite = stepCompositeNode.getStepCompositeRow().pk_id; stepLeafRow.description = _frmNewStep.getStepDescription(); _dsModuleStructure.dtStepLeaf.AdddtStepLeafRow(stepLeafRow); updateRow(stepLeafRow); treeNode = new StepLeafNode(stepLeafRow, _dsModuleStructure.dtActionValue); Dictionary <dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> command = _frmNewStep.getActionValues(); foreach (KeyValuePair <dsModuleStructure3.dtModuleTypeActionTypeRow, ctrlCommand> kvp in command) { Dictionary <dsModuleStructure3.dtActionTypeRow, namedInputTextBox> actionTypeInputBoxDict = kvp.Value.getActionTypesValues(); foreach (KeyValuePair <dsModuleStructure3.dtActionTypeRow, namedInputTextBox> kvpActionType in actionTypeInputBoxDict) { if (kvpActionType.Value.getInputTextValue().Length != 0) { DataSets.dsModuleStructure3.dtActionValueRow actionValue = _dsModuleStructure.dtActionValue.NewdtActionValueRow(); actionValue.fk_action_type = kvpActionType.Key.pk_id; actionValue.fk_action_value_type = kvp.Key.dtActionValueTypeRow.pk_id; actionValue.fk_step_leaf_id = stepLeafRow.pk_id; actionValue.description = kvpActionType.Value.getInputTextValue(); _dsModuleStructure.dtActionValue.AdddtActionValueRow(actionValue); updateRow(actionValue); } } } } } break; default: break; } if (dialogResultAddNode.Equals(DialogResult.OK)) { if (tlvSteps.SelectedNode != null) { tlvSteps.SelectedNode.Nodes.Add(treeNode); } else { tlvSteps.Nodes.Add(treeNode); } } }
public void move(DataSets.dsModuleStructure3.dtActionValueRow actionValue) { if (actionValue.fk_action_type == SET_TARGET_TEMPERATURE) { byte[] toSend = new byte[8]; String[] values = actionValue.description.Split(','); toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x00; // Instruction number: 0 --> Set target temperature toSend[3] = 0x00; // Spare byte toSend[4] = byte.Parse(values[0]); toSend[5] = byte.Parse(values[1]); toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == SET_AGITATOR_SPEED) { byte[] toSend = new byte[8]; String[] values = actionValue.description.Split(','); byte speed = byte.Parse(values[0]); if (speed > 100) { speed = 100; } else if (speed < 0) // Not sure if required.... { speed = 0; } toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x01; // Instruction number: 1 --> Set agitator speed toSend[3] = 0x00; // Spare byte toSend[4] = speed; // Agitator speed in % toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == SET_FAN_SPEED) { byte[] toSend = new byte[8]; String[] values = actionValue.description.Split(','); byte speed = byte.Parse(values[0]); if (speed > 100) { speed = 100; } else if (speed < 0) { speed = 0; } toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x02; // Instruction number: 2 --> Set fan speed toSend[3] = 0x00; // Spare byte toSend[4] = speed; // Desired speed in % toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == START_CALIBRATION) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x03; // Instruction number: 3 --> Start calibration toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == STOP_CALIBRATION) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x04; // Instruction number: 4 --> Stop calibration toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == START_TEMPERATURE_MAINTAIN) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x05; // Instruction number: 5 --> Start temperature maintain toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == STOP_TEMPERATURE_MAINTAIN) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x06; // Instruction number: 6 --> Stop temperature maintain toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == ENABLE_FAN) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x07; // Instruction number: 7 --> Start fan toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == DISABLE_FAN) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x08; // Instruction number: 8 --> Stop fan toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == ENABLE_AGITATOR) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x09; // Instruction number: 9 --> Start fan toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == DISABLE_AGITATOR) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x0A; // Instruction number: 10 --> Stop fan toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == GET_FAN_SPEED) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x0D; // Instruction number: 13 --> Get fan speed toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == GET_TEMPERATURE) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x0E; // Instruction number: 14 --> Get temperature toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } else if (actionValue.fk_action_type == GET_TURBIDITY) { byte[] toSend = new byte[8]; toSend[0] = 0x00; // Will be replaced by something like byte.Parse(values[0]); // Device ID toSend[1] = 0x01; // Submodule ID toSend[2] = 0x0F; // Instruction number: 15 --> Get fan speed toSend[3] = 0x00; // Spare byte toSend[4] = 0x00; // Unused toSend[5] = 0x00; // Unused toSend[6] = 0x00; // Unused toSend[7] = 0x00; // Unused TacComm.sendInstruction(toSend); } acknowledgeEvent.Reset(); acknowledgeEvent.WaitOne(); }
public void move(DataSets.dsModuleStructure3.dtActionValueRow actionValue) { if (actionValue.fk_action_type == MOVE_X) { //String value = "X" + Int32.Parse(actionValue.description) + '\n'; //String value = "G1 X" + Int32.Parse(actionValue.description) / 10 + " F" + desiredXSpeed + "\n"; String value = "G1 X" + Int32.Parse(actionValue.description) / 10; write(value); wait.WaitOne(); } else if (actionValue.fk_action_type == MOVE_Y) { //String value = "Y" + Int32.Parse(actionValue.description) + '\n'; //String value = "G1 Y" + Int32.Parse(actionValue.description) / 10 + " F" + desiredYSpeed + "\n"; String value = "G1 Y" + Int32.Parse(actionValue.description) / 10; write(value); wait.WaitOne(); } else if (actionValue.fk_action_type == MOVE_Z1) { Int16 tempValue = 0; if (Int16.TryParse(actionValue.description, out tempValue)) { SingleChannelPipette.sendPositionToMoveTo(tempValue); wait.WaitOne(); } //serial.Write("Z1" + Int32.Parse(actionValue.description) + '\n'); } else if (actionValue.fk_action_type == MOVE_Z2) { Int16 tempValue = 0; if (Int16.TryParse(actionValue.description, out tempValue)) { MultiChannelPipette.sendPositionToMoveTo(tempValue); wait.WaitOne(); } //serial.Write("Z2" + Int32.Parse(actionValue.description) + '\n'); } else if (actionValue.fk_action_type == MOVE_Z3) { Int16 tempValue = 0; if (Int16.TryParse(actionValue.description, out tempValue)) { DynamixelCom.sendPositionToMoveTo(tempValue); wait.WaitOne(); } //serial.Write("Z3" + Int32.Parse(actionValue.description) + '\n'); } else if (actionValue.fk_action_type == HOME) { switch (actionValue.description) { case "X": //write("HX",1); write("G28 X"); wait.WaitOne(); break; case "Y": //write("HY",1); write("G28 Y"); wait.WaitOne(); break; case "Z1": SingleChannelPipette.homeTool(); wait.WaitOne(); break; case "Z2": MultiChannelPipette.homeTool(); wait.WaitOne(); break; case "Z3": DynamixelCom.homeTool(); wait.WaitOne(); break; default: break; } //if (actionValue.description == //serial.Write("H" + actionValue.description + '\n'); } }