|
15 | 15 | */ |
16 | 16 |
|
17 | 17 |
|
18 | | -// TODO class type for parser? (Simhub for example) |
19 | 18 | ////////////////////////////////////////////// |
20 | 19 |
|
21 | 20 | ClassIdentifier Axis::info = { |
@@ -57,25 +56,24 @@ Axis::~Axis() |
57 | 56 | } |
58 | 57 |
|
59 | 58 | const ClassIdentifier Axis::getInfo() { |
60 | | -// ClassIdentifier newinfo = Axis::info; |
61 | | -// newinfo.unique = axis+'X'; |
| 59 | + |
62 | 60 | return info; |
63 | 61 | } |
64 | 62 |
|
65 | 63 | void Axis::registerCommands(){ |
66 | | - registerCommand("power", Axis_commands::power, "Overall force strength"); |
67 | | - registerCommand("degrees", Axis_commands::degrees, "Rotation range in deg."); |
68 | | - registerCommand("esgain", Axis_commands::esgain, "Endstop stiffness"); |
69 | | - registerCommand("zeroenc", Axis_commands::zeroenc, "Zero axis"); |
70 | | - registerCommand("invert", Axis_commands::invert, "Invert axis"); |
71 | | - registerCommand("idlespring", Axis_commands::idlespring, "Idle spring strength"); |
72 | | - registerCommand("axisdamper", Axis_commands::axisdamper, "Independent damper effect"); |
73 | | - registerCommand("enctype", Axis_commands::enctype, "Encoder type get/set/list"); |
74 | | - registerCommand("drvtype", Axis_commands::drvtype, "Motor driver type get/set/list"); |
75 | | - registerCommand("pos", Axis_commands::pos, "Axis position"); |
76 | | - registerCommand("maxspeed", Axis_commands::maxspeed, "Speed limit in deg/s"); |
77 | | - registerCommand("maxtorquerate", Axis_commands::maxtorquerate, "Torque rate limit in counts/ms"); |
78 | | - registerCommand("fxratio", Axis_commands::fxratio, "Effect ratio. Reduces effects excluding endstop. 255=100%"); |
| 64 | + registerCommand("power", Axis_commands::power, "Overall force strength",CMDFLAG_GET | CMDFLAG_SET); |
| 65 | + registerCommand("degrees", Axis_commands::degrees, "Rotation range in deg",CMDFLAG_GET | CMDFLAG_SET); |
| 66 | + registerCommand("esgain", Axis_commands::esgain, "Endstop stiffness",CMDFLAG_GET | CMDFLAG_SET); |
| 67 | + registerCommand("zeroenc", Axis_commands::zeroenc, "Zero axis",CMDFLAG_GET); |
| 68 | + registerCommand("invert", Axis_commands::invert, "Invert axis",CMDFLAG_GET | CMDFLAG_SET); |
| 69 | + registerCommand("idlespring", Axis_commands::idlespring, "Idle spring strength",CMDFLAG_GET | CMDFLAG_SET); |
| 70 | + registerCommand("axisdamper", Axis_commands::axisdamper, "Independent damper effect",CMDFLAG_GET | CMDFLAG_SET); |
| 71 | + registerCommand("enctype", Axis_commands::enctype, "Encoder type get/set/list",CMDFLAG_GET | CMDFLAG_SET | CMDFLAG_INFOSTRING); |
| 72 | + registerCommand("drvtype", Axis_commands::drvtype, "Motor driver type get/set/list",CMDFLAG_GET | CMDFLAG_SET | CMDFLAG_INFOSTRING); |
| 73 | + registerCommand("pos", Axis_commands::pos, "Axis position",CMDFLAG_GET); |
| 74 | + registerCommand("maxspeed", Axis_commands::maxspeed, "Speed limit in deg/s",CMDFLAG_GET | CMDFLAG_SET); |
| 75 | + registerCommand("maxtorquerate", Axis_commands::maxtorquerate, "Torque rate limit in counts/ms",CMDFLAG_GET | CMDFLAG_SET); |
| 76 | + registerCommand("fxratio", Axis_commands::fxratio, "Effect ratio. Reduces effects excluding endstop. 255=100%",CMDFLAG_GET | CMDFLAG_SET); |
79 | 77 | } |
80 | 78 |
|
81 | 79 | /* |
@@ -696,211 +694,7 @@ CommandStatus Axis::command(const ParsedCommand& cmd,std::vector<CommandReply>& |
696 | 694 | } |
697 | 695 | return CommandStatus::OK; |
698 | 696 | } |
699 | | -// |
700 | | -//ParseStatus Axis::command(ParsedCommand_old *cmd, std::string *reply) |
701 | | -//{ |
702 | | -// if ((cmd->prefix & 0xDF) != axis){ |
703 | | -// return ParseStatus::NOT_FOUND; |
704 | | -// } |
705 | | -// |
706 | | -// ParseStatus flag = ParseStatus::OK; |
707 | | -// |
708 | | -// if (cmd->cmd == "drvtype") |
709 | | -// { |
710 | | -// if (cmd->type == CMDtype::get) |
711 | | -// { |
712 | | -// *reply += std::to_string(this->getDrvType()); |
713 | | -// } |
714 | | -// else if (cmd->type == CMDtype::set && this->drv_chooser.isValidClassId(cmd->val)) |
715 | | -// { |
716 | | -// setDrvType((cmd->val)); |
717 | | -// } |
718 | | -// else |
719 | | -// { |
720 | | -// *reply += drv_chooser.printAvailableClasses(this->conf.drvtype); |
721 | | -// } |
722 | | -// } |
723 | | -// else if (cmd->cmd == "zeroenc") |
724 | | -// { |
725 | | -// if (cmd->type == CMDtype::get) |
726 | | -// { |
727 | | -// this->setPos(0); |
728 | | -// *reply += "Zeroed"; |
729 | | -// } |
730 | | -// } |
731 | | -// else if (cmd->cmd == "enctype") |
732 | | -// { |
733 | | -// if (cmd->type == CMDtype::get) |
734 | | -// { |
735 | | -// *reply += std::to_string(this->getEncType()); |
736 | | -// } |
737 | | -// else if (cmd->type == CMDtype::set) |
738 | | -// { |
739 | | -// setEncType(cmd->val); |
740 | | -// } |
741 | | -// else |
742 | | -// { |
743 | | -// if(this->drv->hasIntegratedEncoder()){ |
744 | | -// *reply += "255:0:"+std::string(this->drv->getInfo().name); // TODO dynamic? |
745 | | -// }else{ |
746 | | -// *reply += enc_chooser.printAvailableClasses(this->conf.enctype); |
747 | | -// } |
748 | | -// } |
749 | | -// } |
750 | | -// else if (cmd->cmd == "pos") |
751 | | -// { |
752 | | -// if (cmd->type == CMDtype::get) |
753 | | -// { |
754 | | -// *reply += std::to_string(this->drv->getEncoder()->getPos()); |
755 | | -// } |
756 | | -// else if (cmd->type == CMDtype::set && this->drv->getEncoder() != nullptr) |
757 | | -// { |
758 | | -// this->drv->getEncoder()->setPos(cmd->val); |
759 | | -// } |
760 | | -// else |
761 | | -// { |
762 | | -// flag = ParseStatus::ERR; |
763 | | -// *reply += "Err. Setup encoder first"; |
764 | | -// } |
765 | | -// } |
766 | | -// else if (cmd->cmd == "maxspeed") |
767 | | -// { |
768 | | -// if (cmd->type == CMDtype::get) |
769 | | -// { |
770 | | -// *reply += std::to_string(maxSpeedDegS); |
771 | | -// } |
772 | | -// else if (cmd->type == CMDtype::set) |
773 | | -// { |
774 | | -// maxSpeedDegS = cmd->val; |
775 | | -// //speedScalerNormalized = getNormalizedSpeedScaler(maxSpeedDegS, degreesOfRotation); |
776 | | -// |
777 | | -// } |
778 | | -// }else if (cmd->cmd == "maxtorquerate") |
779 | | -// { |
780 | | -// if (cmd->type == CMDtype::get) |
781 | | -// { |
782 | | -// *reply += std::to_string(maxTorqueRateMS); |
783 | | -// } |
784 | | -// else if (cmd->type == CMDtype::set) |
785 | | -// { |
786 | | -// maxTorqueRateMS = cmd->val; |
787 | | -// //speedScalerNormalized = getNormalizedSpeedScaler(maxSpeedDegS, degreesOfRotation); |
788 | | -// |
789 | | -// } |
790 | | -// } |
791 | | -//// else if (cmd->cmd == "maxaccel") |
792 | | -//// { |
793 | | -//// if (cmd->type == CMDtype::get) |
794 | | -//// { |
795 | | -//// *reply += std::to_string((uint16_t)(maxAccelDegSS*accelFactor)); |
796 | | -//// } |
797 | | -//// else if (cmd->type == CMDtype::set) |
798 | | -//// { |
799 | | -//// maxAccelDegSS = cmd->val / accelFactor; |
800 | | -//// //accelScalerNormalized = getNormalizedAccelScaler(maxAccelDegSS, degreesOfRotation); |
801 | | -//// } |
802 | | -//// } |
803 | | -// else if (cmd->cmd == "fxratio") |
804 | | -// { |
805 | | -// if (cmd->type == CMDtype::get) |
806 | | -// { |
807 | | -// *reply += std::to_string(fx_ratio_i); |
808 | | -// } |
809 | | -// else if (cmd->type == CMDtype::set) |
810 | | -// { |
811 | | -// setFxRatio(cmd->val); |
812 | | -// } |
813 | | -// } |
814 | | -// else if (cmd->cmd == "power") |
815 | | -// { |
816 | | -// if (cmd->type == CMDtype::get) |
817 | | -// { |
818 | | -// *reply += std::to_string(power); |
819 | | -// } |
820 | | -// else if (cmd->type == CMDtype::set) |
821 | | -// { |
822 | | -// setPower(cmd->val); |
823 | | -// } |
824 | | -// } |
825 | | -// else if (cmd->cmd == "degrees") |
826 | | -// { |
827 | | -// if (cmd->type == CMDtype::get) |
828 | | -// { |
829 | | -// *reply += std::to_string(degreesOfRotation); |
830 | | -// } |
831 | | -// else if (cmd->type == CMDtype::set) |
832 | | -// { |
833 | | -// setDegrees(cmd->val); |
834 | | -// } |
835 | | -// } |
836 | | -// else if (cmd->cmd == "esgain") |
837 | | -// { |
838 | | -// if (cmd->type == CMDtype::get) |
839 | | -// { |
840 | | -// *reply += std::to_string(endstop_gain); |
841 | | -// } |
842 | | -// else if (cmd->type == CMDtype::set) |
843 | | -// { |
844 | | -// endstop_gain = cmd->val; |
845 | | -// } |
846 | | -// } |
847 | | -// else if (cmd->cmd == "invert") |
848 | | -// { |
849 | | -// if (cmd->type == CMDtype::get) |
850 | | -// { |
851 | | -// *reply += invertAxis ? "1" : "0"; |
852 | | -// } |
853 | | -// else if (cmd->type == CMDtype::set) |
854 | | -// { |
855 | | -// invertAxis = cmd->val >= 1 ? true : false; |
856 | | -// } |
857 | | -// } |
858 | | -// else if (cmd->cmd == "idlespring") |
859 | | -// { |
860 | | -// if (cmd->type == CMDtype::get) |
861 | | -// { |
862 | | -// *reply += std::to_string(idlespringstrength); |
863 | | -// } |
864 | | -// else if (cmd->type == CMDtype::set) |
865 | | -// { |
866 | | -// setIdleSpringStrength(cmd->val); |
867 | | -// } |
868 | | -// } |
869 | | -// else if (cmd->cmd == "axisdamper") |
870 | | -// { |
871 | | -// if (cmd->type == CMDtype::get) |
872 | | -// { |
873 | | -// *reply += std::to_string(damperIntensity); |
874 | | -// } |
875 | | -// else if (cmd->type == CMDtype::set) |
876 | | -// { |
877 | | -// setDamperStrength(cmd->val); |
878 | | -// } |
879 | | -// } |
880 | | -//// else if (cmd->cmd == "calibmetrics") |
881 | | -//// { |
882 | | -//// if (cmd->type == CMDtype::get) |
883 | | -//// { |
884 | | -//// *reply += std::to_string(getSpeedRPMFromEncValue(calibMaxSpeedNormalized, degreesOfRotation)) + ':' |
885 | | -//// + std::to_string(getAccelFromEncValue(calibMaxAccelNormalized, degreesOfRotation)); |
886 | | -//// } |
887 | | -//// else if (cmd->type == CMDtype::set) |
888 | | -//// { |
889 | | -//// if (cmd->val == 1) { |
890 | | -//// calibrationInProgress = true; |
891 | | -//// calibMaxAccelNormalized = 0.0; |
892 | | -//// calibMaxSpeedNormalized = 0; |
893 | | -//// } else { |
894 | | -//// calibrationInProgress = false; |
895 | | -//// } |
896 | | -//// } |
897 | | -//// } |
898 | | -// else{ |
899 | | -// flag = ParseStatus::NOT_FOUND; |
900 | | -// } |
901 | | -// |
902 | | -// return flag; |
903 | | -//}; |
| 697 | + |
904 | 698 |
|
905 | 699 |
|
906 | 700 | /* |
|
0 commit comments